mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 10:22:12 +02:00
Global: removes FFlist::elementSize
Improves performance of module Sound and PhysicalMemory
This commit is contained in:
+45
-36
@@ -11,46 +11,49 @@
|
||||
|
||||
typedef struct FFlist {
|
||||
uint8_t* data;
|
||||
uint32_t elementSize;
|
||||
uint32_t length;
|
||||
uint32_t capacity;
|
||||
} FFlist;
|
||||
|
||||
void* ffListAdd(FFlist* list);
|
||||
void* ffListAdd(FFlist* list, uint32_t elementSize);
|
||||
|
||||
// Removes the first element, and copy its value to `*result`
|
||||
bool ffListShift(FFlist* list, void* result);
|
||||
bool ffListShift(FFlist* list, uint32_t elementSize, void* result);
|
||||
// Removes the last element, and copy its value to `*result`
|
||||
bool ffListPop(FFlist* list, void* result);
|
||||
bool ffListPop(FFlist* list, uint32_t elementSize, void* result);
|
||||
|
||||
static inline void ffListInit(FFlist* list, uint32_t elementSize) {
|
||||
assert(elementSize > 0);
|
||||
list->elementSize = elementSize;
|
||||
static inline void ffListInit(FFlist* list) {
|
||||
list->capacity = 0;
|
||||
list->length = 0;
|
||||
list->data = NULL;
|
||||
}
|
||||
|
||||
static inline void ffListInitA(FFlist* list, uint32_t elementSize, uint32_t capacity) {
|
||||
ffListInit(list, elementSize);
|
||||
ffListInit(list);
|
||||
list->capacity = capacity;
|
||||
list->data = __builtin_expect(capacity == 0, 0) ? NULL : (uint8_t*) malloc((size_t) list->capacity * list->elementSize);
|
||||
list->data = __builtin_expect(capacity == 0, 0) ? NULL : (uint8_t*) malloc((size_t) capacity * elementSize);
|
||||
}
|
||||
|
||||
static inline FFlist ffListCreate(uint32_t elementSize) {
|
||||
FF_A_NODISCARD static inline FFlist ffListCreate() {
|
||||
FFlist result;
|
||||
ffListInit(&result, elementSize);
|
||||
ffListInit(&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void* ffListGet(const FFlist* list, uint32_t index) {
|
||||
assert(list->capacity > index);
|
||||
return list->data + (index * list->elementSize);
|
||||
FF_A_NODISCARD static inline FFlist ffListCreateA(uint32_t elementSize, uint32_t capacity) {
|
||||
FFlist result;
|
||||
ffListInitA(&result, elementSize, capacity);
|
||||
return result;
|
||||
}
|
||||
|
||||
FF_A_NODISCARD static inline uint32_t ffListFirstIndexComp(const FFlist* list, void* compElement, bool (*compFunc)(const void*, const void*)) {
|
||||
FF_A_NODISCARD static inline void* ffListGet(const FFlist* list, uint32_t elementSize, uint32_t index) {
|
||||
assert(list->capacity > index);
|
||||
return list->data + (index * elementSize);
|
||||
}
|
||||
|
||||
FF_A_NODISCARD static inline uint32_t ffListFirstIndexComp(const FFlist* list, uint32_t elementSize, void* compElement, bool (*compFunc)(const void*, const void*)) {
|
||||
for (uint32_t i = 0; i < list->length; i++) {
|
||||
if (compFunc(ffListGet(list, i), compElement)) {
|
||||
if (compFunc(ffListGet(list, elementSize, i), compElement)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -58,24 +61,23 @@ FF_A_NODISCARD static inline uint32_t ffListFirstIndexComp(const FFlist* list, v
|
||||
return list->length;
|
||||
}
|
||||
|
||||
static inline bool ffListContains(const FFlist* list, void* compElement, bool (*compFunc)(const void*, const void*)) {
|
||||
return ffListFirstIndexComp(list, compElement, compFunc) != list->length;
|
||||
FF_A_NODISCARD static inline bool ffListContains(const FFlist* list, uint32_t elementSize, void* compElement, bool (*compFunc)(const void*, const void*)) {
|
||||
return ffListFirstIndexComp(list, elementSize, compElement, compFunc) != list->length;
|
||||
}
|
||||
|
||||
static inline void ffListSort(FFlist* list, int (*compar)(const void*, const void*)) {
|
||||
qsort(list->data, list->length, list->elementSize, compar);
|
||||
static inline void ffListSort(FFlist* list, uint32_t elementSize, int (*compar)(const void*, const void*)) {
|
||||
qsort(list->data, list->length, elementSize, compar);
|
||||
}
|
||||
|
||||
// Move the contents of `src` into `list`, and left `src` empty
|
||||
static inline void ffListInitMove(FFlist* list, FFlist* src) {
|
||||
if (src) {
|
||||
list->elementSize = src->elementSize;
|
||||
list->capacity = src->capacity;
|
||||
list->length = src->length;
|
||||
list->data = src->data;
|
||||
ffListInit(src, list->elementSize);
|
||||
ffListInit(src);
|
||||
} else {
|
||||
ffListInit(list, 0);
|
||||
ffListInit(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,35 +96,29 @@ static inline void ffListClear(FFlist* list) {
|
||||
list->length = 0;
|
||||
}
|
||||
|
||||
static inline void ffListReserve(FFlist* list, uint32_t newCapacity) {
|
||||
static inline void ffListReserve(FFlist* list, uint32_t elementSize, uint32_t newCapacity) {
|
||||
if (__builtin_expect(newCapacity <= list->capacity, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
list->data = (uint8_t*) realloc(list->data, (size_t) newCapacity * list->elementSize);
|
||||
list->data = (uint8_t*) realloc(list->data, (size_t) newCapacity * elementSize);
|
||||
list->capacity = newCapacity;
|
||||
}
|
||||
|
||||
#define FF_LIST_FOR_EACH(itemType, itemVarName, listVar) \
|
||||
assert(sizeof(itemType) == (listVar).elementSize); \
|
||||
for (itemType* itemVarName = (itemType*) (listVar).data; \
|
||||
itemVarName - (itemType*) (listVar).data < (intptr_t) (listVar).length; \
|
||||
++itemVarName)
|
||||
|
||||
#define FF_LIST_AUTO_DESTROY FFlist FF_A_CLEANUP(ffListDestroy)
|
||||
|
||||
#define FF_LIST_GET(itemType, listVar, index) \
|
||||
({ \
|
||||
assert(sizeof(itemType) == (listVar).elementSize); \
|
||||
assert((listVar).capacity > (index)); \
|
||||
(itemType*) (listVar).data + (index); \
|
||||
#define FF_LIST_GET(itemType, listVar, index) \
|
||||
({ \
|
||||
assert((listVar).capacity > (index)); \
|
||||
(itemType*) (listVar).data + (index); \
|
||||
})
|
||||
|
||||
#define FF_LIST_ADD(itemType, listVar) \
|
||||
({ \
|
||||
assert(sizeof(itemType) == (listVar).elementSize); \
|
||||
(itemType*) ffListAdd(&(listVar)); \
|
||||
})
|
||||
#define FF_LIST_ADD(itemType, listVar) (itemType*) ffListAdd(&(listVar), (uint32_t) sizeof(itemType))
|
||||
|
||||
#define FF_LIST_FIRST(itemType, listVar) FF_LIST_GET(itemType, listVar, 0)
|
||||
#define FF_LIST_LAST(itemType, listVar) \
|
||||
@@ -130,3 +126,16 @@ static inline void ffListReserve(FFlist* list, uint32_t newCapacity) {
|
||||
assert((listVar).length > 0); \
|
||||
FF_LIST_GET(itemType, listVar, ((listVar).length - 1)); \
|
||||
})
|
||||
|
||||
#define FF_LIST_CONTAINS(listVar, pCompElement, compFunc) \
|
||||
({ \
|
||||
typedef __typeof__(*(pCompElement)) compElementType; \
|
||||
typedef bool compFuncType(const compElementType*, const compElementType*); \
|
||||
static_assert(__builtin_types_compatible_p(__typeof__(compFunc), compFuncType), "In compatible callback function"); \
|
||||
ffListContains(&(listVar), (uint32_t) sizeof(*(pCompElement)), (pCompElement), (bool (*)(const void*, const void*)) compFunc); \
|
||||
})
|
||||
|
||||
#define FF_LIST_SHIFT(listVar, pResult) \
|
||||
ffListShift(&(listVar), (uint32_t) sizeof(*(pResult)), (pResult))
|
||||
#define FF_LIST_POP(listVar, pResult) \
|
||||
ffListPop(&(listVar), (uint32_t) sizeof(*(pResult)), (pResult))
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
void ffPlatformInit(FFPlatform* platform) {
|
||||
ffStrbufInit(&platform->homeDir);
|
||||
ffStrbufInit(&platform->cacheDir);
|
||||
ffListInit(&platform->configDirs, sizeof(FFstrbuf));
|
||||
ffListInit(&platform->dataDirs, sizeof(FFstrbuf));
|
||||
ffListInit(&platform->configDirs);
|
||||
ffListInit(&platform->dataDirs);
|
||||
ffStrbufInit(&platform->exePath);
|
||||
ffStrbufInit(&platform->cwd);
|
||||
|
||||
@@ -77,8 +77,8 @@ void ffPlatformPathAddAbsolute(FFlist* dirs, const char* path) {
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreateS(path);
|
||||
ffStrbufEnsureEndsWithC(&buffer, '/');
|
||||
if (!ffListContains(dirs, &buffer, (void*) ffStrbufEqual)) {
|
||||
ffStrbufInitMove((FFstrbuf*) ffListAdd(dirs), &buffer);
|
||||
if (!FF_LIST_CONTAINS(*dirs, &buffer, ffStrbufEqual)) {
|
||||
ffStrbufInitMove(FF_LIST_ADD(FFstrbuf, *dirs), &buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ void ffPlatformPathAddHome(FFlist* dirs, const FFPlatform* platform, const char*
|
||||
ffStrbufAppend(&buffer, &platform->homeDir);
|
||||
ffStrbufAppendS(&buffer, suffix);
|
||||
ffStrbufEnsureEndsWithC(&buffer, '/');
|
||||
if (ffPathExists(buffer.chars, FF_PATHTYPE_DIRECTORY) && !ffListContains(dirs, &buffer, (void*) ffStrbufEqual)) {
|
||||
ffStrbufInitMove((FFstrbuf*) ffListAdd(dirs), &buffer);
|
||||
if (ffPathExists(buffer.chars, FF_PATHTYPE_DIRECTORY) && !FF_LIST_CONTAINS(*dirs, &buffer, ffStrbufEqual)) {
|
||||
ffStrbufInitMove(FF_LIST_ADD(FFstrbuf, *dirs), &buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,8 +77,8 @@ static void platformPathAddKnownFolder(FFlist* dirs, REFKNOWNFOLDERID folderId)
|
||||
CoTaskMemFree(pPath);
|
||||
ffStrbufReplaceAllC(&buffer, '\\', '/');
|
||||
ffStrbufEnsureEndsWithC(&buffer, '/');
|
||||
if (!ffListContains(dirs, &buffer, (void*) ffStrbufEqual)) {
|
||||
ffStrbufInitMove((FFstrbuf*) ffListAdd(dirs), &buffer);
|
||||
if (!FF_LIST_CONTAINS(*dirs, &buffer, ffStrbufEqual)) {
|
||||
ffStrbufInitMove(FF_LIST_ADD(FFstrbuf, *dirs), &buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,8 +98,8 @@ static void platformPathAddEnvSuffix(FFlist* dirs, const char* env, const char*
|
||||
ffStrbufEnsureEndsWithC(&buffer, '/');
|
||||
}
|
||||
|
||||
if (ffPathExists(buffer.chars, FF_PATHTYPE_DIRECTORY) && !ffListContains(dirs, &buffer, (void*) ffStrbufEqual)) {
|
||||
ffStrbufInitMove((FFstrbuf*) ffListAdd(dirs), &buffer);
|
||||
if (ffPathExists(buffer.chars, FF_PATHTYPE_DIRECTORY) && !FF_LIST_CONTAINS(*dirs, &buffer, ffStrbufEqual)) {
|
||||
ffStrbufInitMove(FF_LIST_ADD(FFstrbuf, *dirs), &buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,32 +3,32 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
void* ffListAdd(FFlist* list) {
|
||||
void* ffListAdd(FFlist* list, uint32_t elementSize) {
|
||||
if (list->length == list->capacity) {
|
||||
ffListReserve(list, list->capacity == 0 ? FF_LIST_DEFAULT_ALLOC : list->capacity * 2);
|
||||
ffListReserve(list, elementSize, list->capacity == 0 ? FF_LIST_DEFAULT_ALLOC : list->capacity * 2);
|
||||
}
|
||||
|
||||
++list->length;
|
||||
return ffListGet(list, list->length - 1);
|
||||
return ffListGet(list, elementSize, list->length - 1);
|
||||
}
|
||||
|
||||
bool ffListShift(FFlist* list, void* result) {
|
||||
bool ffListShift(FFlist* list, uint32_t elementSize, void* result) {
|
||||
if (list->length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(result, list->data, list->elementSize);
|
||||
memmove(list->data, list->data + list->elementSize, (size_t) list->elementSize * (list->length - 1));
|
||||
memcpy(result, list->data, elementSize);
|
||||
memmove(list->data, list->data + elementSize, (size_t) elementSize * (list->length - 1));
|
||||
--list->length;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ffListPop(FFlist* list, void* result) {
|
||||
bool ffListPop(FFlist* list, uint32_t elementSize, void* result) {
|
||||
if (list->length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(result, ffListGet(list, list->length - 1), list->elementSize);
|
||||
memcpy(result, ffListGet(list, elementSize, list->length - 1), elementSize);
|
||||
--list->length;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ void ffFontInit(FFfont* font) {
|
||||
ffStrbufInit(&font->pretty);
|
||||
ffStrbufInit(&font->name);
|
||||
ffStrbufInit(&font->size);
|
||||
ffListInit(&font->styles, sizeof(FFstrbuf));
|
||||
ffListInit(&font->styles);
|
||||
}
|
||||
|
||||
static void strbufAppendNSExcludingC(FFstrbuf* strbuf, uint32_t length, const char* value, char exclude) {
|
||||
@@ -93,7 +93,7 @@ void ffFontInitQt(FFfont* font, const char* data) {
|
||||
data++;
|
||||
if (isalpha(*data)) {
|
||||
do {
|
||||
FFstrbuf* style = (FFstrbuf*) ffListAdd(&font->styles);
|
||||
FFstrbuf* style = FF_LIST_ADD(FFstrbuf, font->styles);
|
||||
ffStrbufInit(style);
|
||||
data = ffStrbufAppendSUntilC(style, data, ' ');
|
||||
if (data) {
|
||||
@@ -152,7 +152,7 @@ static void fontPangoParseWord(const char** data, FFfont* font, FFstrbuf* altern
|
||||
ffStrStartsWithIgnCase(wordStart, "Condensed") ||
|
||||
ffStrStartsWithIgnCase(wordStart, "Expanded")) {
|
||||
if (alternativeBuffer == NULL) {
|
||||
alternativeBuffer = (FFstrbuf*) ffListAdd(&font->styles);
|
||||
alternativeBuffer = FF_LIST_ADD(FFstrbuf, font->styles);
|
||||
ffStrbufInit(alternativeBuffer);
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ void ffFontInitXlfd(FFfont* font, const char* xlfd) {
|
||||
{
|
||||
// ignore "normal" (case-insensitive)
|
||||
if (!(length == 6 && ffStrStartsWithIgnCase(pstart, "normal"))) {
|
||||
FFstrbuf* style = (FFstrbuf*) ffListAdd(&font->styles);
|
||||
FFstrbuf* style = FF_LIST_ADD(FFstrbuf, font->styles);
|
||||
ffStrbufInitNS(style, length, pstart);
|
||||
}
|
||||
}
|
||||
|
||||
+11
-12
@@ -232,18 +232,17 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() {
|
||||
if (!ffAppendFileBuffer("/sys/firmware/dmi/tables/DMI", &buffer))
|
||||
# elif defined(__OpenBSD__)
|
||||
{
|
||||
FF_DEBUG("Using OpenBSD /var/run/dmesg.boot implementation");
|
||||
char dmesg[8192];
|
||||
ssize_t size = ffReadFileData("/var/run/dmesg.boot", sizeof(dmesg), dmesg);
|
||||
if (size <= 0) {
|
||||
goto fallback;
|
||||
}
|
||||
char* line = memmem(dmesg, sizeof(dmesg), "\nbios0 at mainbios0: SMBIOS rev. ", strlen("\nbios0 at mainbios0: SMBIOS rev. "));
|
||||
if (!line) {
|
||||
goto fallback;
|
||||
}
|
||||
line += strlen("\nbios0 at mainbios0: SMBIOS rev. ");
|
||||
|
||||
FF_DEBUG("Using OpenBSD /var/run/dmesg.boot implementation");
|
||||
char dmesg[8192];
|
||||
ssize_t size = ffReadFileData("/var/run/dmesg.boot", sizeof(dmesg), dmesg);
|
||||
if (size <= 0) {
|
||||
goto fallback;
|
||||
}
|
||||
char* line = memmem(dmesg, sizeof(dmesg), "\nbios0 at mainbios0: SMBIOS rev. ", strlen("\nbios0 at mainbios0: SMBIOS rev. "));
|
||||
if (!line) {
|
||||
goto fallback;
|
||||
}
|
||||
line += strlen("\nbios0 at mainbios0: SMBIOS rev. ");
|
||||
}
|
||||
# endif
|
||||
{
|
||||
|
||||
@@ -178,14 +178,6 @@ static bool processRegValue(const FFRegValueArg* arg, const ULONG regType, const
|
||||
}
|
||||
|
||||
FFlist* list = (FFlist*) arg->value;
|
||||
if (list->elementSize != sizeof(FFstrbuf)) {
|
||||
if (error) {
|
||||
FF_STRBUF_AUTO_DESTROY nameA = arg->name ? ffStrbufCreateWS(arg->name) : ffStrbufCreateStatic("(default)");
|
||||
ffStrbufAppendF(error, "ffRegReadValues(%s) type mismatch: expected list of strbuf for REG_MULTI_SZ", nameA.chars);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ffListClear(list);
|
||||
|
||||
for (
|
||||
|
||||
@@ -31,7 +31,7 @@ static const char* parseTermuxApi(FFBatteryOptions* options, FFlist* results) {
|
||||
return "Battery info result is not a JSON object";
|
||||
}
|
||||
|
||||
FFBatteryResult* battery = ffListAdd(results);
|
||||
FFBatteryResult* battery = FF_LIST_ADD(FFBatteryResult, *results);
|
||||
battery->temperature = FF_BATTERY_TEMP_UNSET;
|
||||
battery->cycleCount = 0;
|
||||
battery->timeRemaining = -1;
|
||||
@@ -92,7 +92,7 @@ static const char* parseDumpsys(FFBatteryOptions* options, FFlist* results) {
|
||||
}
|
||||
ffStrbufClear(&temp);
|
||||
|
||||
FFBatteryResult* battery = ffListAdd(results);
|
||||
FFBatteryResult* battery = FF_LIST_ADD(FFBatteryResult, *results);
|
||||
battery->temperature = FF_BATTERY_TEMP_UNSET;
|
||||
battery->cycleCount = 0;
|
||||
battery->timeRemaining = -1;
|
||||
|
||||
@@ -32,7 +32,7 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) {
|
||||
|
||||
bool boolValue;
|
||||
|
||||
FFBatteryResult* battery = ffListAdd(results);
|
||||
FFBatteryResult* battery = FF_LIST_ADD(FFBatteryResult, *results);
|
||||
battery->temperature = FF_BATTERY_TEMP_UNSET;
|
||||
ffStrbufInit(&battery->manufacturer);
|
||||
ffStrbufInit(&battery->modelName);
|
||||
|
||||
@@ -34,7 +34,7 @@ const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* resul
|
||||
continue;
|
||||
}
|
||||
|
||||
FFBatteryResult* battery = ffListAdd(results);
|
||||
FFBatteryResult* battery = FF_LIST_ADD(FFBatteryResult, *results);
|
||||
battery->temperature = FF_BATTERY_TEMP_UNSET;
|
||||
battery->cycleCount = 0;
|
||||
ffStrbufInit(&battery->manufacturer);
|
||||
|
||||
@@ -25,7 +25,7 @@ const char* parseBattery(int dfd, const char* battId, FFlist* results) {
|
||||
return "Skipped";
|
||||
}
|
||||
|
||||
FFBatteryResult* battery = (FFBatteryResult*) ffListAdd(results);
|
||||
FFBatteryResult* battery = FF_LIST_ADD(FFBatteryResult, *results);
|
||||
ffStrbufInitS(&battery->modelName, extended.model_number);
|
||||
ffStrbufInitS(&battery->manufacturer, extended.oem_info);
|
||||
ffStrbufInit(&battery->manufactureDate);
|
||||
|
||||
@@ -60,7 +60,7 @@ static bool parseBattery(int dfd, const char* id, FFBatteryOptions* options, FFl
|
||||
return false;
|
||||
}
|
||||
|
||||
FFBatteryResult* result = ffListAdd(results);
|
||||
FFBatteryResult* result = FF_LIST_ADD(FFBatteryResult, *results);
|
||||
ffStrbufInit(&result->manufacturer);
|
||||
ffStrbufInit(&result->modelName);
|
||||
ffStrbufInit(&result->technology);
|
||||
|
||||
@@ -74,7 +74,7 @@ const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* resul
|
||||
}
|
||||
|
||||
if (max > 0) {
|
||||
FFBatteryResult* battery = ffListAdd(results);
|
||||
FFBatteryResult* battery = FF_LIST_ADD(FFBatteryResult, *results);
|
||||
battery->temperature = FF_BATTERY_TEMP_UNSET;
|
||||
battery->cycleCount = 0;
|
||||
ffStrbufInit(&battery->manufacturer);
|
||||
|
||||
@@ -23,7 +23,7 @@ const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* resul
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FFBatteryResult* battery = (FFBatteryResult*) ffListAdd(result);
|
||||
FFBatteryResult* battery = FF_LIST_ADD(FFBatteryResult, *result);
|
||||
battery->temperature = FF_BATTERY_TEMP_UNSET;
|
||||
battery->cycleCount = 0;
|
||||
battery->timeRemaining = -1;
|
||||
|
||||
@@ -63,7 +63,7 @@ static const char* detectWithCmApi(FFBatteryOptions* options, FFlist* results) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFBatteryResult* battery = (FFBatteryResult*) ffListAdd(results);
|
||||
FFBatteryResult* battery = FF_LIST_ADD(FFBatteryResult, *results);
|
||||
|
||||
if (memcmp(bi.Chemistry, "PbAc", 4) == 0) {
|
||||
ffStrbufInitStatic(&battery->technology, "Lead Acid");
|
||||
@@ -259,7 +259,7 @@ static const char* detectWithNtApi(FF_A_UNUSED FFBatteryOptions* options, FFlist
|
||||
SYSTEM_BATTERY_STATE info;
|
||||
if (NT_SUCCESS(NtPowerInformation(SystemBatteryState, NULL, 0, &info, sizeof(info))) &&
|
||||
info.BatteryPresent) {
|
||||
FFBatteryResult* battery = (FFBatteryResult*) ffListAdd(results);
|
||||
FFBatteryResult* battery = FF_LIST_ADD(FFBatteryResult, *results);
|
||||
ffStrbufInit(&battery->modelName);
|
||||
ffStrbufInit(&battery->manufacturer);
|
||||
ffStrbufInit(&battery->manufactureDate);
|
||||
|
||||
@@ -21,7 +21,7 @@ const char* ffDetectBluetooth(FFBluetoothOptions* options, FFlist* devices /* FF
|
||||
if (!options->showDisconnected && !ioDevice.isConnected)
|
||||
continue;
|
||||
|
||||
FFBluetoothResult* device = ffListAdd(devices);
|
||||
FFBluetoothResult* device = FF_LIST_ADD(FFBluetoothResult, *devices);
|
||||
ffStrbufInitS(&device->name, ioDevice.name.UTF8String);
|
||||
ffStrbufInitS(&device->address, ioDevice.addressString.UTF8String);
|
||||
ffStrbufReplaceAllC(&device->address, '-', ':');
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <bluetooth.h>
|
||||
|
||||
static int enumDev(FF_A_UNUSED int sockfd, struct bt_devinfo const* dev, FFlist* devices) {
|
||||
FFBluetoothResult* device = ffListAdd(devices);
|
||||
FFBluetoothResult* device = FF_LIST_ADD(FFBluetoothResult, *devices);
|
||||
ffStrbufInitS(&device->name,
|
||||
#if __FreeBSD__
|
||||
bt_devremote_name_gen(dev->devname, &dev->bdaddr)
|
||||
|
||||
@@ -17,7 +17,7 @@ const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FFlist* d
|
||||
BString devClass;
|
||||
dev->GetDeviceClass().DumpDeviceClass(devClass);
|
||||
|
||||
FFBluetoothResult* device = (FFBluetoothResult*) ffListAdd(devices);
|
||||
FFBluetoothResult* device = FF_LIST_ADD(FFBluetoothResult, *devices);
|
||||
ffStrbufInitS(&device->name, dev->GetFriendlyName());
|
||||
ffStrbufInitS(&device->address, bdaddrUtils::ToString(dev->GetBluetoothAddress()).String());
|
||||
ffStrbufInitS(&device->type, devClass.String());
|
||||
|
||||
@@ -151,7 +151,7 @@ static FFBluetoothResult* detectBluetoothObject(FFlist* devices, FFDBusData* dbu
|
||||
DBusMessageIter arrayIter;
|
||||
dbus->lib->ffdbus_message_iter_recurse(&dictIter, &arrayIter);
|
||||
|
||||
FFBluetoothResult* device = ffListAdd(devices);
|
||||
FFBluetoothResult* device = FF_LIST_ADD(FFBluetoothResult, *devices);
|
||||
ffStrbufInit(&device->name);
|
||||
ffStrbufInit(&device->address);
|
||||
ffStrbufInit(&device->type);
|
||||
@@ -165,7 +165,7 @@ static FFBluetoothResult* detectBluetoothObject(FFlist* devices, FFDBusData* dbu
|
||||
return device;
|
||||
}
|
||||
|
||||
static void detectBluetoothRoot(FFlist* devices, FFDBusData* dbus, DBusMessageIter* iter, int32_t connectedCount) {
|
||||
static void detectBluetoothRoot(FFBluetoothOptions* options, FFlist* devices, FFDBusData* dbus, DBusMessageIter* iter, int32_t connectedCount) {
|
||||
if (dbus->lib->ffdbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY) {
|
||||
return;
|
||||
}
|
||||
@@ -177,13 +177,17 @@ static void detectBluetoothRoot(FFlist* devices, FFDBusData* dbus, DBusMessageIt
|
||||
FFBluetoothResult* device = detectBluetoothObject(devices, dbus, &arrayIter);
|
||||
|
||||
if (device) {
|
||||
if (device->name.length == 0 || (connectedCount > 0 && !device->connected)) {
|
||||
if (!options->showDisconnected && !device->connected) {
|
||||
ffStrbufDestroy(&device->name);
|
||||
ffStrbufDestroy(&device->address);
|
||||
ffStrbufDestroy(&device->type);
|
||||
--devices->length;
|
||||
}
|
||||
|
||||
if (device->name.length == 0) {
|
||||
ffStrbufSetStatic(&device->name, "Unknown Device");
|
||||
}
|
||||
|
||||
if (device->connected && --connectedCount == 0) {
|
||||
break;
|
||||
}
|
||||
@@ -191,7 +195,7 @@ static void detectBluetoothRoot(FFlist* devices, FFDBusData* dbus, DBusMessageIt
|
||||
} while (dbus->lib->ffdbus_message_iter_next(&arrayIter));
|
||||
}
|
||||
|
||||
static const char* detectBluetooth(FFlist* devices, int32_t connectedCount) {
|
||||
static const char* detectBluetooth(FFBluetoothOptions* options, FFlist* devices, int32_t connectedCount) {
|
||||
FF_DBUS_AUTO_DESTROY_DATA FFDBusData dbus = {};
|
||||
const char* error = ffDBusLoadData(DBUS_BUS_SYSTEM, &dbus);
|
||||
if (error) {
|
||||
@@ -209,7 +213,7 @@ static const char* detectBluetooth(FFlist* devices, int32_t connectedCount) {
|
||||
return "Failed to get root iterator of GetManagedObjects";
|
||||
}
|
||||
|
||||
detectBluetoothRoot(devices, &dbus, &rootIter, connectedCount);
|
||||
detectBluetoothRoot(options, devices, &dbus, &rootIter, connectedCount);
|
||||
|
||||
dbus.lib->ffdbus_message_unref(managedObjects);
|
||||
return NULL;
|
||||
@@ -234,7 +238,7 @@ static uint32_t connectedDevices(void) {
|
||||
|
||||
#endif
|
||||
|
||||
const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FF_A_UNUSED FFlist* devices /* FFBluetoothResult */) {
|
||||
const char* ffDetectBluetooth(FFBluetoothOptions* options, FFlist* devices /* FFBluetoothResult */) {
|
||||
#ifdef FF_HAVE_DBUS
|
||||
int32_t connectedCount = -1;
|
||||
if (!options->showDisconnected) {
|
||||
@@ -244,8 +248,9 @@ const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FF_A_UNUS
|
||||
}
|
||||
}
|
||||
|
||||
return detectBluetooth(devices, connectedCount);
|
||||
return detectBluetooth(options, devices, connectedCount);
|
||||
#else
|
||||
FF_UNUSED(options, devices);
|
||||
return "Fastfetch was compiled without DBus support";
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -30,7 +30,11 @@ const char* ffDetectBluetooth(FFBluetoothOptions* options, FFlist* devices /* FF
|
||||
}
|
||||
|
||||
do {
|
||||
FFBluetoothResult* device = ffListAdd(devices);
|
||||
if (!options->showDisconnected && !btdi.fConnected) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFBluetoothResult* device = FF_LIST_ADD(FFBluetoothResult, *devices);
|
||||
ffStrbufInitWS(&device->name, btdi.szName);
|
||||
ffStrbufInitF(&device->address, "%02X:%02X:%02X:%02X:%02X:%02X", btdi.Address.rgBytes[5], btdi.Address.rgBytes[4], btdi.Address.rgBytes[3], btdi.Address.rgBytes[2], btdi.Address.rgBytes[1], btdi.Address.rgBytes[0]);
|
||||
ffStrbufInit(&device->type);
|
||||
|
||||
@@ -34,7 +34,7 @@ const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothRadioResult */)
|
||||
|
||||
for (IOBluetoothHostController* ctrl in ctrls)
|
||||
{
|
||||
FFBluetoothRadioResult* device = ffListAdd(devices);
|
||||
FFBluetoothRadioResult* device = FF_LIST_ADD(FFBluetoothRadioResult, *devices);
|
||||
ffStrbufInitS(&device->name, ctrl.nameAsString.UTF8String);
|
||||
ffStrbufInitS(&device->address, ctrl.addressAsString.UTF8String);
|
||||
ffStrbufInitStatic(&device->vendor, "Apple");
|
||||
|
||||
@@ -126,7 +126,7 @@ static const char* detectBluetooth(FFlist* devices) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFBluetoothRadioResult* device = ffListAdd(devices);
|
||||
FFBluetoothRadioResult* device = FF_LIST_ADD(FFBluetoothRadioResult, *devices);
|
||||
ffStrbufInit(&device->name);
|
||||
ffStrbufInit(&device->address);
|
||||
ffStrbufInitStatic(&device->vendor, "Unknown");
|
||||
|
||||
@@ -77,7 +77,7 @@ const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothRadioResult */)
|
||||
continue;
|
||||
}
|
||||
|
||||
FFBluetoothRadioResult* device = ffListAdd(devices);
|
||||
FFBluetoothRadioResult* device = FF_LIST_ADD(FFBluetoothRadioResult, *devices);
|
||||
ffStrbufInitS(&device->name, blri.localInfo.name);
|
||||
|
||||
BLUETOOTH_ADDRESS_STRUCT addr = { .ullLong = blri.localInfo.address };
|
||||
|
||||
@@ -34,7 +34,7 @@ static const char* detectWithDisplayServices(const FFDisplayServerResult* displa
|
||||
if (display->type == FF_DISPLAY_TYPE_BUILTIN || display->type == FF_DISPLAY_TYPE_UNKNOWN) {
|
||||
float value;
|
||||
if (DisplayServicesGetBrightness((CGDirectDisplayID) display->id, &value) == kCGErrorSuccess) {
|
||||
FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result);
|
||||
FFBrightnessResult* brightness = FF_LIST_ADD(FFBrightnessResult, *result);
|
||||
brightness->current = value;
|
||||
brightness->max = 1;
|
||||
brightness->min = 0;
|
||||
@@ -103,7 +103,7 @@ static const char* detectWithDdcci(FF_A_UNUSED const FFDisplayServerResult* disp
|
||||
uint32_t current = ((uint32_t) i2cOut[8] << 8u) + (uint32_t) i2cOut[9];
|
||||
uint32_t max = ((uint32_t) i2cOut[6] << 8u) + (uint32_t) i2cOut[7];
|
||||
|
||||
FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result);
|
||||
FFBrightnessResult* brightness = FF_LIST_ADD(FFBrightnessResult, *result);
|
||||
brightness->max = max;
|
||||
brightness->min = 0;
|
||||
brightness->current = current;
|
||||
@@ -214,7 +214,7 @@ static const char* detectWithDdcci(const FFDisplayServerResult* displayServer, F
|
||||
uint32_t current = ((uint32_t) i2cOut[8] << 8u) + (uint32_t) i2cOut[9];
|
||||
uint32_t max = ((uint32_t) i2cOut[6] << 8u) + (uint32_t) i2cOut[7];
|
||||
|
||||
FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result);
|
||||
FFBrightnessResult* brightness = FF_LIST_ADD(FFBrightnessResult, *result);
|
||||
brightness->max = max;
|
||||
brightness->min = 0;
|
||||
brightness->current = current;
|
||||
|
||||
@@ -26,7 +26,7 @@ const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist*
|
||||
continue;
|
||||
}
|
||||
|
||||
FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result);
|
||||
FFBrightnessResult* brightness = FF_LIST_ADD(FFBrightnessResult, *result);
|
||||
ffStrbufInit(&brightness->name);
|
||||
|
||||
brightness->max = BACKLIGHTMAXLEVELS;
|
||||
|
||||
@@ -36,7 +36,7 @@ static const char* detectWithBacklight(FFlist* result) {
|
||||
ffStrbufAppendS(&backlightDir, entry->d_name);
|
||||
ffStrbufAppendS(&backlightDir, "/max_brightness");
|
||||
if (ffReadFileBuffer(backlightDir.chars, &buffer)) {
|
||||
FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result);
|
||||
FFBrightnessResult* brightness = FF_LIST_ADD(FFBrightnessResult, *result);
|
||||
ffStrbufSubstrBeforeLastC(&backlightDir, '/');
|
||||
ffStrbufAppendS(&backlightDir, "/device");
|
||||
ffStrbufInitA(&brightness->name, PATH_MAX);
|
||||
@@ -146,7 +146,7 @@ static const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFl
|
||||
int current = VALREC_CUR_VAL(vcpValue), max = VALREC_MAX_VAL(vcpValue);
|
||||
ffddca_free_any_vcp_value(vcpValue);
|
||||
|
||||
FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result);
|
||||
FFBrightnessResult* brightness = FF_LIST_ADD(FFBrightnessResult, *result);
|
||||
brightness->max = max;
|
||||
brightness->min = 0;
|
||||
brightness->current = current;
|
||||
|
||||
@@ -14,7 +14,7 @@ const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist*
|
||||
continue;
|
||||
}
|
||||
|
||||
FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result);
|
||||
FFBrightnessResult* brightness = FF_LIST_ADD(FFBrightnessResult, *result);
|
||||
ffStrbufInitF(&brightness->name, "acpiout%d", i);
|
||||
|
||||
brightness->max = 100;
|
||||
|
||||
@@ -31,7 +31,7 @@ const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist*
|
||||
continue;
|
||||
}
|
||||
|
||||
FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result);
|
||||
FFBrightnessResult* brightness = FF_LIST_ADD(FFBrightnessResult, *result);
|
||||
ffStrbufInitF(&brightness->name, "ttyC%c", i);
|
||||
|
||||
brightness->max = param.max;
|
||||
|
||||
@@ -43,7 +43,7 @@ static const char* detectWithWmi(FFlist* result) {
|
||||
|
||||
while (FFWmiRecord record = query.next()) {
|
||||
if (FFWmiVariant vtValue = record.get(L"CurrentBrightness")) {
|
||||
FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result);
|
||||
FFBrightnessResult* brightness = FF_LIST_ADD(FFBrightnessResult, *result);
|
||||
brightness->max = 100;
|
||||
brightness->min = 0;
|
||||
brightness->current = vtValue.get<uint8_t>();
|
||||
@@ -90,7 +90,7 @@ static const char* detectWithDdcci(const FFDisplayServerResult* displayServer, F
|
||||
if (NT_SUCCESS(ffGetPhysicalMonitors(&deviceName, 1, &monitorCount, &physicalMonitor)) && monitorCount >= 1) {
|
||||
DWORD curr = 0, max = 0;
|
||||
if (NT_SUCCESS(ffDDCCIGetVCPFeature(physicalMonitor, 0x10 /* luminance */, NULL, &curr, &max))) {
|
||||
FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result);
|
||||
FFBrightnessResult* brightness = FF_LIST_ADD(FFBrightnessResult, *result);
|
||||
if (display->name.length > 0) {
|
||||
ffStrbufInitCopy(&brightness->name, &display->name);
|
||||
} else {
|
||||
|
||||
@@ -138,7 +138,7 @@ const char* ffDetectBtrfs(FFlist* result) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFBtrfsResult* item = ffListAdd(result);
|
||||
FFBtrfsResult* item = FF_LIST_ADD(FFBtrfsResult, *result);
|
||||
(*item) = (FFBtrfsResult) {
|
||||
.uuid = ffStrbufCreateNS(uuidLen, entry->d_name),
|
||||
.name = ffStrbufCreate(),
|
||||
|
||||
@@ -33,7 +33,7 @@ const char* ffDetectCamera(FF_A_UNUSED FFlist* result) {
|
||||
yyjson_val* device;
|
||||
size_t idx, max;
|
||||
yyjson_arr_foreach (root, idx, max, device) {
|
||||
FFCameraResult* camera = (FFCameraResult*) ffListAdd(result);
|
||||
FFCameraResult* camera = FF_LIST_ADD(FFCameraResult, *result);
|
||||
{
|
||||
const char* facing = yyjson_get_str(yyjson_obj_get(device, "facing"));
|
||||
if (facing) {
|
||||
|
||||
@@ -37,7 +37,7 @@ const char* ffDetectCamera(FFlist* result)
|
||||
|
||||
for (AVCaptureDevice* device in session.devices)
|
||||
{
|
||||
FFCameraResult* camera = (FFCameraResult*) ffListAdd(result);
|
||||
FFCameraResult* camera = FF_LIST_ADD(FFCameraResult, *result);
|
||||
ffStrbufInitS(&camera->name, device.localizedName.UTF8String);
|
||||
ffStrbufInitS(&camera->vendor, device.manufacturer.UTF8String);
|
||||
ffStrbufInitS(&camera->id, device.uniqueID.UTF8String);
|
||||
|
||||
@@ -39,7 +39,7 @@ const char* ffDetectCamera(FFlist* result) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFCameraResult* camera = (FFCameraResult*) ffListAdd(result);
|
||||
FFCameraResult* camera = FF_LIST_ADD(FFCameraResult, *result);
|
||||
ffStrbufInitS(&camera->name, (const char*) cap.card);
|
||||
ffStrbufInit(&camera->vendor);
|
||||
ffStrbufInitS(&camera->id, (const char*) cap.bus_info);
|
||||
|
||||
@@ -48,7 +48,7 @@ extern "C" const char* ffDetectCamera(FF_A_UNUSED FFlist* result) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFCameraResult* camera = (FFCameraResult*) ffListAdd(result);
|
||||
FFCameraResult* camera = FF_LIST_ADD(FFCameraResult, *result);
|
||||
ffStrbufInitNWS(&camera->name, length, buffer);
|
||||
ffStrbufInit(&camera->colorspace);
|
||||
ffStrbufInit(&camera->vendor);
|
||||
|
||||
@@ -8,9 +8,7 @@ typedef struct FFCommandResultBundle {
|
||||
} FFCommandResultBundle;
|
||||
|
||||
// FIFO, non-thread-safe list of running commands
|
||||
static FFlist commandQueue = {
|
||||
.elementSize = sizeof(FFCommandResultBundle),
|
||||
};
|
||||
static FFlist commandQueue;
|
||||
|
||||
static const char* spawnProcess(FFCommandOptions* options, FFProcessHandle* handle) {
|
||||
if (options->text.length == 0) {
|
||||
@@ -32,7 +30,7 @@ bool ffPrepareCommand(FFCommandOptions* options) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FFCommandResultBundle* bundle = ffListAdd(&commandQueue);
|
||||
FFCommandResultBundle* bundle = FF_LIST_ADD(FFCommandResultBundle, commandQueue);
|
||||
bundle->error = spawnProcess(options, &bundle->handle);
|
||||
|
||||
return true;
|
||||
@@ -42,7 +40,7 @@ const char* ffDetectCommand(FFCommandOptions* options, FFstrbuf* result) {
|
||||
FFCommandResultBundle bundle = {};
|
||||
if (!options->parallel) {
|
||||
bundle.error = spawnProcess(options, &bundle.handle);
|
||||
} else if (!ffListShift(&commandQueue, &bundle)) {
|
||||
} else if (!FF_LIST_SHIFT(commandQueue, &bundle)) {
|
||||
return "[BUG] command queue is empty";
|
||||
}
|
||||
|
||||
|
||||
@@ -776,7 +776,7 @@ static const char* detectPhysicalCores(FFCPUResult* cpu) {
|
||||
uint64_t pkgLow = 0, pkgHigh = 0;
|
||||
|
||||
struct dirent* entry;
|
||||
FF_LIST_AUTO_DESTROY cpuList = ffListCreate(sizeof(uint32_t));
|
||||
FF_LIST_AUTO_DESTROY cpuList = ffListCreate();
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
if (entry->d_type != DT_DIR || !ffStrStartsWith(entry->d_name, "cpu") || !ffCharIsDigit(entry->d_name[strlen("cpu")])) {
|
||||
continue;
|
||||
@@ -826,7 +826,7 @@ static const char* detectPhysicalCores(FFCPUResult* cpu) {
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
*(uint32_t*) ffListAdd(&cpuList) = coreId;
|
||||
*FF_LIST_ADD(uint32_t, cpuList) = coreId;
|
||||
}
|
||||
|
||||
p = strchr(pend, ',');
|
||||
|
||||
@@ -33,7 +33,7 @@ static inline FFCPUCache* ffCPUCacheAddItem(FFCPUCacheResult* result, uint32_t l
|
||||
}
|
||||
}
|
||||
|
||||
FFCPUCache* item = (FFCPUCache*) ffListAdd(cacheLevel);
|
||||
FFCPUCache* item = FF_LIST_ADD(FFCPUCache, *cacheLevel);
|
||||
*item = (FFCPUCache) {
|
||||
.size = size,
|
||||
.num = 1,
|
||||
|
||||
@@ -8,19 +8,19 @@ static FFlist cpuTimes1;
|
||||
static uint64_t startTime;
|
||||
|
||||
void ffPrepareCPUUsage(void) {
|
||||
if (cpuTimes1.elementSize != 0) {
|
||||
if (startTime != 0) {
|
||||
return; // Already prepared
|
||||
}
|
||||
|
||||
ffListInit(&cpuTimes1, sizeof(FFCpuUsageInfo));
|
||||
ffListInit(&cpuTimes1);
|
||||
ffGetCpuUsageInfo(&cpuTimes1);
|
||||
startTime = ffTimeGetNow();
|
||||
}
|
||||
|
||||
const char* ffGetCpuUsageResult(FFCPUUsageOptions* options, FFlist* result) {
|
||||
const char* error = NULL;
|
||||
if (cpuTimes1.elementSize == 0) {
|
||||
ffListInit(&cpuTimes1, sizeof(FFCpuUsageInfo));
|
||||
if (startTime == 0) {
|
||||
ffListInit(&cpuTimes1);
|
||||
error = ffGetCpuUsageInfo(&cpuTimes1);
|
||||
if (error) {
|
||||
return error;
|
||||
@@ -37,7 +37,7 @@ const char* ffGetCpuUsageResult(FFCPUUsageOptions* options, FFlist* result) {
|
||||
return "No CPU cores found";
|
||||
}
|
||||
|
||||
FF_LIST_AUTO_DESTROY cpuTimes2 = ffListCreate(sizeof(FFCpuUsageInfo));
|
||||
FF_LIST_AUTO_DESTROY cpuTimes2 = ffListCreate();
|
||||
uint32_t retryCount = 0;
|
||||
|
||||
retry:
|
||||
@@ -65,7 +65,7 @@ retry:
|
||||
for (uint32_t i = 0; i < cpuTimes1.length; ++i) {
|
||||
FFCpuUsageInfo* cpuTime1 = FF_LIST_GET(FFCpuUsageInfo, cpuTimes1, i);
|
||||
FFCpuUsageInfo* cpuTime2 = FF_LIST_GET(FFCpuUsageInfo, cpuTimes2, i);
|
||||
*(double*) ffListAdd(result) = (double) (cpuTime2->inUseAll - cpuTime1->inUseAll) / (double) (cpuTime2->totalAll - cpuTime1->totalAll) * 100;
|
||||
*FF_LIST_ADD(double, *result) = (double) (cpuTime2->inUseAll - cpuTime1->inUseAll) / (double) (cpuTime2->totalAll - cpuTime1->totalAll) * 100;
|
||||
cpuTime1->inUseAll = cpuTime2->inUseAll;
|
||||
cpuTime1->totalAll = cpuTime2->totalAll;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
integer_t inUse = cpuInfo[CPU_STATE_MAX * i + CPU_STATE_USER] + cpuInfo[CPU_STATE_MAX * i + CPU_STATE_SYSTEM] + cpuInfo[CPU_STATE_MAX * i + CPU_STATE_NICE];
|
||||
integer_t total = inUse + cpuInfo[CPU_STATE_MAX * i + CPU_STATE_IDLE];
|
||||
|
||||
FFCpuUsageInfo* info = (FFCpuUsageInfo*) ffListAdd(cpuTimes);
|
||||
FFCpuUsageInfo* info = FF_LIST_ADD(FFCpuUsageInfo, *cpuTimes);
|
||||
*info = (FFCpuUsageInfo) {
|
||||
.inUseAll = (uint64_t) inUse,
|
||||
.totalAll = (uint64_t) total,
|
||||
|
||||
@@ -47,7 +47,7 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
uint64_t inUse = cpTime[CP_USER] + cpTime[CP_NICE] + cpTime[CP_SYS] + cpTime[CP_INTR];
|
||||
uint64_t total = inUse + cpTime[CP_IDLE];
|
||||
|
||||
FFCpuUsageInfo* info = (FFCpuUsageInfo*) ffListAdd(cpuTimes);
|
||||
FFCpuUsageInfo* info = FF_LIST_ADD(FFCpuUsageInfo, *cpuTimes);
|
||||
*info = (FFCpuUsageInfo) {
|
||||
.inUseAll = inUse,
|
||||
.totalAll = total,
|
||||
|
||||
@@ -18,7 +18,7 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
uint64_t uptime = (uint64_t) system_time();
|
||||
|
||||
for (uint32_t i = 0; i < sysInfo.cpu_count; ++i) {
|
||||
FFCpuUsageInfo* info = (FFCpuUsageInfo*) ffListAdd(cpuTimes);
|
||||
FFCpuUsageInfo* info = FF_LIST_ADD(FFCpuUsageInfo, *cpuTimes);
|
||||
info->inUseAll = (uint64_t) cpuInfo[i].active_time;
|
||||
info->totalAll = uptime;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
uint64_t inUse = user + nice + system + irq + softirq;
|
||||
uint64_t total = inUse + idle + iowait;
|
||||
|
||||
FFCpuUsageInfo* info = (FFCpuUsageInfo*) ffListAdd(cpuTimes);
|
||||
FFCpuUsageInfo* info = FF_LIST_ADD(FFCpuUsageInfo, *cpuTimes);
|
||||
*info = (FFCpuUsageInfo) {
|
||||
.inUseAll = inUse,
|
||||
.totalAll = total,
|
||||
|
||||
@@ -28,7 +28,7 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
uint64_t inUse = cs.cpu_sysinfo.cpu[CPU_USER] + cs.cpu_sysinfo.cpu[CPU_KERNEL];
|
||||
uint64_t total = inUse + cs.cpu_sysinfo.cpu[CPU_IDLE] + cs.cpu_sysinfo.cpu[CPU_WAIT];
|
||||
|
||||
FFCpuUsageInfo* info = (FFCpuUsageInfo*) ffListAdd(cpuTimes);
|
||||
FFCpuUsageInfo* info = FF_LIST_ADD(FFCpuUsageInfo, *cpuTimes);
|
||||
*info = (FFCpuUsageInfo) {
|
||||
.inUseAll = inUse,
|
||||
.totalAll = total,
|
||||
|
||||
@@ -28,7 +28,7 @@ static const char* getInfoByNqsi(FFlist* cpuTimes) {
|
||||
uint64_t inUse = (uint64_t) (coreInfo->UserTime.QuadPart + coreInfo->KernelTime.QuadPart);
|
||||
uint64_t total = inUse + (uint64_t) coreInfo->IdleTime.QuadPart;
|
||||
|
||||
FFCpuUsageInfo* info = (FFCpuUsageInfo*) ffListAdd(cpuTimes);
|
||||
FFCpuUsageInfo* info = FF_LIST_ADD(FFCpuUsageInfo, *cpuTimes);
|
||||
*info = (FFCpuUsageInfo) {
|
||||
.inUseAll = inUse,
|
||||
.totalAll = total,
|
||||
@@ -138,7 +138,7 @@ static const char* getInfoByPerflib(FFlist* cpuTimes) {
|
||||
return "Counter \"% Processor Utility\" are not supported";
|
||||
}
|
||||
|
||||
FFCpuUsageInfo* info = (FFCpuUsageInfo*) ffListAdd(cpuTimes);
|
||||
FFCpuUsageInfo* info = FF_LIST_ADD(FFCpuUsageInfo, *cpuTimes);
|
||||
*info = (FFCpuUsageInfo) {
|
||||
.inUseAll = processorUtility,
|
||||
.totalAll = utilityBase,
|
||||
|
||||
@@ -18,7 +18,7 @@ const char* ffDetectDisks(FFDiskOptions* options, FFlist* disks) {
|
||||
// For example for /boot/efi/bootmgr we need to check /boot/efi before /boot
|
||||
// Note that we sort alphabetically here for a better ordering when printing the list,
|
||||
// so the check must be done in reverse order
|
||||
ffListSort(disks, (void*) compareDisks);
|
||||
ffListSort(disks, sizeof(FFDisk), (void*) compareDisks);
|
||||
FF_LIST_FOR_EACH (FFDisk, disk, *disks) {
|
||||
if (disk->bytesTotal == 0) {
|
||||
disk->type |= FF_DISK_VOLUME_TYPE_UNKNOWN_BIT;
|
||||
|
||||
@@ -176,7 +176,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
|
||||
}
|
||||
#endif
|
||||
|
||||
FFDisk* disk = ffListAdd(disks);
|
||||
FFDisk* disk = FF_LIST_ADD(FFDisk, *disks);
|
||||
|
||||
disk->bytesTotal = (uint64_t) fs->f_blocks * (uint64_t) fs->f_bsize;
|
||||
disk->bytesFree = (uint64_t) fs->f_bfree * (uint64_t) fs->f_bsize;
|
||||
|
||||
@@ -36,7 +36,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFDisk* disk = (FFDisk*) ffListAdd(disks);
|
||||
FFDisk* disk = FF_LIST_ADD(FFDisk, *disks);
|
||||
|
||||
disk->bytesTotal = (uint64_t) fs.total_blocks * (uint64_t) fs.block_size;
|
||||
disk->bytesFree = (uint64_t) fs.free_blocks * (uint64_t) fs.block_size;
|
||||
|
||||
@@ -308,7 +308,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
|
||||
}
|
||||
|
||||
// We have a valid device, add it to the list
|
||||
FFDisk* disk = ffListAdd(disks);
|
||||
FFDisk* disk = FF_LIST_ADD(FFDisk, *disks);
|
||||
disk->type = FF_DISK_VOLUME_TYPE_NONE;
|
||||
|
||||
// detect mountFrom
|
||||
|
||||
@@ -131,7 +131,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
|
||||
}
|
||||
|
||||
// We have a valid device, add it to the list
|
||||
FFDisk* disk = ffListAdd(disks);
|
||||
FFDisk* disk = FF_LIST_ADD(FFDisk, *disks);
|
||||
disk->type = FF_DISK_VOLUME_TYPE_NONE;
|
||||
ffStrbufInitS(&disk->mountFrom, device.mnt_special);
|
||||
ffStrbufInitS(&disk->mountpoint, device.mnt_mountp);
|
||||
|
||||
@@ -66,7 +66,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
|
||||
}
|
||||
}
|
||||
|
||||
FFDisk* disk = ffListAdd(disks);
|
||||
FFDisk* disk = FF_LIST_ADD(FFDisk, *disks);
|
||||
|
||||
disk->filesUsed = 0;
|
||||
disk->filesTotal = 0;
|
||||
|
||||
@@ -16,7 +16,7 @@ void ffPrepareDiskIO(FFDiskIOOptions* options) {
|
||||
return; // Already prepared
|
||||
}
|
||||
|
||||
ffListInit(&ioCounters1, sizeof(FFDiskIOResult));
|
||||
ffListInit(&ioCounters1);
|
||||
ffDiskIOGetIoCounters(&ioCounters1, options);
|
||||
time1 = ffTimeGetNow();
|
||||
}
|
||||
@@ -33,7 +33,7 @@ const char* ffDetectDiskIO(FFlist* result, FFDiskIOOptions* options) {
|
||||
}
|
||||
|
||||
if (time1 == 0) {
|
||||
ffListInit(&ioCounters1, sizeof(FFDiskIOResult));
|
||||
ffListInit(&ioCounters1);
|
||||
error = ffDiskIOGetIoCounters(&ioCounters1, options);
|
||||
if (error) {
|
||||
return error;
|
||||
|
||||
@@ -37,7 +37,7 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFDiskIOResult* device = (FFDiskIOResult*) ffListAdd(result);
|
||||
FFDiskIOResult* device = FF_LIST_ADD(FFDiskIOResult, *result);
|
||||
ffStrbufInitS(&device->name, deviceName);
|
||||
ffStrbufInit(&device->devPath);
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFDiskIOResult* device = (FFDiskIOResult*) ffListAdd(result);
|
||||
FFDiskIOResult* device = FF_LIST_ADD(FFDiskIOResult, *result);
|
||||
ffStrbufInitF(&device->devPath, "/dev/%s", provider->lg_name);
|
||||
device->bytesRead = snapIter->bytes[DEVSTAT_READ];
|
||||
device->readCount = snapIter->operations[DEVSTAT_READ];
|
||||
@@ -102,7 +102,7 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFDiskIOResult* device = (FFDiskIOResult*) ffListAdd(result);
|
||||
FFDiskIOResult* device = FF_LIST_ADD(FFDiskIOResult, *result);
|
||||
ffStrbufInitS(&device->name, deviceName);
|
||||
ffStrbufInitF(&device->devPath, "/dev/%s", deviceName);
|
||||
device->bytesRead = current->bytes_read;
|
||||
|
||||
@@ -64,7 +64,7 @@ static const char* parseDiskIOCounters(int dfd, const char* devName, FFlist* res
|
||||
}
|
||||
}
|
||||
|
||||
FFDiskIOResult* device = (FFDiskIOResult*) ffListAdd(result);
|
||||
FFDiskIOResult* device = FF_LIST_ADD(FFDiskIOResult, *result);
|
||||
ffStrbufInitMove(&device->name, &name);
|
||||
ffStrbufInitF(&device->devPath, "/dev/%s", devName);
|
||||
device->bytesRead = sectorRead * 512;
|
||||
|
||||
@@ -37,7 +37,7 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFDiskIOResult* device = (FFDiskIOResult*) ffListAdd(result);
|
||||
FFDiskIOResult* device = FF_LIST_ADD(FFDiskIOResult, *result);
|
||||
ffStrbufInitNS(&device->devPath, (uint32_t) (end - path), path);
|
||||
ffStrbufInitS(&device->name, st->name);
|
||||
device->bytesRead = st->rbytes;
|
||||
|
||||
@@ -26,7 +26,7 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFDiskIOResult* device = (FFDiskIOResult*) ffListAdd(result);
|
||||
FFDiskIOResult* device = FF_LIST_ADD(FFDiskIOResult, *result);
|
||||
ffStrbufInitF(&device->devPath, "/dev/%s", st->ds_name);
|
||||
ffStrbufInitS(&device->name, st->ds_name);
|
||||
device->bytesRead = st->ds_rbytes;
|
||||
|
||||
@@ -29,7 +29,7 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFDiskIOResult* device = (FFDiskIOResult*) ffListAdd(result);
|
||||
FFDiskIOResult* device = FF_LIST_ADD(FFDiskIOResult, *result);
|
||||
ffStrbufInit(&device->devPath); // unlike other platforms, `/dev/ks_name` is not available
|
||||
ffStrbufInitS(&device->name, ks->ks_name);
|
||||
device->bytesRead = kio.nread;
|
||||
|
||||
@@ -29,7 +29,7 @@ static bool detectPhysicalDisk(const wchar_t* szDevice, FFlist* result, FFDiskIO
|
||||
return true;
|
||||
}
|
||||
|
||||
FFDiskIOResult* device = (FFDiskIOResult*) ffListAdd(result);
|
||||
FFDiskIOResult* device = FF_LIST_ADD(FFDiskIOResult, *result);
|
||||
STORAGE_DEVICE_DESCRIPTOR* sdd = (STORAGE_DEVICE_DESCRIPTOR*) sddBuffer;
|
||||
|
||||
ffStrbufInit(&device->name);
|
||||
|
||||
@@ -21,7 +21,7 @@ FFDisplayResult* ffdsAppendDisplay(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FFDisplayResult* display = (FFDisplayResult*) ffListAdd(&result->displays);
|
||||
FFDisplayResult* display = FF_LIST_ADD(FFDisplayResult, result->displays);
|
||||
display->width = width;
|
||||
display->height = height;
|
||||
display->refreshRate = refreshRate;
|
||||
@@ -52,13 +52,15 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds);
|
||||
|
||||
const FFDisplayServerResult* ffConnectDisplayServer() {
|
||||
static FFDisplayServerResult result;
|
||||
if (result.displays.elementSize == 0) {
|
||||
static bool initialized = false;
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
ffStrbufInit(&result.wmProcessName);
|
||||
ffStrbufInit(&result.wmPrettyName);
|
||||
ffStrbufInit(&result.wmProtocolName);
|
||||
ffStrbufInit(&result.deProcessName);
|
||||
ffStrbufInit(&result.dePrettyName);
|
||||
ffListInit(&result.displays, sizeof(FFDisplayResult));
|
||||
ffListInit(&result.displays);
|
||||
ffConnectDisplayServerImpl(&result);
|
||||
}
|
||||
return &result;
|
||||
|
||||
@@ -44,7 +44,7 @@ static void waylandKdeModeListener(void* data, FF_A_UNUSED struct kde_output_dev
|
||||
return;
|
||||
}
|
||||
|
||||
WaylandKdeMode* newMode = ffListAdd((FFlist*) wldata->internal);
|
||||
WaylandKdeMode* newMode = FF_LIST_ADD(WaylandKdeMode, *(FFlist*) wldata->internal);
|
||||
*newMode = (WaylandKdeMode) { .pMode = mode };
|
||||
|
||||
// Strangely, the listener is called only in this function, but not in `waylandKdeCurrentModeListener`
|
||||
@@ -188,7 +188,7 @@ const char* ffWaylandHandleKdeOutput(WaylandData* wldata, struct wl_registry* re
|
||||
return "Failed to create kde_output_device_v2";
|
||||
}
|
||||
|
||||
FF_LIST_AUTO_DESTROY modes = ffListCreate(sizeof(WaylandKdeMode));
|
||||
FF_LIST_AUTO_DESTROY modes = ffListCreate();
|
||||
WaylandDisplay display = {
|
||||
.parent = wldata,
|
||||
.transform = WL_OUTPUT_TRANSFORM_NORMAL,
|
||||
|
||||
@@ -50,7 +50,7 @@ static void waylandZwlrModeListener(void* data, FF_A_UNUSED struct zwlr_output_h
|
||||
return;
|
||||
}
|
||||
|
||||
WaylandZwlrMode* newMode = ffListAdd((FFlist*) wldata->internal);
|
||||
WaylandZwlrMode* newMode = FF_LIST_ADD(WaylandZwlrMode, *(FFlist*) wldata->internal);
|
||||
*newMode = (WaylandZwlrMode) { .pMode = mode };
|
||||
|
||||
// Strangely, the listener is called only in this function, but not in `waylandZwlrCurrentModeListener`
|
||||
@@ -118,7 +118,7 @@ static const struct zwlr_output_head_v1_listener headListener = {
|
||||
static void waylandHandleZwlrHead(void* data, FF_A_UNUSED struct zwlr_output_manager_v1* zwlr_output_manager_v1, struct zwlr_output_head_v1* head) {
|
||||
WaylandData* wldata = data;
|
||||
|
||||
FF_LIST_AUTO_DESTROY modes = ffListCreate(sizeof(WaylandZwlrMode));
|
||||
FF_LIST_AUTO_DESTROY modes = ffListCreate();
|
||||
WaylandDisplay display = {
|
||||
.parent = wldata,
|
||||
.transform = WL_OUTPUT_TRANSFORM_NORMAL,
|
||||
|
||||
@@ -48,7 +48,7 @@ static const char* detectDnsFromConf(const char* path, FFDNSOptions* options, FF
|
||||
continue;
|
||||
}
|
||||
|
||||
FFstrbuf* item = (FFstrbuf*) ffListAdd(results);
|
||||
FFstrbuf* item = FF_LIST_ADD(FFstrbuf, *results);
|
||||
ffStrbufInitS(item, nameserver);
|
||||
ffStrbufTrimRightSpace(item);
|
||||
FF_DEBUG("Found DNS server: %s", item->chars);
|
||||
@@ -85,7 +85,7 @@ const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) {
|
||||
}
|
||||
|
||||
// Add to results
|
||||
FFstrbuf* item = (FFstrbuf*) ffListAdd(results);
|
||||
FFstrbuf* item = FF_LIST_ADD(FFstrbuf, *results);
|
||||
ffStrbufInitMove(item, &buffer);
|
||||
FF_DEBUG("Found DNS server on macOS: %s", item->chars);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ static const char* detectDnsFromConf(const char* path, FFDNSOptions* options, FF
|
||||
continue;
|
||||
}
|
||||
|
||||
FFstrbuf* item = (FFstrbuf*) ffListAdd(results);
|
||||
FFstrbuf* item = FF_LIST_ADD(FFstrbuf, *results);
|
||||
ffStrbufInitS(item, nameserver);
|
||||
ffStrbufTrimRightSpace(item);
|
||||
FF_DEBUG("Found DNS server: %s", item->chars);
|
||||
|
||||
@@ -46,7 +46,7 @@ const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) {
|
||||
}
|
||||
|
||||
for (IP_ADAPTER_DNS_SERVER_ADDRESS_XP* ifa = adapter->FirstDnsServerAddress; ifa; ifa = ifa->Next) {
|
||||
FFstrbuf* item = (FFstrbuf*) ffListAdd(results);
|
||||
FFstrbuf* item = FF_LIST_ADD(FFstrbuf, *results);
|
||||
if (ifa->Address.lpSockaddr->sa_family == AF_INET) {
|
||||
SOCKADDR_IN* ipv4 = (SOCKADDR_IN*) ifa->Address.lpSockaddr;
|
||||
ffStrbufInitA(item, INET_ADDRSTRLEN);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <IOKit/hid/IOHIDLib.h>
|
||||
|
||||
static void enumSet(IOHIDDeviceRef value, FFlist* results) {
|
||||
FFGamepadDevice* device = (FFGamepadDevice*) ffListAdd(results);
|
||||
FFGamepadDevice* device = FF_LIST_ADD(FFGamepadDevice, *results);
|
||||
ffStrbufInit(&device->serial);
|
||||
ffStrbufInit(&device->name);
|
||||
device->battery = 0;
|
||||
|
||||
@@ -49,7 +49,7 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) {
|
||||
|
||||
struct usb_device_info di;
|
||||
if (ioctl(fd, USB_GET_DEVICEINFO, &di) != -1) {
|
||||
FFGamepadDevice* device = (FFGamepadDevice*) ffListAdd(devices);
|
||||
FFGamepadDevice* device = FF_LIST_ADD(FFGamepadDevice, *devices);
|
||||
ffStrbufInitS(&device->serial, di.udi_serial);
|
||||
ffStrbufInitF(&device->name, "%s %s", di.udi_vendor, di.udi_product);
|
||||
device->battery = 0;
|
||||
|
||||
@@ -8,7 +8,7 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) {
|
||||
for (int32 i = 0, n = js.CountDevices(); i < n; ++i) {
|
||||
char name[B_OS_NAME_LENGTH];
|
||||
if (js.GetDeviceName(i, name) == B_OK) {
|
||||
FFGamepadDevice* device = (FFGamepadDevice*) ffListAdd(devices);
|
||||
FFGamepadDevice* device = FF_LIST_ADD(FFGamepadDevice, *devices);
|
||||
ffStrbufInit(&device->serial);
|
||||
ffStrbufInitS(&device->name, name);
|
||||
device->battery = 0;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
static void detectGamepad(FFlist* devices, FFstrbuf* name, FFstrbuf* path) {
|
||||
uint32_t baseLen = path->length;
|
||||
FFGamepadDevice* device = (FFGamepadDevice*) ffListAdd(devices);
|
||||
FFGamepadDevice* device = FF_LIST_ADD(FFGamepadDevice, *devices);
|
||||
ffStrbufInit(&device->serial);
|
||||
ffStrbufInitMove(&device->name, name);
|
||||
device->battery = 0;
|
||||
|
||||
@@ -113,7 +113,7 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFGamepadDevice* device = (FFGamepadDevice*) ffListAdd(devices);
|
||||
FFGamepadDevice* device = FF_LIST_ADD(FFGamepadDevice, *devices);
|
||||
ffStrbufInit(&device->serial);
|
||||
ffStrbufInit(&device->name);
|
||||
device->battery = 0;
|
||||
|
||||
@@ -90,7 +90,7 @@ const char* detectByOpenGL(FFlist* gpus) {
|
||||
FF_DEBUG("OpenGL detection returns: %s", error ?: "success");
|
||||
|
||||
if (!error) {
|
||||
FFGPUResult* gpu = (FFGPUResult*) ffListAdd(gpus);
|
||||
FFGPUResult* gpu = FF_LIST_ADD(FFGPUResult, *gpus);
|
||||
gpu->type = FF_GPU_TYPE_UNKNOWN;
|
||||
ffStrbufInitMove(&gpu->vendor, &result.vendor);
|
||||
ffStrbufInitMove(&gpu->name, &result.renderer);
|
||||
|
||||
@@ -112,7 +112,7 @@ const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFGPUResult* gpu = ffListAdd(gpus);
|
||||
FFGPUResult* gpu = FF_LIST_ADD(FFGPUResult, *gpus);
|
||||
gpu->index = FF_GPU_INDEX_UNSET;
|
||||
ffStrbufInit(&gpu->memoryType);
|
||||
gpu->dedicated.total = gpu->dedicated.used = gpu->shared.total = gpu->shared.used = FF_GPU_VMEM_SIZE_UNSET;
|
||||
|
||||
@@ -56,7 +56,7 @@ static const char* detectByDrm(const FFGPUOptions* options, FFlist* gpus) {
|
||||
|
||||
const char* path = dev->nodes[DRM_NODE_PRIMARY];
|
||||
|
||||
FFGPUResult* gpu = (FFGPUResult*) ffListAdd(gpus);
|
||||
FFGPUResult* gpu = FF_LIST_ADD(FFGPUResult, *gpus);
|
||||
ffStrbufInit(&gpu->vendor);
|
||||
ffStrbufInit(&gpu->name);
|
||||
ffStrbufInit(&gpu->driver);
|
||||
@@ -179,7 +179,7 @@ static const char* detectByPci(const FFGPUOptions* options, FFlist* gpus) {
|
||||
continue; // Likely an auxiliary display controller (#2034)
|
||||
}
|
||||
|
||||
FFGPUResult* gpu = (FFGPUResult*) ffListAdd(gpus);
|
||||
FFGPUResult* gpu = FF_LIST_ADD(FFGPUResult, *gpus);
|
||||
ffStrbufInitStatic(&gpu->vendor, ffGPUGetVendorString(pc->pc_vendor));
|
||||
ffStrbufInit(&gpu->name);
|
||||
ffStrbufInitS(&gpu->driver, pc->pd_name);
|
||||
|
||||
@@ -117,7 +117,7 @@ const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpu
|
||||
uint16_t vendorId = data[PCI_VENDOR_ID] | (data[PCI_VENDOR_ID + 1] << 8);
|
||||
uint16_t deviceId = data[PCI_DEVICE_ID] | (data[PCI_DEVICE_ID + 1] << 8);
|
||||
|
||||
FFGPUResult* gpu = (FFGPUResult*) ffListAdd(gpus);
|
||||
FFGPUResult* gpu = FF_LIST_ADD(FFGPUResult, *gpus);
|
||||
ffStrbufInitStatic(&gpu->vendor, ffGPUGetVendorString(vendorId));
|
||||
ffStrbufInit(&gpu->name);
|
||||
ffStrbufInit(&gpu->driver);
|
||||
|
||||
@@ -24,7 +24,7 @@ const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpu
|
||||
continue; // Likely an auxiliary display controller (#2034)
|
||||
}
|
||||
|
||||
FFGPUResult* gpu = (FFGPUResult*) ffListAdd(gpus);
|
||||
FFGPUResult* gpu = FF_LIST_ADD(FFGPUResult, *gpus);
|
||||
ffStrbufInitStatic(&gpu->vendor, ffGPUGetVendorString(dev.vendor_id));
|
||||
ffStrbufInit(&gpu->name);
|
||||
ffStrbufInit(&gpu->driver);
|
||||
|
||||
@@ -392,7 +392,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
|
||||
return "Likely an auxiliary display controller"; // #2034
|
||||
}
|
||||
|
||||
FFGPUResult* gpu = (FFGPUResult*) ffListAdd(gpus);
|
||||
FFGPUResult* gpu = FF_LIST_ADD(FFGPUResult, *gpus);
|
||||
ffStrbufInitStatic(&gpu->vendor, ffGPUGetVendorString((uint16_t) vendorId));
|
||||
ffStrbufInit(&gpu->name);
|
||||
ffStrbufInit(&gpu->driver);
|
||||
@@ -528,7 +528,7 @@ static const char* detectOf(FFlist* gpus, FFstrbuf* buffer, FFstrbuf* drmDir, co
|
||||
++name;
|
||||
}
|
||||
|
||||
FFGPUResult* gpu = (FFGPUResult*) ffListAdd(gpus);
|
||||
FFGPUResult* gpu = FF_LIST_ADD(FFGPUResult, *gpus);
|
||||
gpu->index = FF_GPU_INDEX_UNSET;
|
||||
gpu->deviceId = 0;
|
||||
ffStrbufInit(&gpu->name);
|
||||
|
||||
@@ -83,7 +83,7 @@ const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpu
|
||||
continue; // Likely an auxiliary display controller (#2034)
|
||||
}
|
||||
|
||||
FFGPUResult* gpu = (FFGPUResult*) ffListAdd(gpus);
|
||||
FFGPUResult* gpu = FF_LIST_ADD(FFGPUResult, *gpus);
|
||||
ffStrbufInitStatic(&gpu->vendor, ffGPUGetVendorString(PCI_VENDOR(pciid)));
|
||||
ffStrbufInit(&gpu->name);
|
||||
ffStrbufInit(&gpu->driver);
|
||||
|
||||
@@ -72,7 +72,7 @@ const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpu
|
||||
continue; // Likely an auxiliary display controller (#2034)
|
||||
}
|
||||
|
||||
FFGPUResult* gpu = (FFGPUResult*) ffListAdd(gpus);
|
||||
FFGPUResult* gpu = FF_LIST_ADD(FFGPUResult, *gpus);
|
||||
ffStrbufInitStatic(&gpu->vendor, ffGPUGetVendorString(PCI_VENDOR(pciid)));
|
||||
ffStrbufInit(&gpu->name);
|
||||
ffStrbufInit(&gpu->driver);
|
||||
|
||||
@@ -7,7 +7,7 @@ static int walkDevTree(di_node_t node, FF_A_UNUSED di_minor_t minor, FFlist* gpu
|
||||
int* vendorId;
|
||||
int* deviceId;
|
||||
if (di_prop_lookup_ints(DDI_DEV_T_ANY, node, "vendor-id", &vendorId) > 0 && di_prop_lookup_ints(DDI_DEV_T_ANY, node, "device-id", &deviceId) > 0) {
|
||||
FFGPUResult* gpu = (FFGPUResult*) ffListAdd(gpus);
|
||||
FFGPUResult* gpu = FF_LIST_ADD(FFGPUResult, *gpus);
|
||||
ffStrbufInitS(&gpu->vendor, ffGPUGetVendorString((uint16_t) *vendorId));
|
||||
ffStrbufInit(&gpu->name);
|
||||
ffStrbufInitS(&gpu->driver, di_driver_name(node));
|
||||
|
||||
@@ -32,13 +32,15 @@ static bool queryDeviceIdsFallback(D3DKMT_ADAPTERADDRESS adapterAddress, D3DKMT_
|
||||
}
|
||||
|
||||
static FFlist deviceIdsCache;
|
||||
static bool initialized;
|
||||
typedef struct {
|
||||
D3DKMT_DEVICE_IDS deviceIds;
|
||||
D3DKMT_ADAPTERADDRESS adapterAddress;
|
||||
} CacheEntry;
|
||||
|
||||
if (deviceIdsCache.elementSize == 0) {
|
||||
ffListInit(&deviceIdsCache, sizeof(CacheEntry));
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
ffListInit(&deviceIdsCache);
|
||||
|
||||
ULONG devIdListSize = 0;
|
||||
if (CM_Get_Device_ID_List_SizeW(&devIdListSize, GUID_DEVCLASS_DISPLAY_STRING, CM_GETIDLIST_FILTER_CLASS | CM_GETIDLIST_FILTER_PRESENT) != CR_SUCCESS || devIdListSize <= 1) {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <IOKit/hid/IOHIDLib.h>
|
||||
|
||||
static void enumSet(IOHIDDeviceRef value, FFlist* results) {
|
||||
FFKeyboardDevice* device = (FFKeyboardDevice*) ffListAdd(results);
|
||||
FFKeyboardDevice* device = FF_LIST_ADD(FFKeyboardDevice, *results);
|
||||
ffStrbufInit(&device->serial);
|
||||
ffStrbufInit(&device->name);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ static const char* detectByIoctl(FFlist* devices) {
|
||||
return "ioctl(KDGKBINFO) failed";
|
||||
}
|
||||
|
||||
FFKeyboardDevice* device = (FFKeyboardDevice*) ffListAdd(devices);
|
||||
FFKeyboardDevice* device = FF_LIST_ADD(FFKeyboardDevice, *devices);
|
||||
|
||||
switch (kbdInfo.kb_type) {
|
||||
case KB_84:
|
||||
@@ -69,7 +69,7 @@ static const char* detectByUsbhid(FFlist* devices) {
|
||||
|
||||
struct usb_device_info di;
|
||||
if (ioctl(fd, USB_GET_DEVICEINFO, &di) != -1) {
|
||||
FFKeyboardDevice* device = (FFKeyboardDevice*) ffListAdd(devices);
|
||||
FFKeyboardDevice* device = FF_LIST_ADD(FFKeyboardDevice, *devices);
|
||||
ffStrbufInitS(&device->serial, di.udi_serial);
|
||||
ffStrbufInitS(&device->name, di.udi_product);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFKeyboardDevice* item = (FFKeyboardDevice*) ffListAdd(devices);
|
||||
FFKeyboardDevice* item = FF_LIST_ADD(FFKeyboardDevice, *devices);
|
||||
ffStrbufInit(&item->serial);
|
||||
ffStrbufInitS(&item->name, device->Name());
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) {
|
||||
case '\0':
|
||||
// End of device entry; add to list if it has a name.
|
||||
if (device.name.length > 0) {
|
||||
FFKeyboardDevice* added = (FFKeyboardDevice*) ffListAdd(devices);
|
||||
FFKeyboardDevice* added = FF_LIST_ADD(FFKeyboardDevice, *devices);
|
||||
ffStrbufInitMove(&added->name, &device.name);
|
||||
ffStrbufInitMove(&added->serial, &device.serial);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFKeyboardDevice* device = (FFKeyboardDevice*) ffListAdd(devices);
|
||||
FFKeyboardDevice* device = FF_LIST_ADD(FFKeyboardDevice, *devices);
|
||||
ffStrbufInit(&device->serial);
|
||||
ffStrbufInit(&device->name);
|
||||
|
||||
|
||||
@@ -172,8 +172,10 @@ static FFLocalIpIpv6Type getIpv6Type(struct ifaddrs* ifa) {
|
||||
return result;
|
||||
#elif __linux__
|
||||
static FFlist addresses = {};
|
||||
if (addresses.elementSize == 0) {
|
||||
ffListInit(&addresses, sizeof(struct in6_addr));
|
||||
static bool initialized = false;
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
ffListInit(&addresses);
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
if (!ffReadFileBuffer("/proc/net/if_inet6", &buffer)) {
|
||||
return result;
|
||||
@@ -182,7 +184,7 @@ static FFLocalIpIpv6Type getIpv6Type(struct ifaddrs* ifa) {
|
||||
char* line = NULL;
|
||||
size_t len = 0;
|
||||
while (ffStrbufGetline(&line, &len, &buffer)) {
|
||||
struct in6_addr* entry = (struct in6_addr*) ffListAdd(&addresses);
|
||||
struct in6_addr* entry = FF_LIST_ADD(struct in6_addr, addresses);
|
||||
uint8_t flags;
|
||||
if (sscanf(line, "%2" SCNx8 "%2" SCNx8 "%2" SCNx8 "%2" SCNx8 "%2" SCNx8 "%2" SCNx8 "%2" SCNx8 "%2" SCNx8 "%2" SCNx8 "%2" SCNx8 "%2" SCNx8 "%2" SCNx8 "%2" SCNx8 "%2" SCNx8 "%2" SCNx8 "%2" SCNx8 " %*s %*s %*s %" SCNx8 " %*s", &entry->s6_addr[0], &entry->s6_addr[1], &entry->s6_addr[2], &entry->s6_addr[3], &entry->s6_addr[4], &entry->s6_addr[5], &entry->s6_addr[6], &entry->s6_addr[7], &entry->s6_addr[8], &entry->s6_addr[9], &entry->s6_addr[10], &entry->s6_addr[11], &entry->s6_addr[12], &entry->s6_addr[13], &entry->s6_addr[14], &entry->s6_addr[15], &flags) != 17 ||
|
||||
(!IN6_IS_ADDR_GLOBAL(entry) && !IN6_IS_ADDR_UNIQUE_LOCAL(entry)) ||
|
||||
@@ -284,7 +286,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) {
|
||||
|
||||
FF_DEBUG("Successfully retrieved interface addresses");
|
||||
|
||||
FF_LIST_AUTO_DESTROY adapters = ffListCreate(sizeof(FFAdapter));
|
||||
FF_LIST_AUTO_DESTROY adapters = ffListCreate();
|
||||
|
||||
for (struct ifaddrs* ifa = ifAddrStruct; ifa; ifa = ifa->ifa_next) {
|
||||
if (!ifa->ifa_addr) {
|
||||
@@ -341,11 +343,11 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) {
|
||||
}
|
||||
}
|
||||
if (!adapter) {
|
||||
adapter = ffListAdd(&adapters);
|
||||
adapter = FF_LIST_ADD(FFAdapter, adapters);
|
||||
*adapter = (FFAdapter) {
|
||||
.mac = ifa,
|
||||
.ipv4 = ffListCreate(sizeof(struct ifaddrs*)),
|
||||
.ipv6 = ffListCreate(sizeof(struct ifaddrs*)),
|
||||
.ipv4 = ffListCreate(),
|
||||
.ipv6 = ffListCreate(),
|
||||
};
|
||||
FF_DEBUG("Created new adapter entry for interface %s", ifa->ifa_name);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) {
|
||||
processedCount++;
|
||||
FF_DEBUG("Creating result item for adapter %u ('%s')", (unsigned) adapter->IfIndex, name.chars);
|
||||
|
||||
FFLocalIpResult* item = (FFLocalIpResult*) ffListAdd(results);
|
||||
FFLocalIpResult* item = FF_LIST_ADD(FFLocalIpResult, *results);
|
||||
ffStrbufInitMove(&item->name, &name);
|
||||
ffStrbufInit(&item->ipv4);
|
||||
ffStrbufInit(&item->ipv6);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <IOKit/hid/IOHIDLib.h>
|
||||
|
||||
static void enumSet(IOHIDDeviceRef value, FFlist* results) {
|
||||
FFMouseDevice* device = (FFMouseDevice*) ffListAdd(results);
|
||||
FFMouseDevice* device = FF_LIST_ADD(FFMouseDevice, *results);
|
||||
ffStrbufInit(&device->serial);
|
||||
ffStrbufInit(&device->name);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) {
|
||||
|
||||
struct usb_device_info di;
|
||||
if (ioctl(fd, USB_GET_DEVICEINFO, &di) != -1) {
|
||||
FFMouseDevice* device = (FFMouseDevice*) ffListAdd(devices);
|
||||
FFMouseDevice* device = FF_LIST_ADD(FFMouseDevice, *devices);
|
||||
ffStrbufInitS(&device->serial, di.udi_serial);
|
||||
ffStrbufInitS(&device->name, di.udi_product);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFMouseDevice* item = (FFMouseDevice*) ffListAdd(devices);
|
||||
FFMouseDevice* item = FF_LIST_ADD(FFMouseDevice, *devices);
|
||||
ffStrbufInit(&item->serial);
|
||||
ffStrbufInitS(&item->name, device->Name());
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) {
|
||||
ffStrbufTrimRightSpace(&name);
|
||||
ffStrbufSubstrBefore(&path, path.length - 4);
|
||||
|
||||
FFMouseDevice* device = (FFMouseDevice*) ffListAdd(devices);
|
||||
FFMouseDevice* device = FF_LIST_ADD(FFMouseDevice, *devices);
|
||||
ffStrbufInitMove(&device->name, &name);
|
||||
ffStrbufInit(&device->serial);
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFMouseDevice* device = (FFMouseDevice*) ffListAdd(devices);
|
||||
FFMouseDevice* device = FF_LIST_ADD(FFMouseDevice, *devices);
|
||||
ffStrbufInit(&device->serial);
|
||||
ffStrbufInit(&device->name);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ void ffPrepareNetIO(FFNetIOOptions* options) {
|
||||
return; // Already prepared
|
||||
}
|
||||
|
||||
ffListInit(&ioCounters1, sizeof(FFNetIOResult));
|
||||
ffListInit(&ioCounters1);
|
||||
ffNetIOGetIoCounters(&ioCounters1, options);
|
||||
time1 = ffTimeGetNow();
|
||||
}
|
||||
@@ -31,7 +31,7 @@ const char* ffDetectNetIO(FFlist* result, FFNetIOOptions* options) {
|
||||
}
|
||||
|
||||
if (time1 == 0) {
|
||||
ffListInit(&ioCounters1, sizeof(FFNetIOResult));
|
||||
ffListInit(&ioCounters1);
|
||||
error = ffNetIOGetIoCounters(&ioCounters1, options);
|
||||
if (error) {
|
||||
return error;
|
||||
|
||||
@@ -36,7 +36,7 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFNetIOResult* counters = (FFNetIOResult*) ffListAdd(result);
|
||||
FFNetIOResult* counters = FF_LIST_ADD(FFNetIOResult, *result);
|
||||
*counters = (FFNetIOResult) {
|
||||
.name = ffStrbufCreateS(mibdata->ifmd_name),
|
||||
.txBytes = mibdata->ifmd_data.ifi_obytes,
|
||||
|
||||
@@ -39,7 +39,7 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFNetIOResult* counters = (FFNetIOResult*) ffListAdd(result);
|
||||
FFNetIOResult* counters = FF_LIST_ADD(FFNetIOResult, *result);
|
||||
*counters = (FFNetIOResult) {
|
||||
.name = ffStrbufCreateNS(sdl->sdl_nlen, sdl->sdl_data),
|
||||
.txBytes = ifm->ifm_data.ifi_obytes,
|
||||
|
||||
@@ -33,7 +33,7 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFNetIOResult* counters = (FFNetIOResult*) ffListAdd(result);
|
||||
FFNetIOResult* counters = FF_LIST_ADD(FFNetIOResult, *result);
|
||||
*counters = (FFNetIOResult) {
|
||||
.name = ffStrbufCreateS(interface.Name()),
|
||||
.defaultRoute = defaultRoute,
|
||||
|
||||
@@ -18,7 +18,7 @@ static void getData(FFstrbuf* buffer, const char* ifName, bool isDefaultRoute, i
|
||||
return;
|
||||
}
|
||||
|
||||
FFNetIOResult* counters = (FFNetIOResult*) ffListAdd(result);
|
||||
FFNetIOResult* counters = FF_LIST_ADD(FFNetIOResult, *result);
|
||||
ffStrbufInitS(&counters->name, ifName);
|
||||
counters->defaultRoute = isDefaultRoute;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFNetIOResult* counters = (FFNetIOResult*) ffListAdd(result);
|
||||
FFNetIOResult* counters = FF_LIST_ADD(FFNetIOResult, *result);
|
||||
|
||||
kstat_named_t* wbytes = (kstat_named_t*) kstat_data_lookup(ks, "obytes64");
|
||||
kstat_named_t* rbytes = (kstat_named_t*) kstat_data_lookup(ks, "rbytes64");
|
||||
|
||||
@@ -51,7 +51,7 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) {
|
||||
|
||||
MIB_IF_ROW2 ifRow = { .InterfaceIndex = adapter->IfIndex };
|
||||
if (GetIfEntry2(&ifRow) == NO_ERROR) {
|
||||
FFNetIOResult* counters = (FFNetIOResult*) ffListAdd(result);
|
||||
FFNetIOResult* counters = FF_LIST_ADD(FFNetIOResult, *result);
|
||||
*counters = (FFNetIOResult) {
|
||||
.name = ffStrbufCreateMove(&name),
|
||||
.txBytes = ifRow.OutOctets,
|
||||
|
||||
@@ -87,7 +87,7 @@ static const char* openCLHandleData(OpenCLData* data, FFOpenCLResult* result) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FFGPUResult* gpu = ffListAdd(&result->gpus);
|
||||
FFGPUResult* gpu = FF_LIST_ADD(FFGPUResult, result->gpus);
|
||||
ffStrbufInitS(&gpu->name, buffer);
|
||||
ffStrbufInit(&gpu->vendor);
|
||||
ffStrbufInit(&gpu->driver);
|
||||
@@ -198,12 +198,14 @@ static const char* detectOpenCL(FFOpenCLResult* result) {
|
||||
|
||||
FFOpenCLResult* ffDetectOpenCL(void) {
|
||||
static FFOpenCLResult result;
|
||||
static bool initialized;
|
||||
|
||||
if (result.gpus.elementSize == 0) {
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
ffStrbufInit(&result.version);
|
||||
ffStrbufInit(&result.name);
|
||||
ffStrbufInit(&result.vendor);
|
||||
ffListInit(&result.gpus, sizeof(FFGPUResult));
|
||||
ffListInit(&result.gpus);
|
||||
|
||||
#ifdef FF_HAVE_OPENCL
|
||||
result.error = detectOpenCL(&result);
|
||||
|
||||
@@ -130,7 +130,7 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options)
|
||||
type |= FF_PHYSICALDISK_TYPE_UNUSED;
|
||||
}
|
||||
|
||||
FFPhysicalDiskResult* device = (FFPhysicalDiskResult*) ffListAdd(result);
|
||||
FFPhysicalDiskResult* device = FF_LIST_ADD(FFPhysicalDiskResult, *result);
|
||||
ffStrbufInit(&device->serial);
|
||||
ffStrbufInit(&device->revision);
|
||||
ffStrbufInitMove(&device->name, &deviceName);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user