Chore: IndentPPDirectives: BeforeHash [ci skip]

This commit is contained in:
李通洲
2026-04-15 16:16:46 +08:00
parent b63bd5b8c9
commit abc6c0593c
133 changed files with 1329 additions and 1329 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ SpacesInLineCommentPrefix:
SpacesInContainerLiterals: true
SortIncludes: Never
IndentPPDirectives: AfterHash
IndentPPDirectives: BeforeHash
PPIndentWidth: 4
IndentCaseLabels: true
+3 -3
View File
@@ -11,15 +11,15 @@
#include <assert.h>
#ifdef FF_USE_SYSTEM_YYJSON
# include <yyjson.h>
#include <yyjson.h>
#else
# include "3rdparty/yyjson/yyjson.h"
#include "3rdparty/yyjson/yyjson.h"
#endif
#ifdef _WIN32
// #include <shlwapi.h>
__stdcall char* StrStrIA(const char* lpFirst, const char* lpSrch);
# define strcasestr StrStrIA
#define strcasestr StrStrIA
#endif
#define FASTFETCH_STRBUF_DEFAULT_ALLOC 32
+8 -8
View File
@@ -3,14 +3,14 @@
#include <assert.h>
#ifdef __has_builtin
# if !__cplusplus && FF_SUPPORTS_COUNT_OF
# define ARRAY_SIZE(x) _Countof(x)
# elif __has_builtin(__is_array)
# define ARRAY_SIZE(x) ({ static_assert(__is_array(__typeof__(x)), "Must be an array"); (uint32_t) (sizeof(x) / sizeof(*(x))); })
# elif __has_builtin(__builtin_types_compatible_p)
# define ARRAY_SIZE(x) ({ static_assert(!__builtin_types_compatible_p(__typeof__(x), __typeof__(&*(x))), "Must not be a pointer"); (uint32_t) (sizeof(x) / sizeof(*(x))); })
# endif
#if !__cplusplus && FF_SUPPORTS_COUNT_OF
#define ARRAY_SIZE(x) _Countof(x)
#elif __has_builtin(__is_array)
#define ARRAY_SIZE(x) ({ static_assert(__is_array(__typeof__(x)), "Must be an array"); (uint32_t) (sizeof(x) / sizeof(*(x))); })
#elif __has_builtin(__builtin_types_compatible_p)
#define ARRAY_SIZE(x) ({ static_assert(!__builtin_types_compatible_p(__typeof__(x), __typeof__(&*(x))), "Must not be a pointer"); (uint32_t) (sizeof(x) / sizeof(*(x))); })
#endif
#endif
#ifndef ARRAY_SIZE
# define ARRAY_SIZE(x) ((uint32_t) (sizeof(x) / sizeof(*(x))))
#define ARRAY_SIZE(x) ((uint32_t) (sizeof(x) / sizeof(*(x))))
#endif
+1 -1
View File
@@ -1,7 +1,7 @@
#pragma once
#ifdef _MSC_VER
# define __attribute__(x)
#define __attribute__(x)
#endif
#define FF_A_FALLTHROUGH __attribute__((__fallthrough__))
+4 -4
View File
@@ -1,10 +1,10 @@
#pragma once
#ifdef FF_HAVE_DBUS
# include <dbus/dbus.h>
#include <dbus/dbus.h>
# include "common/FFstrbuf.h"
# include "common/library.h"
#include "common/FFstrbuf.h"
#include "common/library.h"
typedef struct FFDBusLibrary {
FF_LIBRARY_SYMBOL(dbus_bus_get)
@@ -41,6 +41,6 @@ static inline DBusMessage* ffDBusGetAllProperties(FFDBusData* dbus, const char*
return ffDBusGetMethodReply(dbus, busName, objectPath, "org.freedesktop.DBus.Properties", "GetAll", interface, NULL);
}
# define FF_DBUS_AUTO_DESTROY_DATA FF_A_CLEANUP(ffDBusDestroyData)
#define FF_DBUS_AUTO_DESTROY_DATA FF_A_CLEANUP(ffDBusDestroyData)
#endif // FF_HAVE_DBUS
+2 -2
View File
@@ -17,13 +17,13 @@ static inline const char* ffFindFileName(const char* file) {
}
#ifndef NDEBUG
# define FF_DEBUG_PRINT(file_, line_, format_, ...) \
#define FF_DEBUG_PRINT(file_, line_, format_, ...) \
do { \
if (instance.config.display.debugMode) \
fprintf(stderr, "[%s%4d, %s] " format_ "\n", ffFindFileName(file_), line_, ffTimeToTimeStr(ffTimeGetNow()), ##__VA_ARGS__); \
} while (0)
#else
# define FF_DEBUG_PRINT(file_, line_, format_, ...) \
#define FF_DEBUG_PRINT(file_, line_, format_, ...) \
do { \
} while (0)
#endif
+11 -11
View File
@@ -12,17 +12,17 @@
#include <paths.h>
#ifdef __APPLE__
# include <mach-o/dyld.h>
# include <sys/sysctl.h>
#include <mach-o/dyld.h>
#include <sys/sysctl.h>
#elif defined(__FreeBSD__) || defined(__NetBSD__)
# include <sys/sysctl.h>
#include <sys/sysctl.h>
#elif defined(__OpenBSD__)
# include <sys/sysctl.h>
# include <kvm.h>
# include "common/path.h"
#include <sys/sysctl.h>
#include <kvm.h>
#include "common/path.h"
#elif defined(__HAIKU__)
# include <image.h>
# include <OS.h>
#include <image.h>
#include <OS.h>
#endif
static void getExePath(FFPlatform* platform) {
@@ -43,15 +43,15 @@ static void getExePath(FFPlatform* platform) {
size_t exePathLen = sizeof(exePath);
if (sysctl(
(int[]) { CTL_KERN,
# ifdef __FreeBSD__
#ifdef __FreeBSD__
KERN_PROC,
KERN_PROC_PATHNAME,
(pid_t) platform->pid
# else
#else
KERN_PROC_ARGS,
(pid_t) platform->pid,
KERN_PROC_PATHNAME
# endif
#endif
},
4,
exePath,
+5 -5
View File
@@ -2,12 +2,12 @@
#if defined(FF_HAVE_ELF) || defined(__sun) || (defined(__FreeBSD__) && !defined(__DragonFly__)) || defined(__OpenBSD__) || defined(__NetBSD__)
# include "common/io.h"
# include "common/library.h"
# include "common/stringUtils.h"
#include "common/io.h"
#include "common/library.h"
#include "common/stringUtils.h"
# include <libelf.h> // #1254
# include <fcntl.h>
#include <libelf.h> // #1254
#include <fcntl.h>
/**
* Structure to hold dynamically loaded libelf function pointers
+2 -2
View File
@@ -2,8 +2,8 @@
#ifdef FF_HAVE_DBUS
# include "common/thread.h"
# include "common/stringUtils.h"
#include "common/thread.h"
#include "common/stringUtils.h"
static bool loadLibSymbols(FFDBusLibrary* lib) {
FF_LIBRARY_LOAD(dbus, false, "libdbus-1" FF_LIBRARY_EXTENSION, 4);
+3 -3
View File
@@ -11,10 +11,10 @@
#include <unistd.h>
#include <locale.h>
#ifdef _WIN32
# include <windows.h>
# include "common/windows/unicode.h"
#include <windows.h>
#include "common/windows/unicode.h"
#else
# include <signal.h>
#include <signal.h>
#endif
FFinstance instance; // Global singleton
+8 -8
View File
@@ -8,15 +8,15 @@
#include <dirent.h>
#include <errno.h>
#ifndef __APPLE__
# include <poll.h>
#include <poll.h>
#else
# include <sys/select.h>
#include <sys/select.h>
#endif
#if FF_HAVE_WORDEXP
# include <wordexp.h>
#include <wordexp.h>
#else
# include <glob.h>
#include <glob.h>
#endif
static void createSubfolders(const char* fileName) {
@@ -112,12 +112,12 @@ bool ffPathExpandEnv(const char* in, FFstrbuf* out) {
glob_t gb;
if (glob(in, GLOB_NOSORT
# ifdef GLOB_TILDE
#ifdef GLOB_TILDE
| GLOB_TILDE
# endif
# ifdef GLOB_BRACE
#endif
#ifdef GLOB_BRACE
| GLOB_BRACE
# endif
#endif
,
NULL,
&gb) != 0)
+21 -21
View File
@@ -2,35 +2,35 @@
#include "common/library.h"
#if _WIN32
# include "common/debug.h"
# include "common/windows/nt.h"
# include <errno.h>
# include <ntstatus.h>
#include "common/debug.h"
#include "common/windows/nt.h"
#include <errno.h>
#include <ntstatus.h>
#endif
#ifndef FF_DISABLE_DLOPEN
# include <stdarg.h>
#include <stdarg.h>
// Clang doesn't define __SANITIZE_ADDRESS__ but defines __has_feature(address_sanitizer)
# if !defined(__SANITIZE_ADDRESS__) && defined(__has_feature)
# if __has_feature(address_sanitizer)
# define __SANITIZE_ADDRESS__
# endif
# endif
// Clang doesn't define __SANITIZE_ADDRESS__ but defines __has_feature(address_sanitizer)
#if !defined(__SANITIZE_ADDRESS__) && defined(__has_feature)
#if __has_feature(address_sanitizer)
#define __SANITIZE_ADDRESS__
#endif
#endif
# ifndef FF_DLOPEN_FLAGS
# ifdef __SANITIZE_ADDRESS__
# define FF_DLOPEN_FLAGS RTLD_LAZY | RTLD_NODELETE
# else
# define FF_DLOPEN_FLAGS RTLD_LAZY
# endif
# endif
#ifndef FF_DLOPEN_FLAGS
#ifdef __SANITIZE_ADDRESS__
#define FF_DLOPEN_FLAGS RTLD_LAZY | RTLD_NODELETE
#else
#define FF_DLOPEN_FLAGS RTLD_LAZY
#endif
#endif
static void* libraryLoad(const char* path, int maxVersion) {
void* result = dlopen(path, FF_DLOPEN_FLAGS);
# ifdef _WIN32
#ifdef _WIN32
// libX.dll.1 never exists on Windows, while libX-1.dll may exist
FF_UNUSED(maxVersion)
@@ -48,7 +48,7 @@ static void* libraryLoad(const char* path, int maxVersion) {
strcpy(mempcpy(absPath, instance.state.platform.exePath.chars, pathLen + 1), path);
return dlopen(absPath, FF_DLOPEN_FLAGS);
# else
#else
if (result != NULL || maxVersion < 0) {
return result;
@@ -70,7 +70,7 @@ static void* libraryLoad(const char* path, int maxVersion) {
ffStrbufSubstrBefore(&pathbuf, originalLength);
}
# endif
#endif
return result;
}
+2 -2
View File
@@ -1,8 +1,8 @@
#include "common/netif.h"
#ifndef _WIN32
# include <net/if.h>
# include <netinet/in.h>
#include <net/if.h>
#include <netinet/in.h>
#endif
const FFNetifDefaultRouteResult* ffNetifGetDefaultRouteV4(void) {
+5 -5
View File
@@ -11,13 +11,13 @@
#define ROUNDUP2(a, n) ((a) > 0 ? (1 + (((a) - 1U) | ((n) - 1))) : (n))
#if __APPLE__
// https://github.com/apple-oss-distributions/network_cmds/blob/8f38231438e6a4d16ef8015e97e12c2c05105644/rtsol.tproj/if.c#L243
# define ROUNDUP(a) ROUNDUP2((a), sizeof(uint32_t))
// https://github.com/apple-oss-distributions/network_cmds/blob/8f38231438e6a4d16ef8015e97e12c2c05105644/rtsol.tproj/if.c#L243
#define ROUNDUP(a) ROUNDUP2((a), sizeof(uint32_t))
#elif __sun
// https://github.com/illumos/illumos-gate/blob/95b8c88950fa7b19af46bc63230137cf96b0bff7/usr/src/cmd/cmd-inet/usr.sbin/route.c#L339
# define ROUNDUP(a) ROUNDUP2((a), sizeof(long))
// https://github.com/illumos/illumos-gate/blob/95b8c88950fa7b19af46bc63230137cf96b0bff7/usr/src/cmd/cmd-inet/usr.sbin/route.c#L339
#define ROUNDUP(a) ROUNDUP2((a), sizeof(long))
#else
# error unknown platform
#error unknown platform
#endif
static struct sockaddr*
+9 -9
View File
@@ -12,19 +12,19 @@
#define ROUNDUP2(a, n) ((a) > 0 ? (1 + (((a) - 1U) | ((n) - 1))) : (n))
#if __DragonFly__
// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/cf0aa2f1e47a3f0a6055fe427563cb3f3e627064/sys/net/route.h#L315C9-L315C19
# define ROUNDUP(a) ROUNDUP2((a), sizeof(long))
// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/cf0aa2f1e47a3f0a6055fe427563cb3f3e627064/sys/net/route.h#L315C9-L315C19
#define ROUNDUP(a) ROUNDUP2((a), sizeof(long))
#elif __FreeBSD__
// https://github.com/freebsd/freebsd-src/blob/e4c0ecba44b20ebb2e4d80978c2cb6d16b730cb9/sys/net/route.h#L368C9-L368C16
# define ROUNDUP(a) ROUNDUP2((a), sizeof(long))
// https://github.com/freebsd/freebsd-src/blob/e4c0ecba44b20ebb2e4d80978c2cb6d16b730cb9/sys/net/route.h#L368C9-L368C16
#define ROUNDUP(a) ROUNDUP2((a), sizeof(long))
#elif __NetBSD__
// https://github.com/NetBSD/src/blob/29beb637d057520c0ed37ac2cde966f7cc0cadf4/sys/net/route.h#L330
# define ROUNDUP(a) ROUNDUP2((a), sizeof(uint64_t))
// https://github.com/NetBSD/src/blob/29beb637d057520c0ed37ac2cde966f7cc0cadf4/sys/net/route.h#L330
#define ROUNDUP(a) ROUNDUP2((a), sizeof(uint64_t))
#elif __OpenBSD__
// https://github.com/openbsd/src/blob/ca647cfa4ec3ccb8360714bc0ebc32a394f7fb6a/regress/sys/netinet/bindconnect/bindconnect.c#L250
# define ROUNDUP(a) ROUNDUP2((a), sizeof(long))
// https://github.com/openbsd/src/blob/ca647cfa4ec3ccb8360714bc0ebc32a394f7fb6a/regress/sys/netinet/bindconnect/bindconnect.c#L250
#define ROUNDUP(a) ROUNDUP2((a), sizeof(long))
#else
# error unknown platform
#error unknown platform
#endif
static struct sockaddr*
+4 -4
View File
@@ -5,7 +5,7 @@
#include "common/debug.h"
#ifdef FF_HAVE_ZLIB
# include <zlib.h>
#include <zlib.h>
struct FFZlibLibrary {
FF_LIBRARY_SYMBOL(inflateInit2_)
@@ -19,11 +19,11 @@ const char* ffNetworkingLoadZlibLibrary(void) {
if (!zlibData.inited) {
zlibData.inited = true;
FF_LIBRARY_LOAD_MESSAGE(zlib,
# ifdef _WIN32
#ifdef _WIN32
"zlib1"
# else
#else
"libz"
# endif
#endif
FF_LIBRARY_EXTENSION,
2)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(zlib, zlibData, inflateInit2_)
+29 -29
View File
@@ -20,56 +20,56 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state) {
#if defined(TCP_FASTOPEN) || __APPLE__
if (!state->tfo) {
# if __linux__ || __GNU__
#if __linux__ || __GNU__
// Linux doesn't support sendto() on unconnected sockets
FF_DEBUG("TCP Fast Open disabled, skipping");
return "TCP Fast Open disabled";
# endif
#endif
} else {
FF_DEBUG("Attempting to use TCP Fast Open to connect");
# ifndef __APPLE__ // On macOS, TCP_FASTOPEN doesn't seem to be needed
#ifndef __APPLE__ // On macOS, TCP_FASTOPEN doesn't seem to be needed
// Set TCP Fast Open
int flag = 1;
if (setsockopt(state->sockfd, IPPROTO_TCP,
# ifdef __APPLE__
#ifdef __APPLE__
// https://github.com/rust-lang/libc/pull/3135
0x218 // TCP_FASTOPEN_FORCE_ENABLE
# else
#else
TCP_FASTOPEN
# endif
#endif
,
&flag,
sizeof(flag)) != 0) {
FF_DEBUG("Failed to set TCP_FASTOPEN option: %s", strerror(errno));
return "setsockopt(TCP_FASTOPEN) failed";
} else {
# if __linux__ || __GNU__
#if __linux__ || __GNU__
FF_DEBUG("Successfully set TCP_FASTOPEN option, queue length: %d", flag);
# elif defined(__APPLE__)
#elif defined(__APPLE__)
FF_DEBUG("Successfully set TCP_FASTOPEN_FORCE_ENABLE option");
# else
#else
FF_DEBUG("Successfully set TCP_FASTOPEN option");
# endif
#endif
}
# endif
#endif
}
# ifndef __APPLE__
#ifndef __APPLE__
FF_DEBUG("Using sendto() + MSG_DONTWAIT to send %u bytes of data", state->command.length);
ssize_t sent = sendto(state->sockfd,
state->command.chars,
state->command.length,
# ifdef MSG_FASTOPEN
#ifdef MSG_FASTOPEN
MSG_FASTOPEN |
# endif
# ifdef MSG_NOSIGNAL
#endif
#ifdef MSG_NOSIGNAL
MSG_NOSIGNAL |
# endif
#endif
MSG_DONTWAIT,
state->addr->ai_addr,
state->addr->ai_addrlen);
# else
#else
if (fcntl(state->sockfd, F_SETFL, O_NONBLOCK) == -1) {
FF_DEBUG("fcntl(F_SETFL) failed: %s", strerror(errno));
return "fcntl(F_SETFL) failed";
@@ -97,20 +97,20 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state) {
FF_DEBUG("fcntl(F_SETFL) failed: %s", strerror(errno));
return "fcntl(F_SETFL) failed";
}
# endif
#endif
if (sent > 0 || (errno == EAGAIN || errno == EWOULDBLOCK
# ifdef __APPLE__
#ifdef __APPLE__
// On macOS EINPROGRESS means the connection cannot be completed immediately
// On Linux, it means the TFO cookie is not available locally
|| errno == EINPROGRESS
# endif
#endif
)) {
FF_DEBUG(
# ifdef __APPLE__
#ifdef __APPLE__
"connectx()"
# else
#else
"sendto()"
# endif
#endif
" %s (sent=%zd, %s)",
errno == 0 ? "succeeded" : "was in progress",
sent,
@@ -122,18 +122,18 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state) {
}
FF_DEBUG(
# ifdef __APPLE__
#ifdef __APPLE__
"connectx()"
# else
#else
"sendto()"
# endif
#endif
" failed: %s",
strerror(errno));
# ifdef __APPLE__
#ifdef __APPLE__
return "connectx() failed";
# else
#else
return "sendto() failed";
# endif
#endif
#else
FF_UNUSED(state);
return "TFO support is not available";
+3 -3
View File
@@ -4,8 +4,8 @@
#include <ctype.h>
#ifdef _WIN32
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat"
#endif
void ffParseSemver(FFstrbuf* buffer, const FFstrbuf* major, const FFstrbuf* minor, const FFstrbuf* patch) {
@@ -124,5 +124,5 @@ void ffParseGTK(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, co
}
#ifdef _WIN32
# pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#endif
+15 -15
View File
@@ -9,17 +9,17 @@ const char* ffFindExecutableInPath(const char* name, FFstrbuf* result) {
return "$PATH not set";
}
# ifdef _WIN32
#ifdef _WIN32
const bool appendExe = !ffStrEndsWithIgnCase(name, ".exe");
# endif
#endif
for (char* token = path; *token; path = token + 1) {
token = strchr(path,
# ifdef _WIN32
#ifdef _WIN32
';'
# else
#else
':'
# endif
#endif
);
if (!token) {
token = path + strlen(path);
@@ -27,25 +27,25 @@ const char* ffFindExecutableInPath(const char* name, FFstrbuf* result) {
ffStrbufSetNS(result, (uint32_t) (token - path), path);
ffStrbufEnsureEndsWithC(result,
# ifdef _WIN32
#ifdef _WIN32
'\\'
# else
#else
'/'
# endif
#endif
);
ffStrbufAppendS(result, name);
# ifdef _WIN32
#ifdef _WIN32
if (appendExe) {
ffStrbufAppendS(result, ".exe");
}
if (!ffPathExists(result->chars, FF_PATHTYPE_FILE)) {
continue;
}
# else
#else
if (access(result->chars, X_OK) != 0) {
continue;
}
# endif
#endif
return NULL;
}
@@ -53,10 +53,10 @@ const char* ffFindExecutableInPath(const char* name, FFstrbuf* result) {
return "Executable not found";
}
#else
# include <windows.h>
# include <winioctl.h>
# include <errno.h>
# include <stdalign.h>
#include <windows.h>
#include <winioctl.h>
#include <errno.h>
#include <stdalign.h>
const char* ffFindExecutableInPath(const char* name, FFstrbuf* result) {
char buffer[MAX_PATH + 1];
+33 -33
View File
@@ -13,28 +13,28 @@
#include <sys/wait.h>
#if !(__ANDROID__ || __OpenBSD__)
# include <spawn.h>
#include <spawn.h>
#endif
#if defined(__FreeBSD__) || defined(__APPLE__)
# include <sys/types.h>
# include <sys/user.h>
# include <sys/sysctl.h>
#include <sys/types.h>
#include <sys/user.h>
#include <sys/sysctl.h>
#endif
#if defined(__APPLE__)
# include <libproc.h>
#include <libproc.h>
#elif defined(__sun)
# include <procfs.h>
#include <procfs.h>
#elif defined(__OpenBSD__)
# include <sys/param.h>
# include <sys/sysctl.h>
# include <kvm.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <kvm.h>
#elif defined(__NetBSD__)
# include <sys/types.h>
# include <sys/sysctl.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#elif defined(__HAIKU__)
# include <OS.h>
# include <image.h>
#include <OS.h>
#include <image.h>
#endif
#ifndef environ
@@ -234,9 +234,9 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
// For interpreters, try to find the real script path in the arguments
if (ffStrStartsWith(name, "python")
# ifndef __ANDROID__
#ifndef __ANDROID__
|| ffStrEquals(name, "guile") // for shepherd
# endif
#endif
) {
// `cmdline` always ends with a trailing '\0', and ffReadFileBuffer appends another \0
// So `exe->chars` is always double '\0' terminated
@@ -341,15 +341,15 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
static_assert(ARG_MAX > PATH_MAX, "");
if (exePath && sysctl((int[]) { CTL_KERN,
# if __FreeBSD__
#if __FreeBSD__
KERN_PROC,
KERN_PROC_PATHNAME,
pid
# else
#else
KERN_PROC_ARGS,
pid,
KERN_PROC_PATHNAME
# endif
#endif
},
4,
args,
@@ -361,15 +361,15 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
size = ARG_MAX;
if (sysctl(
(int[]) { CTL_KERN,
# if __FreeBSD__
#if __FreeBSD__
KERN_PROC,
KERN_PROC_ARGS,
pid
# else
#else
KERN_PROC_ARGS,
pid,
KERN_PROC_ARGV,
# endif
#endif
},
4,
args,
@@ -476,9 +476,9 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
#if defined(__linux__) || defined(__GNU__)
char procFilePath[64];
# if __linux__
#if __linux__
if (ppid || tty)
# endif
#endif
{
snprintf(procFilePath, sizeof(procFilePath), "/proc/%d/stat", (int) pid);
char buf[PROC_FILE_BUFFSIZ];
@@ -509,9 +509,9 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
pState = end + 2; // skip ") "
}
# if !__linux__
#if !__linux__
if (ppid || tty)
# endif
#endif
{
int ppid_, tty_;
if (sscanf(pState + 2, "%d %*d %*d %d", &ppid_, &tty_) < 2) {
@@ -526,7 +526,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
}
}
}
# if __linux__
#if __linux__
else {
snprintf(procFilePath, sizeof(procFilePath), "/proc/%d/comm", (int) pid);
ssize_t nRead = ffReadFileBuffer(procFilePath, name);
@@ -535,7 +535,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
}
ffStrbufTrimRightSpace(name);
}
# endif
#endif
#elif defined(__APPLE__)
@@ -558,12 +558,12 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
#elif defined(__FreeBSD__)
# ifdef __DragonFly__
# define ki_comm kp_comm
# define ki_ppid kp_ppid
# define ki_tdev kp_tdev
# define ki_flag kp_flags
# endif
#ifdef __DragonFly__
#define ki_comm kp_comm
#define ki_ppid kp_ppid
#define ki_tdev kp_tdev
#define ki_flag kp_flags
#endif
struct kinfo_proc proc;
size_t size = sizeof(proc);
+1 -1
View File
@@ -6,7 +6,7 @@
#include <stdlib.h>
#include <ctype.h>
#ifdef _WIN32
# include "common/windows/getline.h"
#include "common/windows/getline.h"
#endif
bool ffParsePropLinePointer(const char** line, const char* start, FFstrbuf* buffer) {
+7 -7
View File
@@ -7,7 +7,7 @@
#include <string.h>
#ifdef FF_HAVE_GIO
# include <gio/gio.h>
#include <gio/gio.h>
typedef struct GVariantGetters {
FF_LIBRARY_SYMBOL(g_variant_dup_string)
@@ -124,7 +124,7 @@ FFvariant ffSettingsGetGSettings(const char* schemaName, const char* path, const
#endif // FF_HAVE_GIO
#ifdef FF_HAVE_DCONF
# include <dconf.h>
#include <dconf.h>
typedef struct DConfData {
FF_LIBRARY_SYMBOL(dconf_client_read_full)
@@ -200,7 +200,7 @@ FFvariant ffSettingsGetGnome(const char* dconfKey, const char* gsettingsSchemaNa
}
#ifdef FF_HAVE_DBUS
# include "common/dbus.h"
#include "common/dbus.h"
FFvariant ffSettingsGetXFConf(const char* channelName, const char* propertyName, FFvarianttype type) {
FF_DBUS_AUTO_DESTROY_DATA FFDBusData dbus = {};
@@ -248,7 +248,7 @@ FFvariant ffSettingsGetXFConf(const char* channelName, const char* propertyName,
return FF_VARIANT_NULL;
}
# define FF_DBUS_ITER_CONTINUE(dbus, iterator) \
#define FF_DBUS_ITER_CONTINUE(dbus, iterator) \
{ \
if (!(dbus).lib->ffdbus_message_iter_next(iterator)) \
break; \
@@ -334,7 +334,7 @@ FFvariant ffSettingsGetXFConfFirstMatch(const char* channelName, const char* pro
#endif // FF_HAVE_DBUS
#ifdef FF_HAVE_SQLITE3
# include <sqlite3.h>
#include <sqlite3.h>
typedef struct SQLiteData {
FF_LIBRARY_SYMBOL(sqlite3_open_v2)
@@ -454,7 +454,7 @@ bool ffSettingsGetSQLite3String(const char* dbPath, const char* query, FFstrbuf*
#endif // FF_HAVE_SQLITE3
#ifdef __ANDROID__
# include <sys/system_properties.h>
#include <sys/system_properties.h>
bool ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result) {
ffStrbufEnsureFree(result, PROP_VALUE_MAX);
int len = __system_property_get(propName, result->chars + result->length);
@@ -466,7 +466,7 @@ bool ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result) {
return true;
}
#elif defined(__FreeBSD__)
# include <kenv.h>
#include <kenv.h>
bool ffSettingsGetFreeBSDKenv(const char* propName, FFstrbuf* result) {
// https://wiki.ghostbsd.org/index.php/Kenv
ffStrbufEnsureFree(result, KENV_MVALLEN);
+41 -41
View File
@@ -141,21 +141,21 @@ static bool parseSmbiosTable(const uint8_t* data, uint32_t length) {
}
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__sun) || defined(__HAIKU__) || defined(__OpenBSD__) || defined(__GNU__)
# include <fcntl.h>
# include <sys/stat.h>
# include <sys/types.h>
# include <sys/mman.h>
# include <stddef.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <stddef.h>
# ifdef __linux__
# include "common/properties.h"
# elif defined(__FreeBSD__)
# include "common/settings.h"
# elif defined(__NetBSD__)
# include "common/sysctl.h"
# endif
#ifdef __linux__
#include "common/properties.h"
#elif defined(__FreeBSD__)
#include "common/settings.h"
#elif defined(__NetBSD__)
#include "common/sysctl.h"
#endif
# ifdef __linux__
#ifdef __linux__
bool ffGetSmbiosValue(const char* devicesPath, const char* classPath, FFstrbuf* buffer) {
// /sys/class/dmi/id/* are all pseudo-files with very small content
// so reading the whole file at once is efficient
@@ -186,10 +186,10 @@ bool ffGetSmbiosValue(const char* devicesPath, const char* classPath, FFstrbuf*
ffStrbufClear(buffer);
return false;
}
# endif
#endif
static bool readPhysicalMemory(int fd, off_t address, size_t length, void* buffer) {
# if !defined(__FreeBSD__) // Either causes kernel panic or returns EFAULT
#if !defined(__FreeBSD__) // Either causes kernel panic or returns EFAULT
// -1: unknown, 0: failed before (stop trying), 1: succeeded before
static int preadState = -1;
if (preadState != 0) {
@@ -208,7 +208,7 @@ static bool readPhysicalMemory(int fd, off_t address, size_t length, void* buffe
} else {
FF_DEBUG("Skipping pread due to cached failure; using mmap");
}
# endif
#endif
off_t alignedAddress = address & ~((off_t) instance.state.platform.sysinfo.pageSize - 1);
size_t pageOffset = (size_t) (address - alignedAddress);
@@ -270,11 +270,11 @@ typedef union FFSmbiosEntryPoint {
static bool fillTableBufferFallback(FFstrbuf* buffer) {
const char* devMem =
# if __HAIKU__
#if __HAIKU__
"/dev/misc/mem";
# else
#else
"/dev/mem"; // kern.securelevel must be -1
# endif
#endif
FF_DEBUG("Using physical memory searching implementation: %s", devMem);
uint32_t tableLength = 0;
@@ -355,7 +355,7 @@ static bool fillTableBufferFallback(FFstrbuf* buffer) {
return true;
}
# ifdef __OpenBSD__
#ifdef __OpenBSD__
static bool detectSmbiosTableLength(const uint8_t* data, uint32_t bufferLength, uint32_t* tableLength) {
const uint8_t* p = data;
const uint8_t* end = data + bufferLength;
@@ -500,26 +500,26 @@ static bool fillTableBufferPlatform(FFstrbuf* buffer) {
ffStrbufClear(buffer);
return false;
}
# else
#else
static bool fillTableBufferPlatform(FFstrbuf* buffer) {
# if __HAIKU__ && __GNU__
#if __HAIKU__ && __GNU__
return false;
# elif defined(__linux__)
#elif defined(__linux__)
FF_DEBUG("Using Linux implementation - trying /sys/firmware/dmi/tables/DMI");
if (!ffAppendFileBuffer("/sys/firmware/dmi/tables/DMI", buffer))
# else
#else
{
# if !defined(__sun) && !defined(__NetBSD__)
#if !defined(__sun) && !defined(__NetBSD__)
FF_DEBUG("Using memory-mapped implementation");
FF_STRBUF_AUTO_DESTROY strEntryAddress = ffStrbufCreate();
# ifdef __FreeBSD__
#ifdef __FreeBSD__
FF_DEBUG("Using FreeBSD kenv implementation");
if (!ffSettingsGetFreeBSDKenv("hint.smbios.0.mem", &strEntryAddress)) {
FF_DEBUG("Failed to get SMBIOS address from FreeBSD kenv");
return false; // non-UEFI systems
}
FF_DEBUG("Got SMBIOS address from kenv: %s", strEntryAddress.chars);
# elif defined(__linux__)
#elif defined(__linux__)
{
FF_DEBUG("Using Linux EFI systab implementation");
FF_STRBUF_AUTO_DESTROY systab = ffStrbufCreate();
@@ -534,7 +534,7 @@ static bool fillTableBufferPlatform(FFstrbuf* buffer) {
}
FF_DEBUG("Found SMBIOS entry in systab: %s", strEntryAddress.chars);
}
# endif
#endif
off_t entryAddress = (off_t) strtol(strEntryAddress.chars, NULL, 16);
if (entryAddress == 0) {
@@ -558,14 +558,14 @@ static bool fillTableBufferPlatform(FFstrbuf* buffer) {
return false;
}
FF_DEBUG("Successfully read SMBIOS entry point data");
# else
#else
// Sun or NetBSD
FF_DEBUG("Using %s specific implementation",
# ifdef __NetBSD__
#ifdef __NetBSD__
"NetBSD"
# else
#else
"SunOS"
# endif
#endif
);
FF_AUTO_CLOSE_FD int fd = open("/dev/smbios", O_RDONLY | O_CLOEXEC);
@@ -576,7 +576,7 @@ static bool fillTableBufferPlatform(FFstrbuf* buffer) {
FF_DEBUG("/dev/smbios opened successfully with fd=%d", fd);
FFSmbiosEntryPoint entryPoint;
# ifdef __NetBSD__
#ifdef __NetBSD__
off_t addr = (off_t) ffSysctlGetInt64("machdep.smbios", 0);
if (addr == 0) {
FF_DEBUG("Failed to get SMBIOS address from sysctl");
@@ -589,15 +589,15 @@ static bool fillTableBufferPlatform(FFstrbuf* buffer) {
return false;
}
FF_DEBUG("Successfully read SMBIOS entry point");
# else
#else
FF_DEBUG("Reading SMBIOS entry point from /dev/smbios");
if (ffReadFDData(fd, sizeof(entryPoint), &entryPoint) < 1) {
FF_DEBUG("Failed to read SMBIOS entry point: %s", strerror(errno));
return false;
}
FF_DEBUG("Successfully read SMBIOS entry point");
# endif
# endif
#endif
#endif
uint32_t tableLength = 0;
off_t tableAddress = 0;
@@ -649,11 +649,11 @@ static bool fillTableBufferPlatform(FFstrbuf* buffer) {
return false;
}
}
# endif
#endif
return true;
}
# endif
#endif
const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() {
static FFstrbuf buffer;
@@ -684,9 +684,9 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() {
return &smbiosTable;
}
#elif defined(_WIN32)
# include "common/windows/nt.h"
#include "common/windows/nt.h"
# pragma GCC diagnostic ignored "-Wmultichar"
#pragma GCC diagnostic ignored "-Wmultichar"
typedef struct FFRawSmbiosData {
uint8_t Used20CallingMethod;
@@ -754,7 +754,7 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() {
return &smbiosTable;
}
#elif defined(__APPLE__)
# include "common/apple/cf_helpers.h"
#include "common/apple/cf_helpers.h"
const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() {
static CFDataRef smbiosDataBuffer;
+3 -3
View File
@@ -5,8 +5,8 @@
char ffTimeInternalBuffer[64]; // Reduce memory usage and prevent redundant allocations
#ifdef _WIN32
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat"
#endif
const char* ffTimeToFullStr(uint64_t msec) {
@@ -45,7 +45,7 @@ const char* ffTimeToTimeStr(uint64_t msec) {
}
#ifdef _WIN32
# pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#endif
FFTimeGetAgeResult ffTimeGetAge(uint64_t birthMs, uint64_t nowMs) {
+24 -24
View File
@@ -4,36 +4,36 @@
#include "common/FFlist.h"
#ifdef _WIN32
# include <fileapi.h>
# include <handleapi.h>
# include <io.h>
# include "common/windows/nt.h"
#include <fileapi.h>
#include <handleapi.h>
#include <io.h>
#include "common/windows/nt.h"
typedef HANDLE FFNativeFD;
# define FF_INVALID_FD INVALID_HANDLE_VALUE
#define FF_INVALID_FD INVALID_HANDLE_VALUE
#else
# include <unistd.h>
# include <dirent.h>
# include <sys/stat.h>
# include <errno.h>
# include <limits.h>
# include <fcntl.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
#include <errno.h>
#include <limits.h>
#include <fcntl.h>
typedef int FFNativeFD;
# define FF_INVALID_FD (-1)
// procfs's file can be changed between read calls such as /proc/meminfo and /proc/uptime.
// one safe way to read correct data is reading the whole file in a single read syscall
# define PROC_FILE_BUFFSIZ (32 * 1024)
#define FF_INVALID_FD (-1)
// procfs's file can be changed between read calls such as /proc/meminfo and /proc/uptime.
// one safe way to read correct data is reading the whole file in a single read syscall
#define PROC_FILE_BUFFSIZ (32 * 1024)
#endif
#ifdef _WIN32
# ifndef O_CLOEXEC
# define O_CLOEXEC 0
# endif
# ifndef O_RDONLY
# define O_RDONLY 0
# endif
# ifndef O_DIRECTORY
# define O_DIRECTORY 0200000
# endif
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
#ifndef O_RDONLY
#define O_RDONLY 0
#endif
#ifndef O_DIRECTORY
#define O_DIRECTORY 0200000
#endif
// Only O_RDONLY is supported
HANDLE openat(HANDLE dfd, const char* fileName, int oflag);
+36 -36
View File
@@ -4,22 +4,22 @@
#ifndef FF_DISABLE_DLOPEN
# if defined(_WIN32)
# define FF_DLOPEN_FLAGS 0
#if defined(_WIN32)
#define FF_DLOPEN_FLAGS 0
FF_A_NODISCARD void* dlopen(const char* path, int mode);
FF_A_NODISCARD void* dlsym(void* handle, const char* symbol);
int dlclose(void* handle);
# else
# include <dlfcn.h>
# endif
#else
#include <dlfcn.h>
#endif
# ifdef _WIN32
# define FF_LIBRARY_EXTENSION ".dll"
# elif defined(__APPLE__)
# define FF_LIBRARY_EXTENSION ".dylib"
# else
# define FF_LIBRARY_EXTENSION ".so"
# endif
#ifdef _WIN32
#define FF_LIBRARY_EXTENSION ".dll"
#elif defined(__APPLE__)
#define FF_LIBRARY_EXTENSION ".dylib"
#else
#define FF_LIBRARY_EXTENSION ".so"
#endif
static inline void ffLibraryUnload(void** handle) {
assert(handle);
@@ -28,78 +28,78 @@ static inline void ffLibraryUnload(void** handle) {
}
}
# if __cplusplus
# define __auto_type auto
# endif
#if __cplusplus
#define __auto_type auto
#endif
# define FF_LIBRARY_SYMBOL(symbolName) \
#define FF_LIBRARY_SYMBOL(symbolName) \
__typeof__(&symbolName) ff##symbolName;
# define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \
#define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \
void* FF_A_CLEANUP(ffLibraryUnload) libraryObjectName = ffLibraryLoad(__VA_ARGS__, NULL); \
if (libraryObjectName == NULL) \
return returnValue;
# define FF_LIBRARY_LOAD_MESSAGE(libraryObjectName, libraryFileName, maxVersion, ...) \
#define FF_LIBRARY_LOAD_MESSAGE(libraryObjectName, libraryFileName, maxVersion, ...) \
FF_LIBRARY_LOAD(libraryObjectName, "dlopen(" libraryFileName ") failed", libraryFileName, maxVersion, ##__VA_ARGS__)
# define FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, symbolMapping, symbolName, returnValue) \
#define FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, symbolMapping, symbolName, returnValue) \
symbolMapping = (__typeof__(&symbolName)) dlsym(library, #symbolName); \
if (symbolMapping == NULL) \
return returnValue;
# define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \
#define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \
__auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, returnValue);
# define FF_LIBRARY_LOAD_SYMBOL_LAZY(library, symbolName) \
#define FF_LIBRARY_LOAD_SYMBOL_LAZY(library, symbolName) \
__auto_type ff##symbolName = (__typeof__(&symbolName)) dlsym(library, #symbolName);
# define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \
#define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \
__auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, "dlsym " #symbolName " failed");
# define FF_LIBRARY_LOAD_SYMBOL_VAR(library, varName, symbolName, returnValue) \
#define FF_LIBRARY_LOAD_SYMBOL_VAR(library, varName, symbolName, returnValue) \
FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName).ff##symbolName, symbolName, returnValue);
# define FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(library, varName, symbolName) \
#define FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(library, varName, symbolName) \
FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName).ff##symbolName, symbolName, "dlsym " #symbolName " failed");
# define FF_LIBRARY_LOAD_SYMBOL_PTR(library, varName, symbolName, returnValue) \
#define FF_LIBRARY_LOAD_SYMBOL_PTR(library, varName, symbolName, returnValue) \
FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName)->ff##symbolName, symbolName, returnValue);
void* ffLibraryLoad(const char* path, int maxVersion, ...);
#else
# define FF_LIBRARY_EXTENSION ""
#define FF_LIBRARY_EXTENSION ""
# define FF_LIBRARY_SYMBOL(symbolName) \
#define FF_LIBRARY_SYMBOL(symbolName) \
__typeof__(&symbolName) ff##symbolName;
# define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \
#define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \
FF_A_UNUSED void* libraryObjectName = NULL; // Placeholder
# define FF_LIBRARY_LOAD_MESSAGE(libraryObjectName, libraryFileName, maxVersion, ...) \
#define FF_LIBRARY_LOAD_MESSAGE(libraryObjectName, libraryFileName, maxVersion, ...) \
FF_LIBRARY_LOAD(libraryObjectName, , libraryFileName, maxVersion, ##__VA_ARGS__)
# define FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, symbolMapping, symbolName, returnValue) \
#define FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, symbolMapping, symbolName, returnValue) \
symbolMapping = (__typeof__(&symbolName)) &symbolName;
# define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \
#define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \
FF_A_UNUSED __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, returnValue);
# define FF_LIBRARY_LOAD_SYMBOL_LAZY(library, symbolName) \
#define FF_LIBRARY_LOAD_SYMBOL_LAZY(library, symbolName) \
FF_A_UNUSED __auto_type ff##symbolName = (__typeof__(&symbolName)) &symbolName;
# define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \
#define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \
FF_A_UNUSED __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, "dlsym " #symbolName " failed");
# define FF_LIBRARY_LOAD_SYMBOL_VAR(library, varName, symbolName, returnValue) \
#define FF_LIBRARY_LOAD_SYMBOL_VAR(library, varName, symbolName, returnValue) \
FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName).ff##symbolName, symbolName, returnValue);
# define FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(library, varName, symbolName) \
#define FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(library, varName, symbolName) \
FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName).ff##symbolName, symbolName, "dlsym " #symbolName " failed");
# define FF_LIBRARY_LOAD_SYMBOL_PTR(library, varName, symbolName, returnValue) \
#define FF_LIBRARY_LOAD_SYMBOL_PTR(library, varName, symbolName, returnValue) \
FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName)->ff##symbolName, symbolName, returnValue);
#endif
+6 -6
View File
@@ -4,13 +4,13 @@
#include <assert.h>
#if FF_HAVE_MALLOC_USABLE_SIZE || FF_HAVE_MSVC_MSIZE
# if __has_include(<malloc.h>)
# include <malloc.h>
# else
# include <malloc_np.h> // For DragonFly BSD
# endif
#if __has_include(<malloc.h>)
#include <malloc.h>
#else
#include <malloc_np.h> // For DragonFly BSD
#endif
#elif FF_HAVE_MALLOC_SIZE
# include <malloc/malloc.h>
#include <malloc/malloc.h>
#endif
static inline void ffWrapFree(const void* pPtr) {
+2 -2
View File
@@ -3,8 +3,8 @@
#include "fastfetch.h"
#ifndef _WIN32
# include <net/if.h>
# include <netinet/in.h>
#include <net/if.h>
#include <netinet/in.h>
#endif
typedef enum FF_A_PACKED FFNetifDefaultRouteResultStatus {
+3 -3
View File
@@ -4,7 +4,7 @@
#include "common/FFstrbuf.h"
#ifdef _WIN32
# include <minwindef.h>
#include <minwindef.h>
#endif
struct addrinfo;
@@ -17,9 +17,9 @@ typedef struct FFNetworkingState {
int sockfd;
struct addrinfo* addr;
# ifdef FF_HAVE_THREADS
#ifdef FF_HAVE_THREADS
FFThreadType thread;
# endif
#endif
#endif
FFstrbuf command;
+1 -1
View File
@@ -3,7 +3,7 @@
#include "common/FFstrbuf.h"
#ifndef _WIN32
# include <sys/types.h> // pid_t
#include <sys/types.h> // pid_t
#endif
typedef struct FFProcessHandle {
+27 -27
View File
@@ -3,12 +3,12 @@
#include "fastfetch.h"
#ifdef FF_HAVE_THREADS
# if defined(_WIN32)
# include <winternl.h>
# include <synchapi.h>
# include <process.h>
# include <processthreadsapi.h>
# define FF_THREAD_MUTEX_INITIALIZER SRWLOCK_INIT
#if defined(_WIN32)
#include <winternl.h>
#include <synchapi.h>
#include <process.h>
#include <processthreadsapi.h>
#define FF_THREAD_MUTEX_INITIALIZER SRWLOCK_INIT
typedef SRWLOCK FFThreadMutex;
typedef HANDLE FFThreadType;
static inline void ffThreadMutexLock(FFThreadMutex* mutex) {
@@ -20,12 +20,12 @@ static inline void ffThreadMutexUnlock(FFThreadMutex* mutex) {
static inline FFThreadType ffThreadCreate(unsigned(__stdcall* func)(void*), void* data) {
return (FFThreadType) _beginthreadex(NULL, 0, func, data, 0, NULL);
}
# define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) \
#define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) \
static __stdcall unsigned fn##ThreadMain(void* data) { \
fn((paramType) data); \
return 0; \
}
# define FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(fn) \
#define FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(fn) \
static __stdcall unsigned fn##ThreadMain() { \
fn(); \
return 0; \
@@ -42,16 +42,16 @@ static inline bool ffThreadJoin(FFThreadType thread, uint32_t timeout) {
NtClose(thread);
return true;
}
# else
# include <pthread.h>
# include <signal.h>
# if FF_HAVE_PTHREAD_NP
# include <pthread_np.h>
# endif
#else
#include <pthread.h>
#include <signal.h>
#if FF_HAVE_PTHREAD_NP
#include <pthread_np.h>
#endif
typedef pthread_t FFThreadType;
# if __APPLE__
# include <os/lock.h>
# define FF_THREAD_MUTEX_INITIALIZER OS_UNFAIR_LOCK_INIT
#if __APPLE__
#include <os/lock.h>
#define FF_THREAD_MUTEX_INITIALIZER OS_UNFAIR_LOCK_INIT
typedef os_unfair_lock FFThreadMutex;
static inline void ffThreadMutexLock(os_unfair_lock* mutex) {
os_unfair_lock_lock(mutex);
@@ -59,8 +59,8 @@ static inline void ffThreadMutexLock(os_unfair_lock* mutex) {
static inline void ffThreadMutexUnlock(os_unfair_lock* mutex) {
os_unfair_lock_unlock(mutex);
}
# else
# define FF_THREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
#else
#define FF_THREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
typedef pthread_mutex_t FFThreadMutex;
static inline void ffThreadMutexLock(FFThreadMutex* mutex) {
pthread_mutex_lock(mutex);
@@ -68,18 +68,18 @@ static inline void ffThreadMutexLock(FFThreadMutex* mutex) {
static inline void ffThreadMutexUnlock(FFThreadMutex* mutex) {
pthread_mutex_unlock(mutex);
}
# endif
#endif
static inline FFThreadType ffThreadCreate(void* (*func)(void*), void* data) {
FFThreadType newThread = 0;
pthread_create(&newThread, NULL, func, data);
return newThread;
}
# define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) \
#define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) \
static void* fn##ThreadMain(void* data) { \
fn((paramType) data); \
return NULL; \
}
# define FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(fn) \
#define FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(fn) \
static void* fn##ThreadMain() { \
fn(); \
return NULL; \
@@ -88,7 +88,7 @@ static inline void ffThreadDetach(FFThreadType thread) {
pthread_detach(thread);
}
static inline bool ffThreadJoin(FFThreadType thread, FF_A_UNUSED uint32_t timeout) {
# if HAVE_TIMEDJOIN_NP
#if HAVE_TIMEDJOIN_NP
if (timeout > 0) {
struct timespec ts;
if (clock_gettime(CLOCK_REALTIME, &ts) == 0) {
@@ -101,15 +101,15 @@ static inline bool ffThreadJoin(FFThreadType thread, FF_A_UNUSED uint32_t timeou
return true;
}
}
# endif
#endif
pthread_join(thread, NULL);
return true;
}
# endif
#endif
#else // FF_HAVE_THREADS
# define FF_THREAD_MUTEX_INITIALIZER 0
#define FF_THREAD_MUTEX_INITIALIZER 0
typedef char FFThreadMutex;
static inline void ffThreadMutexLock(FF_A_UNUSED FFThreadMutex* mutex) {}
static inline void ffThreadMutexUnlock(FF_A_UNUSED FFThreadMutex* mutex) {}
# define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType)
#define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType)
#endif // FF_HAVE_THREADS
+4 -4
View File
@@ -4,11 +4,11 @@
#include <stdint.h>
#include <time.h>
#ifdef _WIN32
# include <ntstatus.h>
# include "common/windows/nt.h"
# include <profileapi.h>
#include <ntstatus.h>
#include "common/windows/nt.h"
#include <profileapi.h>
#elif defined(__HAIKU__)
# include <OS.h>
#include <OS.h>
#endif
#include "common/arrayUtils.h"
+1 -1
View File
@@ -3,7 +3,7 @@
#include <stdint.h>
#ifdef FF_HAVE_WCWIDTH
# include <wchar.h>
#include <wchar.h>
// Should be char32_t but it's not defined on macOS
static_assert(sizeof(wchar_t) == sizeof(uint32_t), "wcwidth implementation requires wchar_t to be 32 bits");
+4 -4
View File
@@ -2,7 +2,7 @@
#ifdef __cplusplus
# include <unknwn.h>
#include <unknwn.h>
const char* ffInitCom(void);
@@ -13,9 +13,9 @@ static inline void ffReleaseComObject(void* ppUnknown) {
}
}
# define FF_AUTO_RELEASE_COM_OBJECT FF_A_CLEANUP(ffReleaseComObject)
#define FF_AUTO_RELEASE_COM_OBJECT FF_A_CLEANUP(ffReleaseComObject)
#else
// Win32 COM headers requires C++ compiler
# error Must be included in C++ source file
// Win32 COM headers requires C++ compiler
#error Must be included in C++ source file
#endif
+1 -1
View File
@@ -63,7 +63,7 @@ typedef struct _PROCESS_DEVICEMAP_INFORMATION_EX {
} PROCESS_DEVICEMAP_INFORMATION_EX, *PPROCESS_DEVICEMAP_INFORMATION_EX;
#ifndef NtCurrentProcess
# define NtCurrentProcess() ((HANDLE) (LONG_PTR) - 1)
#define NtCurrentProcess() ((HANDLE) (LONG_PTR) - 1)
#endif
typedef struct _CURDIR {
+8 -8
View File
@@ -5,14 +5,14 @@
#include "common/io.h"
#ifndef HKEY_CURRENT_USER
# define HKEY_CLASSES_ROOT ((HKEY) (ULONG_PTR) ((LONG) 0x80000000))
# define HKEY_CURRENT_USER ((HKEY) (ULONG_PTR) ((LONG) 0x80000001))
# define HKEY_LOCAL_MACHINE ((HKEY) (ULONG_PTR) ((LONG) 0x80000002))
# define HKEY_USERS ((HKEY) (ULONG_PTR) ((LONG) 0x80000003))
# define HKEY_PERFORMANCE_DATA ((HKEY) (ULONG_PTR) ((LONG) 0x80000004))
# define HKEY_CURRENT_CONFIG ((HKEY) (ULONG_PTR) ((LONG) 0x80000005))
# define HKEY_DYN_DATA ((HKEY) (ULONG_PTR) ((LONG) 0x80000006))
# define HKEY_CURRENT_USER_LOCAL_SETTINGS ((HKEY) (ULONG_PTR) ((LONG) 0x80000007))
#define HKEY_CLASSES_ROOT ((HKEY) (ULONG_PTR) ((LONG) 0x80000000))
#define HKEY_CURRENT_USER ((HKEY) (ULONG_PTR) ((LONG) 0x80000001))
#define HKEY_LOCAL_MACHINE ((HKEY) (ULONG_PTR) ((LONG) 0x80000002))
#define HKEY_USERS ((HKEY) (ULONG_PTR) ((LONG) 0x80000003))
#define HKEY_PERFORMANCE_DATA ((HKEY) (ULONG_PTR) ((LONG) 0x80000004))
#define HKEY_CURRENT_CONFIG ((HKEY) (ULONG_PTR) ((LONG) 0x80000005))
#define HKEY_DYN_DATA ((HKEY) (ULONG_PTR) ((LONG) 0x80000006))
#define HKEY_CURRENT_USER_LOCAL_SETTINGS ((HKEY) (ULONG_PTR) ((LONG) 0x80000007))
#endif
typedef struct FFRegValueArg {
+3 -3
View File
@@ -3,10 +3,10 @@
#ifdef __cplusplus
extern "C" {
# include "unicode.h"
#include "unicode.h"
}
# include <string_view>
#include <string_view>
static inline void ffStrbufInitWSV(FFstrbuf* result, const std::wstring_view source) {
return ffStrbufInitNWS(result, (uint32_t) source.size(), source.data());
@@ -22,6 +22,6 @@ static inline void ffStrbufSetWSV(FFstrbuf* result, const std::wstring_view sour
#else
# error Must be included in C++ source file
#error Must be included in C++ source file
#endif
+6 -6
View File
@@ -3,13 +3,13 @@
#ifdef __cplusplus
extern "C" {
# include "fastfetch.h"
#include "fastfetch.h"
}
# include <initguid.h>
# include <wbemidl.h>
#include <initguid.h>
#include <wbemidl.h>
# include "variant.hpp"
#include "variant.hpp"
enum class FFWmiNamespace {
CIMV2,
@@ -92,6 +92,6 @@ struct FFWmiQuery {
};
#else
// Win32 COM headers requires C++ compiler
# error Must be included in C++ source file
// Win32 COM headers requires C++ compiler
#error Must be included in C++ source file
#endif //__cplusplus
+10 -10
View File
@@ -2,21 +2,21 @@
#include "common/smbios.h"
#ifdef _WIN32
# include "common/windows/registry.h"
#include "common/windows/registry.h"
# include <ntstatus.h>
# include "common/windows/nt.h"
#include <ntstatus.h>
#include "common/windows/nt.h"
#elif __OpenBSD__
# include "common/io.h"
#include "common/io.h"
# include <fcntl.h>
# include <unistd.h>
#include <fcntl.h>
#include <unistd.h>
#elif __sun
# include <libdevinfo.h>
# include <sys/sunddi.h>
#include <libdevinfo.h>
#include <sys/sunddi.h>
#elif __APPLE__
# include "common/apple/cf_helpers.h"
# include <IOKit/IOKitLib.h>
#include "common/apple/cf_helpers.h"
#include <IOKit/IOKitLib.h>
#endif
typedef struct FFSmbiosBios {
+2 -2
View File
@@ -2,8 +2,8 @@
#include "common/stringUtils.h"
#ifdef FF_HAVE_DBUS
# include "common/dbus.h"
# include "common/io.h"
#include "common/dbus.h"
#include "common/io.h"
/* Example dbus reply, striped to only the relevant parts:
array [ //root
@@ -2,8 +2,8 @@
#include "common/stringUtils.h"
#ifdef FF_HAVE_DBUS
# include "common/dbus.h"
# include "common/io.h"
#include "common/dbus.h"
#include "common/io.h"
/* Example dbus reply:
array [
+3 -3
View File
@@ -3,9 +3,9 @@
#include "common/io.h"
#ifdef __OpenBSD__
# include <dev/efi/efiio.h>
#include <dev/efi/efiio.h>
#else
# include <sys/efiio.h>
#include <sys/efiio.h>
#endif
#include <sys/ioctl.h>
#include <fcntl.h>
@@ -16,7 +16,7 @@ typedef uint16_t efi_char;
#endif
#ifndef EFI_GLOBAL_VARIABLE
# define EFI_GLOBAL_VARIABLE { 0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, { 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c } }
#define EFI_GLOBAL_VARIABLE { 0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, { 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c } }
#endif
const char* ffDetectBootmgr(FFBootmgrResult* result) {
+4 -4
View File
@@ -14,10 +14,10 @@ extern IOReturn IOAVServiceCopyEDID(IOAVServiceRef service, CFDataRef* x2) FF_A_
extern IOReturn IOAVServiceReadI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t offset, void* outputBuffer, uint32_t outputBufferSize) FF_A_WEAK_IMPORT;
extern IOReturn IOAVServiceWriteI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t dataAddress, void* inputBuffer, uint32_t inputBufferSize) FF_A_WEAK_IMPORT;
#else
// DDC/CI (Intel)
# include <IOKit/IOKitLib.h>
# include <IOKit/graphics/IOGraphicsLib.h>
# include <IOKit/i2c/IOI2CInterface.h>
// DDC/CI (Intel)
#include <IOKit/IOKitLib.h>
#include <IOKit/graphics/IOGraphicsLib.h>
#include <IOKit/i2c/IOI2CInterface.h>
extern void CGSServiceForDisplayNumber(CGDirectDisplayID display, io_service_t* service) FF_A_WEAK_IMPORT;
#endif
+5 -5
View File
@@ -2,12 +2,12 @@
#if __has_include(<sys/backlight.h>)
# include "common/io.h"
#include "common/io.h"
# include <sys/backlight.h>
# include <sys/ioctl.h>
# include <sys/fcntl.h>
# include <unistd.h>
#include <sys/backlight.h>
#include <sys/ioctl.h>
#include <sys/fcntl.h>
#include <unistd.h>
const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) {
// https://man.freebsd.org/cgi/man.cgi?query=backlight&sektion=9
+15 -15
View File
@@ -78,19 +78,19 @@ static const char* detectWithBacklight(FFlist* result) {
}
#ifdef FF_HAVE_DDCUTIL
# include "detection/displayserver/displayserver.h"
# include "common/library.h"
# include "common/mallocHelper.h"
#include "detection/displayserver/displayserver.h"
#include "common/library.h"
#include "common/mallocHelper.h"
# include <ddcutil_macros.h>
# include <ddcutil_c_api.h>
#include <ddcutil_macros.h>
#include <ddcutil_c_api.h>
// Try to be compatible with ddcutil 2.0
# if DDCUTIL_VMAJOR >= 2
// Try to be compatible with ddcutil 2.0
#if DDCUTIL_VMAJOR >= 2
double ddca_set_default_sleep_multiplier(double multiplier); // ddcutil 1.4
# else
#else
DDCA_Status ddca_init(const char* libopts, int syslog_level, int opts);
# endif
#endif
static const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) {
FF_LIBRARY_LOAD_MESSAGE(libddcutil, "libddcutil" FF_LIBRARY_EXTENSION, 5);
@@ -100,7 +100,7 @@ static const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFl
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_free_any_vcp_value)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_close_display)
# ifndef FF_DISABLE_DLOPEN
#ifndef FF_DISABLE_DLOPEN
FF_LIBRARY_LOAD_SYMBOL_LAZY(libddcutil, ddca_init)
if (ffddca_init) {
FF_SUPPRESS_IO();
@@ -116,15 +116,15 @@ static const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFl
libddcutil = NULL; // Don't dlclose libddcutil. See https://github.com/rockowitz/ddcutil/issues/330
}
# else
# if DDCUTIL_VMAJOR >= 2
#else
#if DDCUTIL_VMAJOR >= 2
if (ddca_init(NULL, -1 /*DDCA_SYSLOG_NOT_SET*/, 1 /*DDCA_INIT_OPTIONS_DISABLE_CONFIG_FILE*/) < 0) {
return "ddca_init() failed";
}
# else
#else
ddca_set_default_sleep_multiplier(options->ddcciSleep / 40.0);
# endif
# endif
#endif
#endif
FF_AUTO_FREE DDCA_Display_Info_List* infoList = NULL;
if (ffddca_get_display_info_list2(false, &infoList) < 0) {
+3 -3
View File
@@ -6,10 +6,10 @@
#include <sys/ioctl.h>
#if FF_HAVE_LINUX_VIDEODEV2
# include <linux/videodev2.h>
#include <linux/videodev2.h>
#elif __has_include(<sys/videoio.h>) // OpenBSD
# include <sys/videoio.h>
# define FF_HAVE_LINUX_VIDEODEV2 1
#include <sys/videoio.h>
#define FF_HAVE_LINUX_VIDEODEV2 1
#endif
const char* ffDetectCamera(FFlist* result) {
+41 -41
View File
@@ -80,7 +80,7 @@ const char* ffCPUQualcommCodeToName(uint32_t code) {
#if defined(__x86_64__) || defined(__i386__)
# include <cpuid.h>
#include <cpuid.h>
void ffCPUDetectByCpuid(FFCPUResult* cpu) {
uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
@@ -150,9 +150,9 @@ void ffCPUDetectByCpuid(FFCPUResult* cpu) {
// https://en.wikipedia.org/wiki/AArch64#ARM-A_(application_architecture)
// Worth noting: Apple M1 is marked as ARMv8.5-A on Wikipedia, but it lacks BTI (mandatory in v8.5)
# ifdef __linux__
# include "common/io.h"
# include <elf.h>
#ifdef __linux__
#include "common/io.h"
#include <elf.h>
// #include <asm/hwcap.h>
void ffCPUDetectByCpuid(FFCPUResult* cpu) {
@@ -286,8 +286,8 @@ void ffCPUDetectByCpuid(FFCPUResult* cpu) {
}
}
}
# elif __APPLE__
# include <sys/sysctl.h>
#elif __APPLE__
#include <sys/sysctl.h>
// #include <arm/cpu_capabilities_public.h> // Not available in macOS 14-
void ffCPUDetectByCpuid(FFCPUResult* cpu) {
@@ -298,8 +298,8 @@ void ffCPUDetectByCpuid(FFCPUResult* cpu) {
return;
}
// Helper macro to test bit in 80-bit capability mask
# define FF_HAS_CAP(bit) \
// Helper macro to test bit in 80-bit capability mask
#define FF_HAS_CAP(bit) \
(((bit) < 64) ? ((caps[0] >> (bit)) & 1ULL) : ((caps[1] >> ((bit) - 64U)) & 1ULL))
cpu->march = "unknown";
@@ -397,39 +397,39 @@ void ffCPUDetectByCpuid(FFCPUResult* cpu) {
}
}
# undef HAS_CAP
#undef HAS_CAP
}
# elif _WIN32
# include <processthreadsapi.h>
#elif _WIN32
#include <processthreadsapi.h>
// Missing from winnt.h of MinGW-w64
# define PF_ARM_LSE2_AVAILABLE 62
# define PF_RESERVED_FEATURE 63
# define PF_ARM_SHA3_INSTRUCTIONS_AVAILABLE 64
# define PF_ARM_SHA512_INSTRUCTIONS_AVAILABLE 65
# define PF_ARM_V82_I8MM_INSTRUCTIONS_AVAILABLE 66
# define PF_ARM_V82_FP16_INSTRUCTIONS_AVAILABLE 67
# define PF_ARM_V86_BF16_INSTRUCTIONS_AVAILABLE 68
# define PF_ARM_V86_EBF16_INSTRUCTIONS_AVAILABLE 69
# define PF_ARM_SME_INSTRUCTIONS_AVAILABLE 70
# define PF_ARM_SME2_INSTRUCTIONS_AVAILABLE 71
# define PF_ARM_SME2_1_INSTRUCTIONS_AVAILABLE 72
# define PF_ARM_SME2_2_INSTRUCTIONS_AVAILABLE 73
# define PF_ARM_SME_AES_INSTRUCTIONS_AVAILABLE 74
# define PF_ARM_SME_SBITPERM_INSTRUCTIONS_AVAILABLE 75
# define PF_ARM_SME_SF8MM4_INSTRUCTIONS_AVAILABLE 76
# define PF_ARM_SME_SF8MM8_INSTRUCTIONS_AVAILABLE 77
# define PF_ARM_SME_SF8DP2_INSTRUCTIONS_AVAILABLE 78
# define PF_ARM_SME_SF8DP4_INSTRUCTIONS_AVAILABLE 79
# define PF_ARM_SME_SF8FMA_INSTRUCTIONS_AVAILABLE 80
# define PF_ARM_SME_F8F32_INSTRUCTIONS_AVAILABLE 81
# define PF_ARM_SME_F8F16_INSTRUCTIONS_AVAILABLE 82
# define PF_ARM_SME_F16F16_INSTRUCTIONS_AVAILABLE 83
# define PF_ARM_SME_B16B16_INSTRUCTIONS_AVAILABLE 84
# define PF_ARM_SME_F64F64_INSTRUCTIONS_AVAILABLE 85
# define PF_ARM_SME_I16I64_INSTRUCTIONS_AVAILABLE 86
# define PF_ARM_SME_LUTv2_INSTRUCTIONS_AVAILABLE 87
# define PF_ARM_SME_FA64_INSTRUCTIONS_AVAILABLE 88
// Missing from winnt.h of MinGW-w64
#define PF_ARM_LSE2_AVAILABLE 62
#define PF_RESERVED_FEATURE 63
#define PF_ARM_SHA3_INSTRUCTIONS_AVAILABLE 64
#define PF_ARM_SHA512_INSTRUCTIONS_AVAILABLE 65
#define PF_ARM_V82_I8MM_INSTRUCTIONS_AVAILABLE 66
#define PF_ARM_V82_FP16_INSTRUCTIONS_AVAILABLE 67
#define PF_ARM_V86_BF16_INSTRUCTIONS_AVAILABLE 68
#define PF_ARM_V86_EBF16_INSTRUCTIONS_AVAILABLE 69
#define PF_ARM_SME_INSTRUCTIONS_AVAILABLE 70
#define PF_ARM_SME2_INSTRUCTIONS_AVAILABLE 71
#define PF_ARM_SME2_1_INSTRUCTIONS_AVAILABLE 72
#define PF_ARM_SME2_2_INSTRUCTIONS_AVAILABLE 73
#define PF_ARM_SME_AES_INSTRUCTIONS_AVAILABLE 74
#define PF_ARM_SME_SBITPERM_INSTRUCTIONS_AVAILABLE 75
#define PF_ARM_SME_SF8MM4_INSTRUCTIONS_AVAILABLE 76
#define PF_ARM_SME_SF8MM8_INSTRUCTIONS_AVAILABLE 77
#define PF_ARM_SME_SF8DP2_INSTRUCTIONS_AVAILABLE 78
#define PF_ARM_SME_SF8DP4_INSTRUCTIONS_AVAILABLE 79
#define PF_ARM_SME_SF8FMA_INSTRUCTIONS_AVAILABLE 80
#define PF_ARM_SME_F8F32_INSTRUCTIONS_AVAILABLE 81
#define PF_ARM_SME_F8F16_INSTRUCTIONS_AVAILABLE 82
#define PF_ARM_SME_F16F16_INSTRUCTIONS_AVAILABLE 83
#define PF_ARM_SME_B16B16_INSTRUCTIONS_AVAILABLE 84
#define PF_ARM_SME_F64F64_INSTRUCTIONS_AVAILABLE 85
#define PF_ARM_SME_I16I64_INSTRUCTIONS_AVAILABLE 86
#define PF_ARM_SME_LUTv2_INSTRUCTIONS_AVAILABLE 87
#define PF_ARM_SME_FA64_INSTRUCTIONS_AVAILABLE 88
void ffCPUDetectByCpuid(FFCPUResult* cpu) {
// ARMv8-A
@@ -504,11 +504,11 @@ void ffCPUDetectByCpuid(FFCPUResult* cpu) {
}
}
}
# else
#else
void ffCPUDetectByCpuid(FF_A_UNUSED FFCPUResult* cpu) {
// Unsupported system
}
# endif
#endif
#else
+2 -2
View File
@@ -41,9 +41,9 @@ static double detectCpuTemp(const FFCPUOptions* options, const FFstrbuf* cpuName
}
#ifdef __aarch64__
# include "common/apple/cf_helpers.h"
#include "common/apple/cf_helpers.h"
# include <IOKit/IOKitLib.h>
#include <IOKit/IOKitLib.h>
static const char* detectFrequency(FFCPUResult* cpu) {
// https://github.com/giampaolo/psutil/pull/2222/files
+2 -2
View File
@@ -4,8 +4,8 @@
#include <sys/param.h>
#if __has_include(<sys/cpuset.h>)
# include <sys/cpuset.h>
# define FF_HAVE_CPUSET 1
#include <sys/cpuset.h>
#define FF_HAVE_CPUSET 1
#endif
static const char* detectCpuTemp(const FFCPUOptions* options, double* current) {
+14 -14
View File
@@ -204,7 +204,7 @@ static void detectNumaNodes(FFCPUResult* cpu) {
}
#ifdef __ANDROID__
# include "common/settings.h"
#include "common/settings.h"
static void detectQualcomm(FFCPUResult* cpu) {
// https://en.wikipedia.org/wiki/List_of_Qualcomm_Snapdragon_systems_on_chips
@@ -452,7 +452,7 @@ static void detectAndroid(FFCPUResult* cpu) {
#endif
#if __arm__ || __aarch64__
# include "cpu_arm.h"
#include "cpu_arm.h"
static void detectArmName(FFstrbuf* cpuinfo, FFCPUResult* cpu, uint32_t implId) {
char* line = NULL;
@@ -925,7 +925,7 @@ FF_A_UNUSED static void detectSocName(FFCPUResult* cpu) {
if (false) {
}
# if __aarch64__
#if __aarch64__
else if (ffStrEquals(vendor, "apple")) {
// https://elixir.bootlin.com/linux/v6.11/source/arch/arm64/boot/dts/apple
if (model[0] == 't') {
@@ -942,7 +942,7 @@ FF_A_UNUSED static void detectSocName(FFCPUResult* cpu) {
ffStrbufSetStatic(&cpu->vendor, "Apple");
}
# endif
#endif
else if (ffStrEquals(vendor, "qcom")) {
// https://elixir.bootlin.com/linux/v6.11/source/arch/arm64/boot/dts/qcom
if (ffStrStartsWith(model, "x")) {
@@ -982,7 +982,7 @@ FF_A_UNUSED static void detectSocName(FFCPUResult* cpu) {
}
}
# ifdef __loongarch__
#ifdef __loongarch__
FF_A_UNUSED static uint16_t getLoongarchPropCount(FFstrbuf* cpuinfo, const char* key) {
const char* p = cpuinfo->chars;
uint64_t low = 0, high = 0;
@@ -1002,17 +1002,17 @@ FF_A_UNUSED static uint16_t getLoongarchPropCount(FFstrbuf* cpuinfo, const char*
return (uint16_t) (__builtin_popcountll(low) + __builtin_popcountll(high));
}
# endif
#endif
FF_A_UNUSED static const char* detectCPUOthers(const FFCPUOptions* options, FFCPUResult* cpu) {
cpu->coresLogical = (uint16_t) get_nprocs_conf();
cpu->coresOnline = (uint16_t) get_nprocs();
# if __ANDROID__
#if __ANDROID__
detectAndroid(cpu);
# elif !__powerpc__ && !__powerpc
#elif !__powerpc__ && !__powerpc
detectSocName(cpu);
# endif
#endif
detectFrequency(cpu, options);
@@ -1036,14 +1036,14 @@ FF_A_UNUSED static const char* detectCPUOthers(const FFCPUOptions* options, FFCP
cpu->frequencyBase = (uint32_t) ffStrbufToUInt(&cpuMHz, 0);
}
# if __arm__ || __aarch64__
#if __arm__ || __aarch64__
uint32_t cpuImplementer = (uint32_t) strtoul(cpuImplementerStr.chars, NULL, 16);
ffStrbufSetStatic(&cpu->vendor, hwImplId2Vendor(cpuImplementer));
if (cpu->name.length == 0) {
detectArmName(&cpuinfo, cpu, cpuImplementer);
}
# elif __riscv__ || __riscv
#elif __riscv__ || __riscv
if (cpu->name.length == 0) {
if (cpuUarch.length > 0) {
if (cpu->name.length > 0) {
@@ -1060,17 +1060,17 @@ FF_A_UNUSED static const char* detectCPUOthers(const FFCPUOptions* options, FFCP
ffStrbufAppend(&cpu->name, &cpuIsa);
}
}
# elif __loongarch__
#elif __loongarch__
cpu->packages = getLoongarchPropCount(&cpuinfo, "\npackage\t\t\t:");
cpu->coresPhysical = getLoongarchPropCount(&cpuinfo, "\ncore\t\t\t:");
if (cpu->packages > 1) {
cpu->coresPhysical *= cpu->packages;
}
# elif __s390x__
#elif __s390x__
if (cpu->name.length) {
ffStrbufPrependS(&cpu->name, "Machine ");
}
# endif
#endif
}
if (cpu->coresPhysical == 0) {
+4 -4
View File
@@ -7,17 +7,17 @@
#include <stdlib.h>
#if __OpenBSD__ || __NetBSD__
# include <sys/sched.h>
#include <sys/sched.h>
#endif
const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
size_t neededLength = 0;
#if __OpenBSD__ || __NetBSD__
# ifdef KERN_CPTIME
#ifdef KERN_CPTIME
int ctls[] = { CTL_KERN, KERN_CPTIME };
# else
#else
int ctls[] = { CTL_KERN, KERN_CP_TIME };
# endif
#endif
if (sysctl(ctls, 2, NULL, &neededLength, NULL, 0) != 0) {
return "sysctl({CTL_KERN, KERN_CPTIME}, 2, NULL) failed";
}
+6 -6
View File
@@ -12,14 +12,14 @@
#include <ctype.h>
#ifdef __FreeBSD__
# include <paths.h>
# ifndef _PATH_LOCALBASE
# define _PATH_LOCALBASE "/usr/local"
# endif
#include <paths.h>
#ifndef _PATH_LOCALBASE
#define _PATH_LOCALBASE "/usr/local"
#endif
#elif __OpenBSD__
# define _PATH_LOCALBASE "/usr/local"
#define _PATH_LOCALBASE "/usr/local"
#elif __NetBSD__
# define _PATH_LOCALBASE "/usr/pkg"
#define _PATH_LOCALBASE "/usr/pkg"
#endif
static void getKDE(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
+1 -1
View File
@@ -31,7 +31,7 @@ const char* ffDetectDisks(FFDiskOptions* options, FFlist* disks) {
}
#ifndef _WIN32
# include <fnmatch.h>
#include <fnmatch.h>
bool ffDiskMatchesFolderPatterns(FFstrbuf* folders, const char* path, char separator) {
uint32_t startIndex = 0;
+2 -2
View File
@@ -4,9 +4,9 @@
#include "modules/disk/option.h"
#ifdef _WIN32
# define FF_DISK_FOLDER_SEPARATOR ';'
#define FF_DISK_FOLDER_SEPARATOR ';'
#else
# define FF_DISK_FOLDER_SEPARATOR ':'
#define FF_DISK_FOLDER_SEPARATOR ':'
#endif
typedef struct FFDisk {
+18 -18
View File
@@ -7,16 +7,16 @@
#include <sys/stat.h>
#ifdef __NetBSD__
# include <sys/types.h>
# include <sys/statvfs.h>
# define statfs statvfs
# define f_flags f_flag
# define f_bsize f_frsize
#include <sys/types.h>
#include <sys/statvfs.h>
#define statfs statvfs
#define f_flags f_flag
#define f_bsize f_frsize
#endif
#ifdef __FreeBSD__
# if __has_include(<libgeom.h>)
# include <libgeom.h>
#if __has_include(<libgeom.h>)
#include <libgeom.h>
static const char* detectFsLabel(struct statfs* fs, FFDisk* disk) {
if (!ffStrStartsWith(fs->f_mntfromname, "/dev/")) {
@@ -53,11 +53,11 @@ static const char* detectFsLabel(struct statfs* fs, FFDisk* disk) {
return NULL;
}
# else
#else
static const char* detectFsLabel(FF_A_UNUSED struct statfs* fs, FF_A_UNUSED FFDisk* disk) {
return "Fastfetch was compiled without libgeom support";
}
# endif
#endif
static void detectFsInfo(struct statfs* fs, FFDisk* disk) {
if (ffStrbufEqualS(&disk->filesystem, "zfs")) {
@@ -75,14 +75,14 @@ static void detectFsInfo(struct statfs* fs, FFDisk* disk) {
detectFsLabel(fs, disk);
}
#elif __APPLE__
# include "common/apple/cf_helpers.h"
#include "common/apple/cf_helpers.h"
# include <sys/attr.h>
# include <unistd.h>
#include <sys/attr.h>
#include <unistd.h>
# ifndef MAC_OS_X_VERSION_10_15
# define MNT_REMOVABLE 0x00000200
# endif
#ifndef MAC_OS_X_VERSION_10_15
#define MNT_REMOVABLE 0x00000200
#endif
struct CmnAttrBuf {
uint32_t length;
@@ -112,11 +112,11 @@ void detectFsInfo(struct statfs* fs, FFDisk* disk) {
}
#else
static void detectFsInfo(struct statfs* fs, FFDisk* disk) {
# ifdef MNT_IGNORE
#ifdef MNT_IGNORE
if (fs->f_flags & MNT_IGNORE) {
disk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT;
} else
# endif
#endif
if (!(fs->f_flags & MNT_LOCAL)) {
disk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT;
} else {
@@ -200,7 +200,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
}
#ifdef __OpenBSD__
# define st_birthtimespec __st_birthtim
#define st_birthtimespec __st_birthtim
#endif
#ifndef __DragonFly__
struct stat st;
+5 -5
View File
@@ -11,14 +11,14 @@
#include <sys/statvfs.h>
#if defined(STATX_BTIME) && !defined(__ANDROID__)
# include <sys/syscall.h>
#include <sys/syscall.h>
#endif
#ifdef __USE_LARGEFILE64
# define stat stat64
# define statvfs statvfs64
# define dirent dirent64
# define readdir readdir64
#define stat stat64
#define statvfs statvfs64
#define dirent dirent64
#define readdir readdir64
#endif
static bool isPhysicalDevice(const struct mntent* device) {
+9 -9
View File
@@ -2,14 +2,14 @@
#if __has_include(<libgeom.h>)
# include "common/stringUtils.h"
#include "common/stringUtils.h"
# include <devstat.h>
# include <memory.h>
# include <fcntl.h>
# include <sys/ioctl.h>
# include <sys/disk.h>
# include <libgeom.h>
#include <devstat.h>
#include <memory.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/disk.h>
#include <libgeom.h>
const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
FF_A_CLEANUP(geom_deletetree) struct gmesh geomTree = {};
@@ -74,8 +74,8 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
#else
# include <devstat.h>
# include <memory.h>
#include <devstat.h>
#include <memory.h>
const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
if (checkversion() < 0) {
@@ -15,7 +15,7 @@ extern Boolean CoreDisplay_Display_SupportsHDRMode(CGDirectDisplayID display) FF
extern Boolean CoreDisplay_Display_IsHDRModeEnabled(CGDirectDisplayID display) FF_A_WEAK_IMPORT;
extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display) FF_A_WEAK_IMPORT;
#else
# include <IOKit/graphics/IOGraphicsLib.h>
#include <IOKit/graphics/IOGraphicsLib.h>
#endif
static void detectDisplays(FFDisplayServerResult* ds) {
@@ -3,7 +3,7 @@
#include "common/stringUtils.h"
#ifdef __FreeBSD__
# include "common/settings.h"
#include "common/settings.h"
#endif
static void getWMProtocolNameFromEnv(FFDisplayServerResult* result) {
+9 -9
View File
@@ -4,7 +4,7 @@
#include "common/stringUtils.h"
#ifdef __linux__
# include <dirent.h>
#include <dirent.h>
static const char* drmParseSysfs(FFDisplayServerResult* result) {
const char* drmDirPath = "/sys/class/drm/";
@@ -107,11 +107,11 @@ static const char* drmParseSysfs(FFDisplayServerResult* result) {
#ifdef FF_HAVE_DRM
# include "common/library.h"
#include "common/library.h"
# include <xf86drm.h>
# include <xf86drmMode.h>
# include <fcntl.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include <fcntl.h>
// https://gitlab.freedesktop.org/mesa/drm/-/blob/main/xf86drmMode.c#L1785
// It's not supported on Ubuntu 20.04
@@ -242,14 +242,14 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result) {
const char* path = dev->nodes[DRM_NODE_PRIMARY];
# if __linux__
#if __linux__
ffStrbufSetF(&name, "/sys/class/drm/%s/device/power/runtime_status", strrchr(path, '/') + 1);
char buffer[8] = "";
if (ffReadFileData(name.chars, strlen("suspend"), buffer) > 0 && ffStrStartsWith(buffer, "suspend")) {
continue;
}
# endif
#endif
FF_AUTO_CLOSE_FD int primaryFd = open(path, O_RDWR | O_CLOEXEC);
if (primaryFd < 0) {
@@ -356,7 +356,7 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result) {
ffdrmModeFreeProperty(prop);
}
# if __linux__
#if __linux__
if (name.length == 0) {
uint8_t edidData[512];
ssize_t edidLength = 0;
@@ -367,7 +367,7 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result) {
ffEdidGetSerialAndManufactureDate(edidData, &serial, &myear, &mweak);
}
}
# endif
#endif
if (name.length == 0) {
const char* connectorTypeName = drmType2Name(conn->connector_type);
@@ -1,8 +1,8 @@
#ifdef FF_HAVE_WAYLAND
# include "wayland.h"
# include "common/stringUtils.h"
# include "xdg-output-unstable-v1-client-protocol.h"
#include "wayland.h"
#include "common/stringUtils.h"
#include "xdg-output-unstable-v1-client-protocol.h"
static void waylandOutputModeListener(void* data, FF_A_UNUSED struct wl_output* output, uint32_t flags, int32_t width, int32_t height, int32_t refreshRate) {
WaylandDisplay* display = data;
@@ -34,7 +34,7 @@ struct kde_output_device_registry_v2;
struct kde_output_device_v2;
#ifndef KDE_OUTPUT_DEVICE_REGISTRY_V2_INTERFACE
# define KDE_OUTPUT_DEVICE_REGISTRY_V2_INTERFACE
#define KDE_OUTPUT_DEVICE_REGISTRY_V2_INTERFACE
/**
* @page page_iface_kde_output_device_registry_v2 kde_output_device_registry_v2
* @section page_iface_kde_output_device_registry_v2_desc Description
@@ -57,7 +57,7 @@ struct kde_output_device_v2;
extern const struct wl_interface kde_output_device_registry_v2_interface;
#endif
#ifndef KDE_OUTPUT_DEVICE_V2_INTERFACE
# define KDE_OUTPUT_DEVICE_V2_INTERFACE
#define KDE_OUTPUT_DEVICE_V2_INTERFACE
/**
* @page page_iface_kde_output_device_v2 kde_output_device_v2
* @section page_iface_kde_output_device_v2_desc Description
@@ -114,7 +114,7 @@ extern const struct wl_interface kde_output_device_registry_v2_interface;
extern const struct wl_interface kde_output_device_v2_interface;
#endif
#ifndef KDE_OUTPUT_DEVICE_MODE_V2_INTERFACE
# define KDE_OUTPUT_DEVICE_MODE_V2_INTERFACE
#define KDE_OUTPUT_DEVICE_MODE_V2_INTERFACE
/**
* @page page_iface_kde_output_device_mode_v2 kde_output_device_mode_v2
* @section page_iface_kde_output_device_mode_v2_desc Description
@@ -146,7 +146,7 @@ extern const struct wl_interface kde_output_device_mode_v2_interface;
#endif
#ifndef KDE_OUTPUT_DEVICE_REGISTRY_V2_ERROR_ENUM
# define KDE_OUTPUT_DEVICE_REGISTRY_V2_ERROR_ENUM
#define KDE_OUTPUT_DEVICE_REGISTRY_V2_ERROR_ENUM
/**
* @ingroup iface_kde_output_device_registry_v2
* kde_output_device_registry_v2 error values
@@ -256,7 +256,7 @@ kde_output_device_registry_v2_destroy(struct kde_output_device_registry_v2* kde_
// }
#ifndef KDE_OUTPUT_DEVICE_V2_SUBPIXEL_ENUM
# define KDE_OUTPUT_DEVICE_V2_SUBPIXEL_ENUM
#define KDE_OUTPUT_DEVICE_V2_SUBPIXEL_ENUM
/**
* @ingroup iface_kde_output_device_v2
* subpixel geometry information
@@ -275,7 +275,7 @@ enum kde_output_device_v2_subpixel {
#endif /* KDE_OUTPUT_DEVICE_V2_SUBPIXEL_ENUM */
#ifndef KDE_OUTPUT_DEVICE_V2_TRANSFORM_ENUM
# define KDE_OUTPUT_DEVICE_V2_TRANSFORM_ENUM
#define KDE_OUTPUT_DEVICE_V2_TRANSFORM_ENUM
/**
* @ingroup iface_kde_output_device_v2
* transform from framebuffer to output
@@ -304,7 +304,7 @@ enum kde_output_device_v2_transform {
#endif /* KDE_OUTPUT_DEVICE_V2_TRANSFORM_ENUM */
#ifndef KDE_OUTPUT_DEVICE_V2_CAPABILITY_ENUM
# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_ENUM
#define KDE_OUTPUT_DEVICE_V2_CAPABILITY_ENUM
/**
* @ingroup iface_kde_output_device_v2
* describes capabilities of the outputdevice
@@ -384,58 +384,58 @@ enum kde_output_device_v2_capability {
*/
KDE_OUTPUT_DEVICE_V2_CAPABILITY_AUTO_BRIGHTNESS = 0x4000,
};
/**
* @ingroup iface_kde_output_device_v2
*/
# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_HIGH_DYNAMIC_RANGE_SINCE_VERSION 3
/**
* @ingroup iface_kde_output_device_v2
*/
# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_WIDE_COLOR_GAMUT_SINCE_VERSION 3
/**
* @ingroup iface_kde_output_device_v2
*/
# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_AUTO_ROTATE_SINCE_VERSION 4
/**
* @ingroup iface_kde_output_device_v2
*/
# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_ICC_PROFILE_SINCE_VERSION 5
/**
* @ingroup iface_kde_output_device_v2
*/
# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_BRIGHTNESS_SINCE_VERSION 9
/**
* @ingroup iface_kde_output_device_v2
*/
# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_BUILT_IN_COLOR_SINCE_VERSION 12
/**
* @ingroup iface_kde_output_device_v2
*/
# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_DDC_CI_SINCE_VERSION 14
/**
* @ingroup iface_kde_output_device_v2
*/
# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_MAX_BITS_PER_COLOR_SINCE_VERSION 15
/**
* @ingroup iface_kde_output_device_v2
*/
# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_EDR_SINCE_VERSION 16
/**
* @ingroup iface_kde_output_device_v2
*/
# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_SHARPNESS_SINCE_VERSION 17
/**
* @ingroup iface_kde_output_device_v2
*/
# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_CUSTOM_MODES_SINCE_VERSION 18
/**
* @ingroup iface_kde_output_device_v2
*/
# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_AUTO_BRIGHTNESS_SINCE_VERSION 19
/**
* @ingroup iface_kde_output_device_v2
*/
#define KDE_OUTPUT_DEVICE_V2_CAPABILITY_HIGH_DYNAMIC_RANGE_SINCE_VERSION 3
/**
* @ingroup iface_kde_output_device_v2
*/
#define KDE_OUTPUT_DEVICE_V2_CAPABILITY_WIDE_COLOR_GAMUT_SINCE_VERSION 3
/**
* @ingroup iface_kde_output_device_v2
*/
#define KDE_OUTPUT_DEVICE_V2_CAPABILITY_AUTO_ROTATE_SINCE_VERSION 4
/**
* @ingroup iface_kde_output_device_v2
*/
#define KDE_OUTPUT_DEVICE_V2_CAPABILITY_ICC_PROFILE_SINCE_VERSION 5
/**
* @ingroup iface_kde_output_device_v2
*/
#define KDE_OUTPUT_DEVICE_V2_CAPABILITY_BRIGHTNESS_SINCE_VERSION 9
/**
* @ingroup iface_kde_output_device_v2
*/
#define KDE_OUTPUT_DEVICE_V2_CAPABILITY_BUILT_IN_COLOR_SINCE_VERSION 12
/**
* @ingroup iface_kde_output_device_v2
*/
#define KDE_OUTPUT_DEVICE_V2_CAPABILITY_DDC_CI_SINCE_VERSION 14
/**
* @ingroup iface_kde_output_device_v2
*/
#define KDE_OUTPUT_DEVICE_V2_CAPABILITY_MAX_BITS_PER_COLOR_SINCE_VERSION 15
/**
* @ingroup iface_kde_output_device_v2
*/
#define KDE_OUTPUT_DEVICE_V2_CAPABILITY_EDR_SINCE_VERSION 16
/**
* @ingroup iface_kde_output_device_v2
*/
#define KDE_OUTPUT_DEVICE_V2_CAPABILITY_SHARPNESS_SINCE_VERSION 17
/**
* @ingroup iface_kde_output_device_v2
*/
#define KDE_OUTPUT_DEVICE_V2_CAPABILITY_CUSTOM_MODES_SINCE_VERSION 18
/**
* @ingroup iface_kde_output_device_v2
*/
#define KDE_OUTPUT_DEVICE_V2_CAPABILITY_AUTO_BRIGHTNESS_SINCE_VERSION 19
#endif /* KDE_OUTPUT_DEVICE_V2_CAPABILITY_ENUM */
#ifndef KDE_OUTPUT_DEVICE_V2_VRR_POLICY_ENUM
# define KDE_OUTPUT_DEVICE_V2_VRR_POLICY_ENUM
#define KDE_OUTPUT_DEVICE_V2_VRR_POLICY_ENUM
/**
* @ingroup iface_kde_output_device_v2
* describes vrr policy
@@ -450,7 +450,7 @@ enum kde_output_device_v2_vrr_policy {
#endif /* KDE_OUTPUT_DEVICE_V2_VRR_POLICY_ENUM */
#ifndef KDE_OUTPUT_DEVICE_V2_RGB_RANGE_ENUM
# define KDE_OUTPUT_DEVICE_V2_RGB_RANGE_ENUM
#define KDE_OUTPUT_DEVICE_V2_RGB_RANGE_ENUM
/**
* @ingroup iface_kde_output_device_v2
* describes RGB range policy
@@ -465,7 +465,7 @@ enum kde_output_device_v2_rgb_range {
#endif /* KDE_OUTPUT_DEVICE_V2_RGB_RANGE_ENUM */
#ifndef KDE_OUTPUT_DEVICE_V2_AUTO_ROTATE_POLICY_ENUM
# define KDE_OUTPUT_DEVICE_V2_AUTO_ROTATE_POLICY_ENUM
#define KDE_OUTPUT_DEVICE_V2_AUTO_ROTATE_POLICY_ENUM
/**
* @ingroup iface_kde_output_device_v2
* describes when auto rotate should be used
@@ -478,7 +478,7 @@ enum kde_output_device_v2_auto_rotate_policy {
#endif /* KDE_OUTPUT_DEVICE_V2_AUTO_ROTATE_POLICY_ENUM */
#ifndef KDE_OUTPUT_DEVICE_V2_COLOR_PROFILE_SOURCE_ENUM
# define KDE_OUTPUT_DEVICE_V2_COLOR_PROFILE_SOURCE_ENUM
#define KDE_OUTPUT_DEVICE_V2_COLOR_PROFILE_SOURCE_ENUM
/**
* @ingroup iface_kde_output_device_v2
* which source the compositor should use for the color profile on an output
@@ -491,7 +491,7 @@ enum kde_output_device_v2_color_profile_source {
#endif /* KDE_OUTPUT_DEVICE_V2_COLOR_PROFILE_SOURCE_ENUM */
#ifndef KDE_OUTPUT_DEVICE_V2_COLOR_POWER_TRADEOFF_ENUM
# define KDE_OUTPUT_DEVICE_V2_COLOR_POWER_TRADEOFF_ENUM
#define KDE_OUTPUT_DEVICE_V2_COLOR_POWER_TRADEOFF_ENUM
/**
* @ingroup iface_kde_output_device_v2
* tradeoff between power and accuracy
@@ -514,7 +514,7 @@ enum kde_output_device_v2_color_power_tradeoff {
#endif /* KDE_OUTPUT_DEVICE_V2_COLOR_POWER_TRADEOFF_ENUM */
#ifndef KDE_OUTPUT_DEVICE_V2_EDR_POLICY_ENUM
# define KDE_OUTPUT_DEVICE_V2_EDR_POLICY_ENUM
#define KDE_OUTPUT_DEVICE_V2_EDR_POLICY_ENUM
/**
* @ingroup iface_kde_output_device_v2
* when the compositor may make use of EDR
@@ -1190,7 +1190,7 @@ kde_output_device_v2_destroy(struct kde_output_device_v2* kde_output_device_v2)
// }
#ifndef KDE_OUTPUT_DEVICE_MODE_V2_FLAGS_ENUM
# define KDE_OUTPUT_DEVICE_MODE_V2_FLAGS_ENUM
#define KDE_OUTPUT_DEVICE_MODE_V2_FLAGS_ENUM
/**
* @ingroup iface_kde_output_device_mode_v2
* mode flags
@@ -12,10 +12,10 @@
* SPDX-License-Identifier: MIT-CMU
*/
# include <stdbool.h>
# include <stdlib.h>
# include <stdint.h>
# include <wayland-util.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>
#include <wayland-util.h>
extern const struct wl_interface kde_output_device_mode_v2_interface;
extern const struct wl_interface kde_output_device_v2_interface;
@@ -26,7 +26,7 @@ extern "C" {
struct kde_output_order_v1;
#ifndef KDE_OUTPUT_ORDER_V1_INTERFACE
# define KDE_OUTPUT_ORDER_V1_INTERFACE
#define KDE_OUTPUT_ORDER_V1_INTERFACE
/**
* @page page_iface_kde_output_order_v1 kde_output_order_v1
* @section page_iface_kde_output_order_v1_desc Description
@@ -8,9 +8,9 @@
* SPDX-License-Identifier: MIT-CMU
*/
# include <stdlib.h>
# include <stdint.h>
# include "wayland-util.h"
#include <stdlib.h>
#include <stdint.h>
#include "wayland-util.h"
static const struct wl_interface* kde_output_order_v1_types[] = {
NULL,
@@ -1,10 +1,10 @@
#ifdef FF_HAVE_WAYLAND
# include "wayland.h"
# include "kde-output-device-v2-client-protocol.h"
# include "kde-output-order-v1-client-protocol.h"
# include "common/edidHelper.h"
# include "common/base64.h"
#include "wayland.h"
#include "kde-output-device-v2-client-protocol.h"
#include "kde-output-order-v1-client-protocol.h"
#include "common/edidHelper.h"
#include "common/base64.h"
typedef struct WaylandKdeMode {
int32_t width;
@@ -8,26 +8,26 @@
#ifdef FF_HAVE_WAYLAND
# include <sys/socket.h>
#include <sys/socket.h>
# include "common/properties.h"
#include "common/properties.h"
# include "wayland.h"
# include "wlr-output-management-unstable-v1-client-protocol.h"
# include "kde-output-device-v2-client-protocol.h"
# include "kde-output-order-v1-client-protocol.h"
# include "xdg-output-unstable-v1-client-protocol.h"
#include "wayland.h"
#include "wlr-output-management-unstable-v1-client-protocol.h"
#include "kde-output-device-v2-client-protocol.h"
#include "kde-output-order-v1-client-protocol.h"
#include "xdg-output-unstable-v1-client-protocol.h"
# if __FreeBSD__
# include <sys/un.h>
# include <sys/ucred.h>
# include <sys/sysctl.h>
# endif
#if __FreeBSD__
#include <sys/un.h>
#include <sys/ucred.h>
#include <sys/sysctl.h>
#endif
static bool waylandDetectWM(int fd, FFDisplayServerResult* result) {
# if __linux__ || __GNU__ || (__FreeBSD__ && !__DragonFly__)
#if __linux__ || __GNU__ || (__FreeBSD__ && !__DragonFly__)
# if __linux__ || __GNU__
#if __linux__ || __GNU__
struct ucred ucred = {};
socklen_t len = sizeof(ucred);
if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) == -1 || ucred.pid <= 0) {
@@ -39,7 +39,7 @@ static bool waylandDetectWM(int fd, FFDisplayServerResult* result) {
if (!ffReadFileBuffer(procPath.chars, &result->wmProcessName)) {
return false;
}
# else
#else
struct xucred ucred = {};
socklen_t len = sizeof(ucred);
if (getsockopt(fd, AF_UNSPEC, LOCAL_PEERCRED, &ucred, &len) == -1 || ucred.cr_pid <= 0) {
@@ -53,7 +53,7 @@ static bool waylandDetectWM(int fd, FFDisplayServerResult* result) {
return false;
}
result->wmProcessName.length = (uint32_t) size - 1;
# endif
#endif
// #1135: wl-restart is a special case
const char* filename = strrchr(result->wmProcessName.chars, '/');
@@ -72,10 +72,10 @@ static bool waylandDetectWM(int fd, FFDisplayServerResult* result) {
return true;
# else
#else
FF_UNUSED(fd, result);
return false;
# endif
#endif
}
static void waylandGlobalAddListener(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version) {
@@ -148,11 +148,11 @@ void ffWaylandOutputNameListener(void* data, FF_A_UNUSED void* output, const cha
}
display->type = ffdsGetDisplayType(name);
# if __linux__
#if __linux__
if (!display->edidName.length) {
matchDrmConnector(name, display);
}
# endif
#endif
display->id = ffWaylandGenerateIdFromName(name);
ffStrbufAppendS(&display->name, name);
}
@@ -2,12 +2,12 @@
#ifdef FF_HAVE_WAYLAND
# include "common/library.h"
# include "common/stringUtils.h"
#include "common/library.h"
#include "common/stringUtils.h"
# include <wayland-client.h>
#include <wayland-client.h>
# include "../displayserver_linux.h"
#include "../displayserver_linux.h"
typedef enum FF_A_PACKED WaylandProtocolType {
FF_WAYLAND_PROTOCOL_TYPE_NONE,
@@ -69,7 +69,7 @@ struct zwlr_output_manager_v1;
struct zwlr_output_mode_v1;
#ifndef ZWLR_OUTPUT_MANAGER_V1_INTERFACE
# define ZWLR_OUTPUT_MANAGER_V1_INTERFACE
#define ZWLR_OUTPUT_MANAGER_V1_INTERFACE
/**
* @page page_iface_zwlr_output_manager_v1 zwlr_output_manager_v1
* @section page_iface_zwlr_output_manager_v1_desc Description
@@ -138,7 +138,7 @@ struct zwlr_output_mode_v1;
extern const struct wl_interface zwlr_output_manager_v1_interface;
#endif
#ifndef ZWLR_OUTPUT_HEAD_V1_INTERFACE
# define ZWLR_OUTPUT_HEAD_V1_INTERFACE
#define ZWLR_OUTPUT_HEAD_V1_INTERFACE
/**
* @page page_iface_zwlr_output_head_v1 zwlr_output_head_v1
* @section page_iface_zwlr_output_head_v1_desc Description
@@ -179,7 +179,7 @@ extern const struct wl_interface zwlr_output_manager_v1_interface;
extern const struct wl_interface zwlr_output_head_v1_interface;
#endif
#ifndef ZWLR_OUTPUT_MODE_V1_INTERFACE
# define ZWLR_OUTPUT_MODE_V1_INTERFACE
#define ZWLR_OUTPUT_MODE_V1_INTERFACE
/**
* @page page_iface_zwlr_output_mode_v1 zwlr_output_mode_v1
* @section page_iface_zwlr_output_mode_v1_desc Description
@@ -210,7 +210,7 @@ extern const struct wl_interface zwlr_output_head_v1_interface;
extern const struct wl_interface zwlr_output_mode_v1_interface;
#endif
#ifndef ZWLR_OUTPUT_CONFIGURATION_V1_INTERFACE
# define ZWLR_OUTPUT_CONFIGURATION_V1_INTERFACE
#define ZWLR_OUTPUT_CONFIGURATION_V1_INTERFACE
/**
* @page page_iface_zwlr_output_configuration_v1 zwlr_output_configuration_v1
* @section page_iface_zwlr_output_configuration_v1_desc Description
@@ -245,7 +245,7 @@ extern const struct wl_interface zwlr_output_mode_v1_interface;
extern const struct wl_interface zwlr_output_configuration_v1_interface;
#endif
#ifndef ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_INTERFACE
# define ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_INTERFACE
#define ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_INTERFACE
/**
* @page page_iface_zwlr_output_configuration_head_v1 zwlr_output_configuration_head_v1
* @section page_iface_zwlr_output_configuration_head_v1_desc Description
@@ -408,7 +408,7 @@ zwlr_output_manager_v1_destroy(struct zwlr_output_manager_v1* zwlr_output_manage
// }
#ifndef ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_ENUM
# define ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_ENUM
#define ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_ENUM
enum zwlr_output_head_v1_adaptive_sync_state {
/**
* adaptive sync is disabled
@@ -896,7 +896,7 @@ zwlr_output_mode_v1_destroy(struct zwlr_output_mode_v1* zwlr_output_mode_v1) {
// }
#ifndef ZWLR_OUTPUT_CONFIGURATION_V1_ERROR_ENUM
# define ZWLR_OUTPUT_CONFIGURATION_V1_ERROR_ENUM
#define ZWLR_OUTPUT_CONFIGURATION_V1_ERROR_ENUM
enum zwlr_output_configuration_v1_error {
/**
* head has been configured twice
@@ -1119,7 +1119,7 @@ zwlr_output_configuration_v1_get_version(struct zwlr_output_configuration_v1* zw
// }
#ifndef ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_ENUM
# define ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_ENUM
#define ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_ENUM
enum zwlr_output_configuration_head_v1_error {
/**
* property has already been set
@@ -1147,10 +1147,10 @@ enum zwlr_output_configuration_head_v1_error {
*/
ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_INVALID_ADAPTIVE_SYNC_STATE = 6,
};
/**
* @ingroup iface_zwlr_output_configuration_head_v1
*/
# define ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_INVALID_ADAPTIVE_SYNC_STATE_SINCE_VERSION 4
/**
* @ingroup iface_zwlr_output_configuration_head_v1
*/
#define ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_INVALID_ADAPTIVE_SYNC_STATE_SINCE_VERSION 4
#endif /* ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_ENUM */
#define ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_SET_MODE 0
@@ -27,20 +27,20 @@
* THIS SOFTWARE.
*/
# include <stdbool.h>
# include <stdlib.h>
# include <stdint.h>
# include <wayland-util.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>
#include <wayland-util.h>
# ifndef __has_attribute
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
# endif
#ifndef __has_attribute
#define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
#endif
# if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
# define WL_PRIVATE __attribute__((visibility("hidden")))
# else
# define WL_PRIVATE
# endif
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
#define WL_PRIVATE __attribute__((visibility("hidden")))
#else
#define WL_PRIVATE
#endif
extern const struct wl_interface zwlr_output_configuration_head_v1_interface;
extern const struct wl_interface zwlr_output_configuration_v1_interface;
@@ -78,7 +78,7 @@ struct zxdg_output_manager_v1;
struct zxdg_output_v1;
#ifndef ZXDG_OUTPUT_MANAGER_V1_INTERFACE
# define ZXDG_OUTPUT_MANAGER_V1_INTERFACE
#define ZXDG_OUTPUT_MANAGER_V1_INTERFACE
/**
* @page page_iface_zxdg_output_manager_v1 zxdg_output_manager_v1
* @section page_iface_zxdg_output_manager_v1_desc Description
@@ -95,7 +95,7 @@ struct zxdg_output_v1;
extern const struct wl_interface zxdg_output_manager_v1_interface;
#endif
#ifndef ZXDG_OUTPUT_V1_INTERFACE
# define ZXDG_OUTPUT_V1_INTERFACE
#define ZXDG_OUTPUT_V1_INTERFACE
/**
* @page page_iface_zxdg_output_v1 zxdg_output_v1
* @section page_iface_zxdg_output_v1_desc Description
@@ -24,9 +24,9 @@
* DEALINGS IN THE SOFTWARE.
*/
# include <stdlib.h>
# include <stdint.h>
# include <wayland-util.h>
#include <stdlib.h>
#include <stdint.h>
#include <wayland-util.h>
extern const struct wl_interface wl_output_interface;
extern const struct wl_interface zxdg_output_v1_interface;
@@ -1,7 +1,7 @@
#ifdef FF_HAVE_WAYLAND
# include "wayland.h"
# include "wlr-output-management-unstable-v1-client-protocol.h"
#include "wayland.h"
#include "wlr-output-management-unstable-v1-client-protocol.h"
static void waylandZwlrTransformListener(void* data, FF_A_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, int32_t transform) {
WaylandDisplay* wldata = (WaylandDisplay*) data;
+12 -12
View File
@@ -9,18 +9,18 @@
#include <unistd.h>
#if __FreeBSD__
# include <sys/sysctl.h>
# include <sys/types.h>
# include <sys/user.h>
#include <sys/sysctl.h>
#include <sys/types.h>
#include <sys/user.h>
#elif __OpenBSD__
# include <sys/param.h>
# include <sys/sysctl.h>
# include <kvm.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <kvm.h>
#elif __sun
# include <procfs.h>
#include <procfs.h>
#elif __NetBSD__
# include <sys/types.h>
# include <sys/sysctl.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
static const char* parseEnv(void) {
@@ -273,9 +273,9 @@ static const char* getFromProcesses(FFDisplayServerResult* result) {
uint32_t userId = instance.state.platform.uid;
#if __FreeBSD__
# ifdef __DragonFly__
# define ki_comm kp_comm
# endif
#ifdef __DragonFly__
#define ki_comm kp_comm
#endif
int request[] = { CTL_KERN, KERN_PROC, KERN_PROC_UID, (int) userId };
size_t length = 0;
+9 -9
View File
@@ -2,16 +2,16 @@
#ifdef FF_HAVE_XCB_RANDR
# include "common/library.h"
# include "common/properties.h"
# include "common/edidHelper.h"
# include "common/mallocHelper.h"
# include "common/stringUtils.h"
#include "common/library.h"
#include "common/properties.h"
#include "common/edidHelper.h"
#include "common/mallocHelper.h"
#include "common/stringUtils.h"
# include <stdlib.h>
# include <string.h>
# include <xcb/randr.h>
# include <xcb/xcb.h>
#include <stdlib.h>
#include <string.h>
#include <xcb/randr.h>
#include <xcb/xcb.h>
typedef struct XcbRandrData {
FF_LIBRARY_SYMBOL(xcb_randr_get_screen_resources_current)
+6 -6
View File
@@ -2,13 +2,13 @@
#ifdef FF_HAVE_XRANDR
# include "common/library.h"
# include "common/properties.h"
# include "common/edidHelper.h"
# include "common/stringUtils.h"
#include "common/library.h"
#include "common/properties.h"
#include "common/edidHelper.h"
#include "common/stringUtils.h"
# include <X11/extensions/Xrandr.h>
# include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
#include <X11/Xlib.h>
typedef struct XrandrData {
FF_LIBRARY_SYMBOL(XInternAtom)
+2 -2
View File
@@ -6,9 +6,9 @@
#include "common/debug.h"
#ifdef __HAIKU__
# define RESOLV_CONF "/system/settings/network/resolv.conf"
#define RESOLV_CONF "/system/settings/network/resolv.conf"
#else
# define RESOLV_CONF "/etc/resolv.conf"
#define RESOLV_CONF "/etc/resolv.conf"
#endif
static const char* detectDnsFromConf(const char* path, FFDNSOptions* options, FFlist* results) {
+2 -2
View File
@@ -6,9 +6,9 @@
#include <usbhid.h>
#if __has_include(<dev/usb/usb_ioctl.h>)
# include <dev/usb/usb_ioctl.h> // FreeBSD
#include <dev/usb/usb_ioctl.h> // FreeBSD
#else
# include <bus/u4b/usb_ioctl.h> // DragonFly
#include <bus/u4b/usb_ioctl.h> // DragonFly
#endif
#define MAX_UHID_JOYS 64
+13 -13
View File
@@ -6,12 +6,12 @@
#include <stdalign.h>
#if _WIN32
# include <ntdef.h>
# include <windef.h>
#include <ntdef.h>
#include <windef.h>
#else
# include <sys/ioctl.h>
# include <uchar.h>
# include <errno.h>
#include <sys/ioctl.h>
#include <uchar.h>
#include <errno.h>
typedef struct _LUID {
uint32_t LowPart;
@@ -40,8 +40,8 @@ typedef union {
int64_t QuadPart;
} LARGE_INTEGER;
typedef int32_t NTSTATUS; // 0 for success, -1 for failure
# define NT_SUCCESS(Status) ((NTSTATUS) (Status) >= 0)
# define _In_range_(low, hi)
#define NT_SUCCESS(Status) ((NTSTATUS) (Status) >= 0)
#define _In_range_(low, hi)
#endif
#define D3DKMT_ALIGN64 alignas(8)
@@ -330,12 +330,12 @@ EXTERN_C _Check_return_ NTSTATUS APIENTRY D3DKMTQueryStatistics(_In_ CONST D3DKM
#else
// Ref: https://github.com/microsoft/WSL2-Linux-Kernel/blob/linux-msft-wsl-6.6.y/include/uapi/misc/d3dkmthk.h
# define LX_DXOPENADAPTERFROMLUID _IOWR(0x47, 0x01, D3DKMT_OPENADAPTERFROMLUID)
# define LX_DXQUERYADAPTERINFO _IOWR(0x47, 0x09, D3DKMT_QUERYADAPTERINFO)
# define LX_DXENUMADAPTERS2 _IOWR(0x47, 0x14, D3DKMT_ENUMADAPTERS2)
# define LX_DXCLOSEADAPTER _IOWR(0x47, 0x15, D3DKMT_CLOSEADAPTER)
# define LX_DXQUERYSTATISTICS _IOWR(0x47, 0x43, D3DKMT_QUERYSTATISTICS)
// Ref: https://github.com/microsoft/WSL2-Linux-Kernel/blob/linux-msft-wsl-6.6.y/include/uapi/misc/d3dkmthk.h
#define LX_DXOPENADAPTERFROMLUID _IOWR(0x47, 0x01, D3DKMT_OPENADAPTERFROMLUID)
#define LX_DXQUERYADAPTERINFO _IOWR(0x47, 0x09, D3DKMT_QUERYADAPTERINFO)
#define LX_DXENUMADAPTERS2 _IOWR(0x47, 0x14, D3DKMT_ENUMADAPTERS2)
#define LX_DXCLOSEADAPTER _IOWR(0x47, 0x15, D3DKMT_CLOSEADAPTER)
#define LX_DXQUERYSTATISTICS _IOWR(0x47, 0x43, D3DKMT_QUERYSTATISTICS)
extern int dxgfd; // File descriptor for /dev/dxg, initialized in gpu_wsl.c
+2 -2
View File
@@ -66,14 +66,14 @@ typedef struct FFGpuDriverPciBusId {
void ffGPUFillVendorAndName(uint8_t subclass, uint16_t vendor, uint16_t device, FFGPUResult* gpu);
void ffGPUQueryAmdGpuName(uint16_t deviceId, uint8_t revisionId, FFGPUResult* gpu);
# if FF_HAVE_DRM
#if FF_HAVE_DRM
const char* ffDrmDetectRadeon(const FFGPUOptions* options, FFGPUResult* gpu, const char* renderPath);
const char* ffDrmDetectAmdgpu(const FFGPUOptions* options, FFGPUResult* gpu, const char* renderPath);
const char* ffDrmDetectI915(FFGPUResult* gpu, int fd);
const char* ffDrmDetectXe(FFGPUResult* gpu, int fd);
const char* ffDrmDetectAsahi(FFGPUResult* gpu, int fd);
const char* ffDrmDetectNouveau(FFGPUResult* gpu, int fd);
# endif // FF_HAVE_DRM
#endif // FF_HAVE_DRM
const char* ffGPUDetectDriverSpecific(const FFGPUOptions* options, FFGPUResult* gpu, FFGpuDriverPciBusId pciBusId);
#endif // defined(XXX)
+2 -2
View File
@@ -48,9 +48,9 @@ static double detectGpuTemp(const FFstrbuf* gpuName) {
}
#ifdef __aarch64__
# include "common/apple/cf_helpers.h"
#include "common/apple/cf_helpers.h"
# include <IOKit/IOKitLib.h>
#include <IOKit/IOKitLib.h>
static const char* detectFrequency(FFGPUResult* gpu) {
// https://github.com/giampaolo/psutil/pull/2222/files
+5 -5
View File
@@ -6,9 +6,9 @@
#include <sys/pciio.h>
#include <fcntl.h>
#if __has_include(<dev/pci/pcireg.h>)
# include <dev/pci/pcireg.h> // FreeBSD
#include <dev/pci/pcireg.h> // FreeBSD
#else
# include <bus/pci/pcireg.h> // DragonFly
#include <bus/pci/pcireg.h> // DragonFly
#endif
static void fillGPUTypeGeneric(FFGPUResult* gpu) {
@@ -31,10 +31,10 @@ static void fillGPUTypeGeneric(FFGPUResult* gpu) {
}
#if FF_HAVE_DRM
# include "common/library.h"
# include "common/stringUtils.h"
#include "common/library.h"
#include "common/stringUtils.h"
# include <xf86drm.h>
#include <xf86drm.h>
static const char* detectByDrm(const FFGPUOptions* options, FFlist* gpus) {
FF_LIBRARY_LOAD_MESSAGE(libdrm, "libdrm" FF_LIBRARY_EXTENSION, 2)
+7 -7
View File
@@ -44,7 +44,7 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResult result, const char* soName);
#ifndef FF_GPU_DRIVER_DLLNAME_PATH_PREFIX
# define FF_GPU_DRIVER_DLLNAME_PATH_PREFIX
#define FF_GPU_DRIVER_DLLNAME_PATH_PREFIX
#endif
FF_A_UNUSED static inline bool getDriverSpecificDetectionFn(const char* vendor, __typeof__(&ffDetectNvidiaGpuInfo)* pDetectFn, const char** pDllName) {
@@ -66,18 +66,18 @@ FF_A_UNUSED static inline bool getDriverSpecificDetectionFn(const char* vendor,
#ifdef _WIN32
else if (vendor == FF_GPU_VENDOR_NAME_INTEL) {
*pDetectFn = ffDetectIntelGpuInfo;
# ifdef _WIN64
#ifdef _WIN64
*pDllName = FF_GPU_DRIVER_DLLNAME_PATH_PREFIX "ControlLib.dll";
# else
#else
*pDllName = FF_GPU_DRIVER_DLLNAME_PATH_PREFIX "ControlLib32.dll";
# endif
#endif
} else if (vendor == FF_GPU_VENDOR_NAME_AMD) {
*pDetectFn = ffDetectAmdGpuInfo;
# ifdef _WIN64
#ifdef _WIN64
*pDllName = FF_GPU_DRIVER_DLLNAME_PATH_PREFIX "atiadlxx.dll";
# else
#else
*pDllName = FF_GPU_DRIVER_DLLNAME_PATH_PREFIX "atiadlxy.dll";
# endif
#endif
}
#endif
else {
+22 -22
View File
@@ -1,19 +1,19 @@
#include "gpu.h"
#if FF_HAVE_DRM
# include <drm.h>
# include <fcntl.h>
# include <sys/ioctl.h>
#include <drm.h>
#include <fcntl.h>
#include <sys/ioctl.h>
# include "common/io.h"
# include "common/library.h"
# include "common/mallocHelper.h"
# include "common/stringUtils.h"
#include "common/io.h"
#include "common/library.h"
#include "common/mallocHelper.h"
#include "common/stringUtils.h"
# include "intel_drm.h"
# include "asahi_drm.h"
# include <radeon_drm.h>
# include <nouveau_drm.h>
#include "intel_drm.h"
#include "asahi_drm.h"
#include <radeon_drm.h>
#include <nouveau_drm.h>
const char* ffDrmDetectRadeon(const FFGPUOptions* options, FFGPUResult* gpu, const char* renderPath) {
FF_AUTO_CLOSE_FD int fd = open(renderPath, O_RDONLY | O_CLOEXEC);
@@ -76,12 +76,12 @@ const char* ffDrmDetectRadeon(const FFGPUOptions* options, FFGPUResult* gpu, con
return NULL;
}
# ifdef FF_HAVE_DRM_AMDGPU
# include <amdgpu.h>
# include <amdgpu_drm.h>
#ifdef FF_HAVE_DRM_AMDGPU
#include <amdgpu.h>
#include <amdgpu_drm.h>
const char* ffDrmDetectAmdgpu(const FFGPUOptions* options, FFGPUResult* gpu, const char* renderPath) {
# if FF_HAVE_DRM_AMDGPU
#if FF_HAVE_DRM_AMDGPU
FF_LIBRARY_LOAD_MESSAGE(libdrm, "libdrm_amdgpu" FF_LIBRARY_EXTENSION, 1)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, amdgpu_device_initialize)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, amdgpu_get_marketing_name)
@@ -117,7 +117,7 @@ const char* ffDrmDetectAmdgpu(const FFGPUOptions* options, FFGPUResult* gpu, con
gpu->frequency = (uint32_t) (gpuInfo.max_engine_clk / 1000u);
gpu->index = FF_GPU_INDEX_UNSET;
gpu->type = gpuInfo.ids_flags & AMDGPU_IDS_FLAGS_FUSION ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE;
# define FF_VRAM_CASE(name, value) \
#define FF_VRAM_CASE(name, value) \
case value /* AMDGPU_VRAM_TYPE_ ## name */: \
ffStrbufSetStatic(&gpu->memoryType, #name); \
break
@@ -158,12 +158,12 @@ const char* ffDrmDetectAmdgpu(const FFGPUOptions* options, FFGPUResult* gpu, con
ffamdgpu_device_deinitialize(handle);
return NULL;
# else
#else
FF_UNUSED(options, gpu, renderPath);
return "Fastfetch is compiled without libdrm support";
# endif
#endif
}
# endif
#endif
const char* ffDrmDetectI915(FFGPUResult* gpu, int fd) {
{
@@ -326,9 +326,9 @@ const char* ffDrmDetectAsahi(FFGPUResult* gpu, int fd) {
return "Failed to query Asahi GPU information";
}
# ifndef DRM_IOCTL_NOUVEAU_GETPARAM
# define DRM_IOCTL_NOUVEAU_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GETPARAM, struct drm_nouveau_getparam)
# endif
#ifndef DRM_IOCTL_NOUVEAU_GETPARAM
#define DRM_IOCTL_NOUVEAU_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GETPARAM, struct drm_nouveau_getparam)
#endif
const char* ffDrmDetectNouveau(FFGPUResult* gpu, int fd) {
struct drm_nouveau_getparam getparam = {};
+19 -19
View File
@@ -13,26 +13,26 @@
#include <stdint.h>
#ifdef FF_HAVE_DRM_AMDGPU
# include <amdgpu.h>
# include <amdgpu_drm.h>
# include <fcntl.h>
#include <amdgpu.h>
#include <amdgpu_drm.h>
#include <fcntl.h>
#endif
#ifdef FF_HAVE_DRM
# include "intel_drm.h"
# include <fcntl.h>
# include <sys/ioctl.h>
#include "intel_drm.h"
#include <fcntl.h>
#include <sys/ioctl.h>
#endif
#if defined(FF_HAVE_DRM) && defined(__aarch64__)
// https://github.com/alyssarosenzweig/linux/blob/agx-uapi-v7/include/uapi/drm/asahi_drm.h
// Found in kernel-headers-6.14.4-400.asahi.fc42.aarch64
# if __has_include(<drm/asahi_drm.h>)
# include <drm/asahi_drm.h>
# else
# include "asahi_drm.h"
# endif
# define FF_HAVE_DRM_ASAHI 1
// https://github.com/alyssarosenzweig/linux/blob/agx-uapi-v7/include/uapi/drm/asahi_drm.h
// Found in kernel-headers-6.14.4-400.asahi.fc42.aarch64
#if __has_include(<drm/asahi_drm.h>)
#include <drm/asahi_drm.h>
#else
#include "asahi_drm.h"
#endif
#define FF_HAVE_DRM_ASAHI 1
#endif
static bool pciDetectDriver(FFstrbuf* result, FFstrbuf* pciDir, FFstrbuf* buffer, FF_A_UNUSED const char* drmKey) {
@@ -108,12 +108,12 @@ static const char* drmDetectAmdSpecific(const FFGPUOptions* options, FFGPUResult
if (ffStrbufEqualS(&gpu->driver, "radeon")) {
return ffDrmDetectRadeon(options, gpu, buffer->chars);
} else {
# if FF_HAVE_DRM_AMDGPU
#if FF_HAVE_DRM_AMDGPU
return ffDrmDetectAmdgpu(options, gpu, buffer->chars);
# else
#else
FF_UNUSED(options, gpu, drmKey, buffer);
return "Fastfetch is not compiled with libdrm_amdgpu support";
# endif
#endif
}
#else
FF_UNUSED(options, gpu, drmKey, buffer);
@@ -503,14 +503,14 @@ FF_A_UNUSED static const char* drmDetectAsahiSpecific(FFGPUResult* gpu, const ch
}
ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_APPLE);
# if FF_HAVE_DRM_ASAHI
#if FF_HAVE_DRM_ASAHI
ffStrbufSetS(buffer, "/dev/dri/");
ffStrbufAppendS(buffer, drmKey);
FF_AUTO_CLOSE_FD int fd = open(buffer->chars, O_RDONLY | O_CLOEXEC);
if (fd >= 0) {
return ffDrmDetectAsahi(gpu, fd);
}
# endif
#endif
return NULL;
}
+10 -10
View File
@@ -23,7 +23,7 @@ struct FFNvmlData {
#if defined(_WIN32) && !defined(FF_DISABLE_DLOPEN)
# include "nvapi.h"
#include "nvapi.h"
struct FFNvapiData {
FF_LIBRARY_SYMBOL(nvapi_Unload)
@@ -39,15 +39,15 @@ static const char* detectMoreByNvapi(FFGpuDriverResult* result) {
nvapiData.inited = true;
FF_LIBRARY_LOAD_MESSAGE(libnvapi,
# ifdef _WIN64
#ifdef _WIN64
"nvapi64.dll"
# else
#else
"nvapi.dll"
# endif
#endif
,
1);
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libnvapi, nvapi_QueryInterface)
# define FF_NVAPI_INTERFACE(iName, iOffset) \
#define FF_NVAPI_INTERFACE(iName, iOffset) \
__typeof__(&iName) ff##iName = ffnvapi_QueryInterface(iOffset); \
if (ff##iName == NULL) return "nvapi_QueryInterface " #iName " failed";
@@ -56,7 +56,7 @@ static const char* detectMoreByNvapi(FFGpuDriverResult* result) {
FF_NVAPI_INTERFACE(nvapi_EnumPhysicalGPUs, NVAPI_INTERFACE_OFFSET_ENUM_PHYSICAL_GPUS)
FF_NVAPI_INTERFACE(nvapi_GPU_GetRamType, NVAPI_INTERFACE_OFFSET_GPU_GET_RAM_TYPE)
FF_NVAPI_INTERFACE(nvapi_GPU_GetGPUType, NVAPI_INTERFACE_OFFSET_GPU_GET_GPU_TYPE)
# undef FF_NVAPI_INTERFACE
#undef FF_NVAPI_INTERFACE
if (ffnvapi_Initialize() < 0) {
return "NvAPI_Initialize() failed";
@@ -94,7 +94,7 @@ static const char* detectMoreByNvapi(FFGpuDriverResult* result) {
NvApiGPUMemoryType memType;
if (result->memoryType && nvapiData.ffnvapi_GPU_GetRamType(gpuHandle, &memType) == 0) {
switch (memType) {
# define FF_NVAPI_MEMORY_TYPE(type) \
#define FF_NVAPI_MEMORY_TYPE(type) \
case NVAPI_GPU_MEMORY_TYPE_##type: \
ffStrbufSetStatic(result->memoryType, #type); \
break;
@@ -115,7 +115,7 @@ static const char* detectMoreByNvapi(FFGpuDriverResult* result) {
FF_NVAPI_MEMORY_TYPE(GDDR6)
FF_NVAPI_MEMORY_TYPE(GDDR6X)
FF_NVAPI_MEMORY_TYPE(GDDR7)
# undef FF_NVAPI_MEMORY_TYPE
#undef FF_NVAPI_MEMORY_TYPE
default:
ffStrbufSetF(result->memoryType, "Unknown (%d)", memType);
break;
@@ -236,12 +236,12 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR
unsigned int value;
if (nvmlData.ffnvmlDeviceGetIndex(device, &value) == NVML_SUCCESS) {
*result.index = value;
# ifdef _WIN32
#ifdef _WIN32
// Don't bother loading nvapi for GPU type detection only
if (result.memoryType) {
detectMoreByNvapi(&result);
}
# endif
#endif
}
}
+13 -13
View File
@@ -5,21 +5,21 @@
#include <stdlib.h>
#ifdef __FreeBSD__
# include <paths.h>
# ifndef _PATH_LOCALBASE
# define _PATH_LOCALBASE "/usr/local"
# endif
#include <paths.h>
#ifndef _PATH_LOCALBASE
#define _PATH_LOCALBASE "/usr/local"
#endif
#elif __OpenBSD__
# define _PATH_LOCALBASE "/usr/local"
#define _PATH_LOCALBASE "/usr/local"
#elif __NetBSD__
# define _PATH_LOCALBASE "/usr/pkg"
#define _PATH_LOCALBASE "/usr/pkg"
#endif
#if FF_HAVE_EMBEDDED_PCIIDS
# include "fastfetch_pciids.c.inc"
#include "fastfetch_pciids.c.inc"
#endif
#if FF_HAVE_EMBEDDED_AMDGPUIDS
# include "fastfetch_amdgpuids.c.inc"
#include "fastfetch_amdgpuids.c.inc"
#endif
#define FF_STR_INDIR(x) #x
@@ -39,7 +39,7 @@ static const FFstrbuf* loadPciIds() {
#else // FF_CUSTOM_PCI_IDS_PATH
# if __linux__
#if __linux__
ffReadFileBuffer(FASTFETCH_TARGET_DIR_USR "/share/hwdata/pci.ids", &pciids);
if (pciids.length == 0) {
ffReadFileBuffer(FASTFETCH_TARGET_DIR_USR "/share/misc/pci.ids", &pciids); // debian?
@@ -47,16 +47,16 @@ static const FFstrbuf* loadPciIds() {
ffReadFileBuffer(FASTFETCH_TARGET_DIR_USR "/local/share/hwdata/pci.ids", &pciids);
}
}
# elif __OpenBSD__ || __FreeBSD__ || __NetBSD__
#elif __OpenBSD__ || __FreeBSD__ || __NetBSD__
ffReadFileBuffer(_PATH_LOCALBASE "/share/hwdata/pci.ids", &pciids);
if (pciids.length == 0) {
ffReadFileBuffer(_PATH_LOCALBASE "/share/pciids/pci.ids", &pciids);
}
# elif __sun
#elif __sun
ffReadFileBuffer(FASTFETCH_TARGET_DIR_ROOT "/usr/share/hwdata/pci.ids", &pciids);
# elif __HAIKU__
#elif __HAIKU__
ffReadFileBuffer(FASTFETCH_TARGET_DIR_ROOT "/system/data/hwdata/pci.ids", &pciids);
# endif
#endif
#endif // FF_CUSTOM_PCI_IDS_PATH
+14 -14
View File
@@ -1,6 +1,6 @@
#include "detection/gpu/gpu.h"
#if __linux__
# define FF_GPU_DRIVER_DLLNAME_PATH_PREFIX "/usr/lib/wsl/lib/"
#define FF_GPU_DRIVER_DLLNAME_PATH_PREFIX "/usr/lib/wsl/lib/"
#endif
#include "detection/gpu/gpu_driver_specific.h"
#include "common/debug.h"
@@ -9,16 +9,16 @@
#include "d3dkmthk.h"
#if _WIN32
# include "common/windows/unicode.h"
# include "common/windows/registry.h"
#include "common/windows/unicode.h"
#include "common/windows/registry.h"
# if FF_WIN81_COMPAT
# include "common/mallocHelper.h"
# include <windows.h>
# include <cfgmgr32.h>
# include <devguid.h>
#if FF_WIN81_COMPAT
#include "common/mallocHelper.h"
#include <windows.h>
#include <cfgmgr32.h>
#include <devguid.h>
# define GUID_DEVCLASS_DISPLAY_STRING L"{4d36e968-e325-11ce-bfc1-08002be10318}" // Found in <devguid.h>
#define GUID_DEVCLASS_DISPLAY_STRING L"{4d36e968-e325-11ce-bfc1-08002be10318}" // Found in <devguid.h>
static bool queryDeviceIdsFallback(D3DKMT_ADAPTERADDRESS adapterAddress, D3DKMT_DEVICE_IDS* outDeviceIds) {
FF_DEBUG("KMTQAITYPE_PHYSICALADAPTERDEVICEIDS failed. Attempting queryDeviceIdsFallback: bus=%u device=%u function=%u",
@@ -128,7 +128,7 @@ static bool queryDeviceIdsFallback(D3DKMT_ADAPTERADDRESS adapterAddress, D3DKMT_
FF_DEBUG("Cache miss for adapter address: bus=%u device=%u function=%u", adapterAddress.BusNumber, adapterAddress.DeviceNumber, adapterAddress.FunctionNumber);
return false;
}
# endif // FF_WIN81_COMPAT
#endif // FF_WIN81_COMPAT
static bool queryVendorNameViaRegistry(FFstrbuf* vendor, D3DKMT_HANDLE hAdapter) {
// `KMTQAITYPE_QUERY_ADAPTER_UNIQUE_GUID` reports the GUID value used by the adapter's registry key (DirectX and Video)
@@ -158,10 +158,10 @@ static bool queryVendorNameViaRegistry(FFstrbuf* vendor, D3DKMT_HANDLE hAdapter)
}
#else
# include <unistd.h>
# include <fcntl.h>
# include <sys/ioctl.h>
# include <uchar.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <uchar.h>
int dxgfd = -2;
+7 -7
View File
@@ -6,9 +6,9 @@ extern "C" {
#if __has_include(<directx/dxcore.h>) && __has_include(<dxguids/dxguids.h>)
# include <directx/dxcore.h>
# include <dxguids/dxguids.h>
# include "common/windows/util.hpp"
#include <directx/dxcore.h>
#include <dxguids/dxguids.h>
#include "common/windows/util.hpp"
static IDXCoreAdapterFactory* loadDxCoreFactory() {
static bool initialized = false;
@@ -23,14 +23,14 @@ static IDXCoreAdapterFactory* loadDxCoreFactory() {
// DXCoreCreateAdapterFactory is a reloaded function, so we can't use FF_LIBRARY_LOAD_SYMBOL_MESSAGE here
typedef HRESULT (*DXCoreCreateAdapterFactory_t)(REFIID riid, void** ppvFactory);
# ifndef FF_DISABLE_DLOPEN
#ifndef FF_DISABLE_DLOPEN
auto ffDXCoreCreateAdapterFactory = (DXCoreCreateAdapterFactory_t) dlsym(dxcore, "DXCoreCreateAdapterFactory");
if (ffDXCoreCreateAdapterFactory == nullptr) {
return NULL;
}
# else
#else
auto ffDXCoreCreateAdapterFactory = (DXCoreCreateAdapterFactory_t) DXCoreCreateAdapterFactory;
# endif
#endif
HRESULT hr = ffDXCoreCreateAdapterFactory(IID_PPV_ARGS(&factory));
if (FAILED(hr)) {
@@ -72,7 +72,7 @@ extern "C" const char* ffGPUDetectTypeWithDXCore(LUID adapterLuid, FFGPUResult*
#else
# warning "DXCore headers not available, GPU type detection may be less accurate"
#warning "DXCore headers not available, GPU type detection may be less accurate"
extern "C" const char* ffGPUDetectTypeWithDXCore(LUID adapterLuid, FFGPUResult* gpu) {
FF_UNUSED(adapterLuid, gpu);
+2 -2
View File
@@ -7,9 +7,9 @@
#include <sys/kbio.h>
#if __has_include(<dev/usb/usb_ioctl.h>)
# include <dev/usb/usb_ioctl.h> // FreeBSD
#include <dev/usb/usb_ioctl.h> // FreeBSD
#else
# include <bus/u4b/usb_ioctl.h> // DragonFly
#include <bus/u4b/usb_ioctl.h> // DragonFly
#endif
static const char* detectByIoctl(FFlist* devices) {
+3 -3
View File
@@ -10,11 +10,11 @@ const char* ffDetectLibc(FFLibcResult* result) {
result->name = "ndk-bionic";
result->version = FF_STR(__NDK_MAJOR__) "." FF_STR(__NDK_MINOR__) "." FF_STR(__NDK_BUILD__)
# if __NDK_BETA__
#if __NDK_BETA__
"-beta" FF_STR(__NDK_BETA__)
# elif __NDK_CANARY__
#elif __NDK_CANARY__
"-canary"
# endif
#endif
;
return NULL;
+4 -4
View File
@@ -6,14 +6,14 @@ const char* ffDetectLibc(FFLibcResult* result) {
#ifdef __DragonFly__ // We define `__FreeBSD__` on DragonFly BSD for simplification
result->name = "DF";
# ifdef FF_DF_VERSION
#ifdef FF_DF_VERSION
result->version = FF_DF_VERSION;
# endif
#endif
#elif __FreeBSD__
result->name = "FBSD";
# ifdef FF_FBSD_VERSION
#ifdef FF_FBSD_VERSION
result->version = FF_FBSD_VERSION;
# endif
#endif
#endif
return NULL;
+3 -3
View File
@@ -14,11 +14,11 @@ const char* ffDetectLibc(FFLibcResult* result) {
result->version = FF_STR(__GLIBC__) "." FF_STR(__GLIBC_MINOR__);
#else
result->name = "musl";
# ifdef FF_MUSL_VERSION
#ifdef FF_MUSL_VERSION
result->version = FF_MUSL_VERSION;
# else
#else
result->version = NULL;
# endif
#endif
#endif
return NULL;
+1 -1
View File
@@ -3,7 +3,7 @@ extern "C" {
}
#ifdef __MINGW32__
# include <_mingw.h>
#include <_mingw.h>
#endif
template <uint32_t Major, uint32_t Minor>
+3 -3
View File
@@ -36,9 +36,9 @@ static const char* getSshdVersion(FFstrbuf* version) {
}
#ifdef FF_HAVE_ZLIB
# include "common/library.h"
# include <stdlib.h>
# include <zlib.h>
#include "common/library.h"
#include <stdlib.h>
#include <zlib.h>
static const char* getSddmVersion(FFstrbuf* version) {
FF_LIBRARY_LOAD_MESSAGE(zlib, "libz" FF_LIBRARY_EXTENSION, 2)
+5 -5
View File
@@ -3,11 +3,11 @@
#include <sys/sysctl.h>
#if __FreeBSD__ || __OpenBSD__ || __NetBSD__
# include <sys/types.h>
# include <sys/resource.h>
# if __FreeBSD__
# include <vm/vm_param.h>
# endif
#include <sys/types.h>
#include <sys/resource.h>
#if __FreeBSD__
#include <vm/vm_param.h>
#endif
#endif
const char* ffDetectLoadavg(double result[3]) {
+6 -6
View File
@@ -4,16 +4,16 @@
#include "modules/localip/option.h"
#ifndef IN6_IS_ADDR_GLOBAL
/* Global Unicast: 2000::/3 (001...) */
# define IN6_IS_ADDR_GLOBAL(a) (((a)->s6_addr[0] & 0xE0) == 0x20)
/* Global Unicast: 2000::/3 (001...) */
#define IN6_IS_ADDR_GLOBAL(a) (((a)->s6_addr[0] & 0xE0) == 0x20)
#endif
#ifndef IN6_IS_ADDR_UNIQUE_LOCAL
/* Unique Local: fc00::/7 (1111 110...) */
# define IN6_IS_ADDR_UNIQUE_LOCAL(a) (((a)->s6_addr[0] & 0xFE) == 0xFC)
/* Unique Local: fc00::/7 (1111 110...) */
#define IN6_IS_ADDR_UNIQUE_LOCAL(a) (((a)->s6_addr[0] & 0xFE) == 0xFC)
#endif
#ifndef IN6_IS_ADDR_LINKLOCAL
/* Link-Local: fe80::/10 (1111 1110 10...) */
# define IN6_IS_ADDR_LINKLOCAL(a) (((a)->s6_addr[0] == 0xFE) && (((a)->s6_addr[1] & 0xC0) == 0x80))
/* Link-Local: fe80::/10 (1111 1110 10...) */
#define IN6_IS_ADDR_LINKLOCAL(a) (((a)->s6_addr[0] == 0xFE) && (((a)->s6_addr[1] & 0xC0) == 0x80))
#endif
typedef struct FFLocalIpResult {
+251 -251
View File
@@ -16,27 +16,27 @@
#include <fcntl.h>
#ifdef __linux__
# include <linux/ethtool.h>
# include <linux/sockios.h>
# include <linux/if.h>
# include <linux/if_addr.h>
#include <linux/ethtool.h>
#include <linux/sockios.h>
#include <linux/if.h>
#include <linux/if_addr.h>
#endif
#if __has_include(<netinet6/in6_var.h>)
# include <netinet6/in6_var.h>
#include <netinet6/in6_var.h>
#endif
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__) || defined(__HAIKU__)
# include <net/if_media.h>
# include <net/if_dl.h>
#include <net/if_media.h>
#include <net/if_dl.h>
#elif !defined(__GNU__)
# include <netpacket/packet.h>
#include <netpacket/packet.h>
#endif
#if defined(__sun) || defined(__HAIKU__)
# include <sys/sockio.h>
#include <sys/sockio.h>
#endif
#if defined(__sun)
# include <kstat.h>
#include <kstat.h>
static inline void kstatFreeWrap(kstat_ctl_t** pkc) {
assert(pkc);
@@ -135,16 +135,16 @@ static FFLocalIpIpv6Type getIpv6Type(struct ifaddrs* ifa) {
static int sockfd = 0;
if (sockfd == 0) {
sockfd = socket(AF_INET6, SOCK_DGRAM
# ifdef SOCK_CLOEXEC
#ifdef SOCK_CLOEXEC
| SOCK_CLOEXEC
# endif
#endif
,
0);
# ifndef SOCK_CLOEXEC
#ifndef SOCK_CLOEXEC
if (sockfd > 0) {
fcntl(sockfd, F_SETFD, FD_CLOEXEC);
}
# endif
#endif
}
if (sockfd < 0) {
return result;
@@ -158,15 +158,15 @@ static FFLocalIpIpv6Type getIpv6Type(struct ifaddrs* ifa) {
return result;
}
# ifdef IN6_IFF_PREFER_SOURCE
#ifdef IN6_IFF_PREFER_SOURCE
if (ifr6.ifr_ifru.ifru_flags6 & IN6_IFF_PREFER_SOURCE) {
result |= FF_LOCALIP_IPV6_TYPE_PREFERRED_BIT;
}
# endif
#endif
if (ifr6.ifr_ifru.ifru_flags6 & (IN6_IFF_DEPRECATED | IN6_IFF_TEMPORARY | IN6_IFF_TENTATIVE | IN6_IFF_DUPLICATED
# ifdef IN6_IFF_OPTIMISTIC
#ifdef IN6_IFF_OPTIMISTIC
| IN6_IFF_OPTIMISTIC
# endif
#endif
))
result |= FF_LOCALIP_IPV6_TYPE_SECONDARY_BIT;
return result;
@@ -519,11 +519,11 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) {
#if !defined(__sun) && !defined(__GNU__)
if (options->showType & FF_LOCALIP_TYPE_MAC_BIT) {
if (adapter->mac->ifa_addr) {
# if __FreeBSD__ || __OpenBSD__ || __APPLE__ || __NetBSD__ || __HAIKU__
#if __FreeBSD__ || __OpenBSD__ || __APPLE__ || __NetBSD__ || __HAIKU__
uint8_t* ptr = (uint8_t*) LLADDR((struct sockaddr_dl*) adapter->mac->ifa_addr);
# else
#else
uint8_t* ptr = ((struct sockaddr_ll*) adapter->mac->ifa_addr)->sll_addr;
# endif
#endif
ffStrbufSetF(&item->mac, "%02x:%02x:%02x:%02x:%02x:%02x", ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]);
FF_DEBUG("Added MAC address %s for interface %s", item->mac.chars, adapter->mac->ifa_name);
} else {
@@ -584,379 +584,379 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) {
if (ioctl(sockfd, SIOCGIFMEDIA, &ifmr) == 0 && (IFM_TYPE(ifmr.ifm_active) & IFM_ETHER)) {
FF_DEBUG("Interface %s media type: 0x%x", iface->name.chars, (unsigned) IFM_SUBTYPE(ifmr.ifm_active));
switch (IFM_SUBTYPE(ifmr.ifm_active)) {
# ifdef IFM_HPNA_1
#ifdef IFM_HPNA_1
case IFM_HPNA_1:
# endif
#endif
iface->speed = 1;
break;
# ifdef IFM_1000_CX
#ifdef IFM_1000_CX
case IFM_1000_CX:
# endif
# ifdef IFM_1000_CX_SGMII
#endif
#ifdef IFM_1000_CX_SGMII
case IFM_1000_CX_SGMII:
# endif
# ifdef IFM_1000_KX
#endif
#ifdef IFM_1000_KX
case IFM_1000_KX:
# endif
# ifdef IFM_1000_LX
#endif
#ifdef IFM_1000_LX
case IFM_1000_LX:
# endif
# ifdef IFM_1000_SGMII
#endif
#ifdef IFM_1000_SGMII
case IFM_1000_SGMII:
# endif
# ifdef IFM_1000_SX
#endif
#ifdef IFM_1000_SX
case IFM_1000_SX:
# endif
# ifdef IFM_1000_T
#endif
#ifdef IFM_1000_T
case IFM_1000_T:
# endif
#endif
iface->speed = 1000;
break;
# ifdef IFM_100G_AUI2
#ifdef IFM_100G_AUI2
case IFM_100G_AUI2:
# endif
# ifdef IFM_100G_AUI2_AC
#endif
#ifdef IFM_100G_AUI2_AC
case IFM_100G_AUI2_AC:
# endif
# ifdef IFM_100G_AUI4
#endif
#ifdef IFM_100G_AUI4
case IFM_100G_AUI4:
# endif
# ifdef IFM_100G_AUI4_AC
#endif
#ifdef IFM_100G_AUI4_AC
case IFM_100G_AUI4_AC:
# endif
# ifdef IFM_100G_CAUI2
#endif
#ifdef IFM_100G_CAUI2
case IFM_100G_CAUI2:
# endif
# ifdef IFM_100G_CAUI2_AC
#endif
#ifdef IFM_100G_CAUI2_AC
case IFM_100G_CAUI2_AC:
# endif
# ifdef IFM_100G_CAUI4
#endif
#ifdef IFM_100G_CAUI4
case IFM_100G_CAUI4:
# endif
# ifdef IFM_100G_CAUI4_AC
#endif
#ifdef IFM_100G_CAUI4_AC
case IFM_100G_CAUI4_AC:
# endif
# ifdef IFM_100G_CP2
#endif
#ifdef IFM_100G_CP2
case IFM_100G_CP2:
# endif
# ifdef IFM_100G_CR4
#endif
#ifdef IFM_100G_CR4
case IFM_100G_CR4:
# endif
# ifdef IFM_100G_CR_PAM4
#endif
#ifdef IFM_100G_CR_PAM4
case IFM_100G_CR_PAM4:
# endif
# ifdef IFM_100G_DR
#endif
#ifdef IFM_100G_DR
case IFM_100G_DR:
# endif
# ifdef IFM_100G_KR2_PAM4
#endif
#ifdef IFM_100G_KR2_PAM4
case IFM_100G_KR2_PAM4:
# endif
# ifdef IFM_100G_KR4
#endif
#ifdef IFM_100G_KR4
case IFM_100G_KR4:
# endif
# ifdef IFM_100G_KR_PAM4
#endif
#ifdef IFM_100G_KR_PAM4
case IFM_100G_KR_PAM4:
# endif
# ifdef IFM_100G_LR4
#endif
#ifdef IFM_100G_LR4
case IFM_100G_LR4:
# endif
# ifdef IFM_100G_SR2
#endif
#ifdef IFM_100G_SR2
case IFM_100G_SR2:
# endif
# ifdef IFM_100G_SR4
#endif
#ifdef IFM_100G_SR4
case IFM_100G_SR4:
# endif
#endif
iface->speed = 100000;
break;
# ifdef IFM_100_FX
#ifdef IFM_100_FX
case IFM_100_FX:
# endif
# ifdef IFM_100_SGMII
#endif
#ifdef IFM_100_SGMII
case IFM_100_SGMII:
# endif
# ifdef IFM_100_T
#endif
#ifdef IFM_100_T
case IFM_100_T:
# endif
# ifdef IFM_100_T2
#endif
#ifdef IFM_100_T2
case IFM_100_T2:
# endif
# ifdef IFM_100_T4
#endif
#ifdef IFM_100_T4
case IFM_100_T4:
# endif
# ifdef IFM_100_TX
#endif
#ifdef IFM_100_TX
case IFM_100_TX:
# endif
# ifdef IFM_100_VG
#endif
#ifdef IFM_100_VG
case IFM_100_VG:
# endif
#endif
iface->speed = 100;
break;
# ifdef IFM_10G_AOC
#ifdef IFM_10G_AOC
case IFM_10G_AOC:
# endif
# ifdef IFM_10G_CR1
#endif
#ifdef IFM_10G_CR1
case IFM_10G_CR1:
# endif
# ifdef IFM_10G_CX4
#endif
#ifdef IFM_10G_CX4
case IFM_10G_CX4:
# endif
# ifdef IFM_10G_ER
#endif
#ifdef IFM_10G_ER
case IFM_10G_ER:
# endif
# ifdef IFM_10G_KR
#endif
#ifdef IFM_10G_KR
case IFM_10G_KR:
# endif
# ifdef IFM_10G_KX4
#endif
#ifdef IFM_10G_KX4
case IFM_10G_KX4:
# endif
# ifdef IFM_10G_LR
#endif
#ifdef IFM_10G_LR
case IFM_10G_LR:
# endif
# ifdef IFM_10G_LRM
#endif
#ifdef IFM_10G_LRM
case IFM_10G_LRM:
# endif
# ifdef IFM_10G_SFI
#endif
#ifdef IFM_10G_SFI
case IFM_10G_SFI:
# endif
# ifdef IFM_10G_SR
#endif
#ifdef IFM_10G_SR
case IFM_10G_SR:
# endif
# ifdef IFM_10G_T
#endif
#ifdef IFM_10G_T
case IFM_10G_T:
# endif
# ifdef IFM_10G_TWINAX
#endif
#ifdef IFM_10G_TWINAX
case IFM_10G_TWINAX:
# endif
# ifdef IFM_10G_TWINAX_LONG
#endif
#ifdef IFM_10G_TWINAX_LONG
case IFM_10G_TWINAX_LONG:
# endif
#endif
iface->speed = 10000;
break;
# ifdef IFM_10_2
#ifdef IFM_10_2
case IFM_10_2:
# endif
# ifdef IFM_10_5
#endif
#ifdef IFM_10_5
case IFM_10_5:
# endif
# ifdef IFM_10_FL
#endif
#ifdef IFM_10_FL
case IFM_10_FL:
# endif
# ifdef IFM_10_STP
#endif
#ifdef IFM_10_STP
case IFM_10_STP:
# endif
# ifdef IFM_10_T
#endif
#ifdef IFM_10_T
case IFM_10_T:
# endif
#endif
iface->speed = 10;
break;
# ifdef IFM_200G_AUI4
#ifdef IFM_200G_AUI4
case IFM_200G_AUI4:
# endif
# ifdef IFM_200G_AUI4_AC
#endif
#ifdef IFM_200G_AUI4_AC
case IFM_200G_AUI4_AC:
# endif
# ifdef IFM_200G_AUI8
#endif
#ifdef IFM_200G_AUI8
case IFM_200G_AUI8:
# endif
# ifdef IFM_200G_AUI8_AC
#endif
#ifdef IFM_200G_AUI8_AC
case IFM_200G_AUI8_AC:
# endif
# ifdef IFM_200G_CR4_PAM4
#endif
#ifdef IFM_200G_CR4_PAM4
case IFM_200G_CR4_PAM4:
# endif
# ifdef IFM_200G_DR4
#endif
#ifdef IFM_200G_DR4
case IFM_200G_DR4:
# endif
# ifdef IFM_200G_FR4
#endif
#ifdef IFM_200G_FR4
case IFM_200G_FR4:
# endif
# ifdef IFM_200G_KR4_PAM4
#endif
#ifdef IFM_200G_KR4_PAM4
case IFM_200G_KR4_PAM4:
# endif
# ifdef IFM_200G_LR4
#endif
#ifdef IFM_200G_LR4
case IFM_200G_LR4:
# endif
# ifdef IFM_200G_SR4
#endif
#ifdef IFM_200G_SR4
case IFM_200G_SR4:
# endif
#endif
iface->speed = 200000;
break;
# ifdef IFM_20G_KR2
#ifdef IFM_20G_KR2
case IFM_20G_KR2:
# endif
#endif
iface->speed = 20000;
break;
# ifdef IFM_2500_KX
#ifdef IFM_2500_KX
case IFM_2500_KX:
# endif
# ifdef IFM_2500_SX
#endif
#ifdef IFM_2500_SX
case IFM_2500_SX:
# endif
# ifdef IFM_2500_T
#endif
#ifdef IFM_2500_T
case IFM_2500_T:
# endif
# ifdef IFM_2500_X
#endif
#ifdef IFM_2500_X
case IFM_2500_X:
# endif
#endif
iface->speed = 2500;
break;
# ifdef IFM_25G_ACC
#ifdef IFM_25G_ACC
case IFM_25G_ACC:
# endif
# ifdef IFM_25G_AOC
#endif
#ifdef IFM_25G_AOC
case IFM_25G_AOC:
# endif
# ifdef IFM_25G_AUI
#endif
#ifdef IFM_25G_AUI
case IFM_25G_AUI:
# endif
# ifdef IFM_25G_CR
#endif
#ifdef IFM_25G_CR
case IFM_25G_CR:
# endif
# ifdef IFM_25G_CR1
#endif
#ifdef IFM_25G_CR1
case IFM_25G_CR1:
# endif
# ifdef IFM_25G_CR_S
#endif
#ifdef IFM_25G_CR_S
case IFM_25G_CR_S:
# endif
# ifdef IFM_25G_KR
#endif
#ifdef IFM_25G_KR
case IFM_25G_KR:
# endif
# ifdef IFM_25G_KR1
#endif
#ifdef IFM_25G_KR1
case IFM_25G_KR1:
# endif
# ifdef IFM_25G_KR_S
#endif
#ifdef IFM_25G_KR_S
case IFM_25G_KR_S:
# endif
# ifdef IFM_25G_LR
#endif
#ifdef IFM_25G_LR
case IFM_25G_LR:
# endif
# ifdef IFM_25G_PCIE
#endif
#ifdef IFM_25G_PCIE
case IFM_25G_PCIE:
# endif
# ifdef IFM_25G_SR
#endif
#ifdef IFM_25G_SR
case IFM_25G_SR:
# endif
# ifdef IFM_25G_T
#endif
#ifdef IFM_25G_T
case IFM_25G_T:
# endif
#endif
iface->speed = 25000;
break;
# ifdef IFM_400G_AUI8
#ifdef IFM_400G_AUI8
case IFM_400G_AUI8:
# endif
# ifdef IFM_400G_AUI8_AC
#endif
#ifdef IFM_400G_AUI8_AC
case IFM_400G_AUI8_AC:
# endif
# ifdef IFM_400G_DR4
#endif
#ifdef IFM_400G_DR4
case IFM_400G_DR4:
# endif
# ifdef IFM_400G_FR8
#endif
#ifdef IFM_400G_FR8
case IFM_400G_FR8:
# endif
# ifdef IFM_400G_LR8
#endif
#ifdef IFM_400G_LR8
case IFM_400G_LR8:
# endif
#endif
iface->speed = 400000;
break;
# ifdef IFM_40G_CR4
#ifdef IFM_40G_CR4
case IFM_40G_CR4:
# endif
# ifdef IFM_40G_ER4
#endif
#ifdef IFM_40G_ER4
case IFM_40G_ER4:
# endif
# ifdef IFM_40G_KR4
#endif
#ifdef IFM_40G_KR4
case IFM_40G_KR4:
# endif
# ifdef IFM_40G_LR4
#endif
#ifdef IFM_40G_LR4
case IFM_40G_LR4:
# endif
# ifdef IFM_40G_SR4
#endif
#ifdef IFM_40G_SR4
case IFM_40G_SR4:
# endif
# ifdef IFM_40G_XLAUI
#endif
#ifdef IFM_40G_XLAUI
case IFM_40G_XLAUI:
# endif
# ifdef IFM_40G_XLAUI_AC
#endif
#ifdef IFM_40G_XLAUI_AC
case IFM_40G_XLAUI_AC:
# endif
# ifdef IFM_40G_XLPPI
#endif
#ifdef IFM_40G_XLPPI
case IFM_40G_XLPPI:
# endif
# ifdef IFM_40G_LM4
#endif
#ifdef IFM_40G_LM4
case IFM_40G_LM4:
# endif
#endif
iface->speed = 40000;
break;
# ifdef IFM_5000_KR
#ifdef IFM_5000_KR
case IFM_5000_KR:
# endif
# ifdef IFM_5000_KR1
#endif
#ifdef IFM_5000_KR1
case IFM_5000_KR1:
# endif
# ifdef IFM_5000_KR_S
#endif
#ifdef IFM_5000_KR_S
case IFM_5000_KR_S:
# endif
# ifdef IFM_5000_T
#endif
#ifdef IFM_5000_T
case IFM_5000_T:
# endif
#endif
iface->speed = 5000;
break;
# ifdef IFM_50G_AUI1
#ifdef IFM_50G_AUI1
case IFM_50G_AUI1:
# endif
# ifdef IFM_50G_AUI1_AC
#endif
#ifdef IFM_50G_AUI1_AC
case IFM_50G_AUI1_AC:
# endif
# ifdef IFM_50G_AUI2
#endif
#ifdef IFM_50G_AUI2
case IFM_50G_AUI2:
# endif
# ifdef IFM_50G_AUI2_AC
#endif
#ifdef IFM_50G_AUI2_AC
case IFM_50G_AUI2_AC:
# endif
# ifdef IFM_50G_CP
#endif
#ifdef IFM_50G_CP
case IFM_50G_CP:
# endif
# ifdef IFM_50G_CR2
#endif
#ifdef IFM_50G_CR2
case IFM_50G_CR2:
# endif
# ifdef IFM_50G_FR
#endif
#ifdef IFM_50G_FR
case IFM_50G_FR:
# endif
# ifdef IFM_50G_KR2
#endif
#ifdef IFM_50G_KR2
case IFM_50G_KR2:
# endif
# ifdef IFM_50G_KR_PAM4
#endif
#ifdef IFM_50G_KR_PAM4
case IFM_50G_KR_PAM4:
# endif
# ifdef IFM_50G_LAUI2
#endif
#ifdef IFM_50G_LAUI2
case IFM_50G_LAUI2:
# endif
# ifdef IFM_50G_LAUI2_AC
#endif
#ifdef IFM_50G_LAUI2_AC
case IFM_50G_LAUI2_AC:
# endif
# ifdef IFM_50G_LR
#endif
#ifdef IFM_50G_LR
case IFM_50G_LR:
# endif
# ifdef IFM_50G_LR2
#endif
#ifdef IFM_50G_LR2
case IFM_50G_LR2:
# endif
# ifdef IFM_50G_PCIE
#endif
#ifdef IFM_50G_PCIE
case IFM_50G_PCIE:
# endif
# ifdef IFM_50G_SR
#endif
#ifdef IFM_50G_SR
case IFM_50G_SR:
# endif
# ifdef IFM_50G_SR2
#endif
#ifdef IFM_50G_SR2
case IFM_50G_SR2:
# endif
# ifdef IFM_50G_KR4
#endif
#ifdef IFM_50G_KR4
case IFM_50G_KR4:
# endif
#endif
iface->speed = 50000;
break;
# ifdef IFM_56G_R4
#ifdef IFM_56G_R4
case IFM_56G_R4:
# endif
#endif
iface->speed = 56000;
break;
default:
+2 -2
View File
@@ -9,9 +9,9 @@
#define FF_DBUS_MPRIS_PREFIX "org.mpris.MediaPlayer2."
#ifdef FF_HAVE_DBUS
# include "common/dbus.h"
#include "common/dbus.h"
# define FF_DBUS_ITER_CONTINUE(dbus, iterator) \
#define FF_DBUS_ITER_CONTINUE(dbus, iterator) \
{ \
if (!(dbus)->lib->ffdbus_message_iter_next(iterator)) \
break; \
+2 -2
View File
@@ -6,9 +6,9 @@
#include <usbhid.h>
#if __has_include(<dev/usb/usb_ioctl.h>)
# include <dev/usb/usb_ioctl.h> // FreeBSD
#include <dev/usb/usb_ioctl.h> // FreeBSD
#else
# include <bus/u4b/usb_ioctl.h> // DragonFly
#include <bus/u4b/usb_ioctl.h> // DragonFly
#endif
#define MAX_UHID_MICE 64

Some files were not shown because too many files have changed in this diff Show More