mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 10:52:08 +02:00
Global: unifies GCC attributes usage
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# include <sal.h>
|
||||
#endif
|
||||
|
||||
#if defined(__has_attribute) && __has_attribute(__warn_unused_result__)
|
||||
# define FF_C_NODISCARD __attribute__((__warn_unused_result__))
|
||||
#elif defined(_MSC_VER)
|
||||
# define FF_C_NODISCARD _Check_return_
|
||||
#else
|
||||
# define FF_C_NODISCARD
|
||||
#endif
|
||||
|
||||
#if defined(__has_attribute) && __has_attribute(__format__)
|
||||
# define FF_C_PRINTF(formatStrIndex, argsStartIndex) __attribute__((__format__(printf, formatStrIndex, argsStartIndex)))
|
||||
#else
|
||||
# define FF_C_PRINTF(formatStrIndex, argsStartIndex)
|
||||
#endif
|
||||
|
||||
#if defined(__has_attribute) && __has_attribute(__format__)
|
||||
# define FF_C_SCANF(formatStrIndex, argsStartIndex) __attribute__((__format__(scanf, formatStrIndex, argsStartIndex)))
|
||||
#else
|
||||
# define FF_C_SCANF(formatStrIndex, argsStartIndex)
|
||||
#endif
|
||||
|
||||
#if defined(__has_attribute) && __has_attribute(__nonnull__)
|
||||
# define FF_C_NONNULL(argIndex, ...) __attribute__((__nonnull__(argIndex, ##__VA_ARGS__)))
|
||||
#else
|
||||
# define FF_C_NONNULL(argIndex, ...)
|
||||
#endif
|
||||
|
||||
#if defined(__has_attribute) && __has_attribute(__returns_nonnull__)
|
||||
# define FF_C_RETURNS_NONNULL __attribute__((__returns_nonnull__))
|
||||
#else
|
||||
# define FF_C_RETURNS_NONNULL
|
||||
#endif
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "FFcheckmacros.h"
|
||||
#include "common/attributes.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@@ -48,7 +48,7 @@ static inline void* ffListGet(const FFlist* list, uint32_t index) {
|
||||
return list->data + (index * list->elementSize);
|
||||
}
|
||||
|
||||
FF_C_NODISCARD static inline uint32_t ffListFirstIndexComp(const FFlist* list, void* compElement, bool (*compFunc)(const void*, const void*)) {
|
||||
FF_A_NODISCARD static inline uint32_t ffListFirstIndexComp(const FFlist* list, void* compElement, bool (*compFunc)(const void*, const void*)) {
|
||||
for (uint32_t i = 0; i < list->length; i++) {
|
||||
if (compFunc(ffListGet(list, i), compElement)) {
|
||||
return i;
|
||||
@@ -109,7 +109,7 @@ static inline void ffListReserve(FFlist* list, uint32_t newCapacity) {
|
||||
itemVarName - (itemType*) (listVar).data < (intptr_t) (listVar).length; \
|
||||
++itemVarName)
|
||||
|
||||
#define FF_LIST_AUTO_DESTROY FFlist __attribute__((__cleanup__(ffListDestroy)))
|
||||
#define FF_LIST_AUTO_DESTROY FFlist FF_A_CLEANUP(ffListDestroy)
|
||||
|
||||
#define FF_LIST_GET(itemType, listVar, index) \
|
||||
({ \
|
||||
|
||||
+55
-55
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "FFcheckmacros.h"
|
||||
#include "common/attributes.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
@@ -47,7 +47,7 @@ void ffStrbufAppendC(FFstrbuf* strbuf, char c);
|
||||
void ffStrbufAppendNC(FFstrbuf* strbuf, uint32_t num, char c);
|
||||
void ffStrbufAppendNS(FFstrbuf* strbuf, uint32_t length, const char* value);
|
||||
void ffStrbufAppendTransformS(FFstrbuf* strbuf, const char* value, int (*transformFunc)(int));
|
||||
FF_C_PRINTF(2, 3)
|
||||
FF_A_PRINTF(2, 3)
|
||||
void ffStrbufAppendF(FFstrbuf* strbuf, const char* format, ...);
|
||||
void ffStrbufAppendVF(FFstrbuf* strbuf, const char* format, va_list arguments);
|
||||
const char* ffStrbufAppendSUntilC(FFstrbuf* strbuf, const char* value, char until);
|
||||
@@ -61,7 +61,7 @@ void ffStrbufInsertNC(FFstrbuf* strbuf, uint32_t index, uint32_t num, char c);
|
||||
// NOTE: Unlike ffStrbufAppend*, ffStrbufSet* functions may NOT reserve extra space
|
||||
void ffStrbufSet(FFstrbuf* strbuf, const FFstrbuf* value);
|
||||
void ffStrbufSetNS(FFstrbuf* strbuf, uint32_t length, const char* value);
|
||||
FF_C_PRINTF(2, 3)
|
||||
FF_A_PRINTF(2, 3)
|
||||
void ffStrbufSetF(FFstrbuf* strbuf, const char* format, ...);
|
||||
|
||||
void ffStrbufTrimLeft(FFstrbuf* strbuf, char c);
|
||||
@@ -73,10 +73,10 @@ bool ffStrbufRemoveSubstr(FFstrbuf* strbuf, uint32_t startIndex, uint32_t endInd
|
||||
void ffStrbufRemoveS(FFstrbuf* strbuf, const char* str);
|
||||
void ffStrbufRemoveStrings(FFstrbuf* strbuf, uint32_t numStrings, const char* strings[]);
|
||||
|
||||
FF_C_NODISCARD uint32_t ffStrbufNextIndexC(const FFstrbuf* strbuf, uint32_t start, char c);
|
||||
FF_C_NODISCARD uint32_t ffStrbufNextIndexS(const FFstrbuf* strbuf, uint32_t start, const char* str);
|
||||
FF_A_NODISCARD uint32_t ffStrbufNextIndexC(const FFstrbuf* strbuf, uint32_t start, char c);
|
||||
FF_A_NODISCARD uint32_t ffStrbufNextIndexS(const FFstrbuf* strbuf, uint32_t start, const char* str);
|
||||
|
||||
FF_C_NODISCARD uint32_t ffStrbufPreviousIndexC(const FFstrbuf* strbuf, uint32_t start, char c);
|
||||
FF_A_NODISCARD uint32_t ffStrbufPreviousIndexC(const FFstrbuf* strbuf, uint32_t start, char c);
|
||||
|
||||
void ffStrbufReplaceAllC(FFstrbuf* strbuf, char find, char replace);
|
||||
|
||||
@@ -88,7 +88,7 @@ bool ffStrbufSubstrAfterFirstS(FFstrbuf* strbuf, const char* str);
|
||||
bool ffStrbufSubstrAfterLastC(FFstrbuf* strbuf, char c);
|
||||
bool ffStrbufSubstr(FFstrbuf* strbuf, uint32_t start, uint32_t end);
|
||||
|
||||
FF_C_NODISCARD uint32_t ffStrbufCountC(const FFstrbuf* strbuf, char c);
|
||||
FF_A_NODISCARD uint32_t ffStrbufCountC(const FFstrbuf* strbuf, char c);
|
||||
|
||||
bool ffStrbufRemoveIgnCaseEndS(FFstrbuf* strbuf, const char* end);
|
||||
|
||||
@@ -97,9 +97,9 @@ bool ffStrbufEnsureEndsWithC(FFstrbuf* strbuf, char c);
|
||||
void ffStrbufWriteTo(const FFstrbuf* strbuf, FILE* file);
|
||||
void ffStrbufPutTo(const FFstrbuf* strbuf, FILE* file);
|
||||
|
||||
FF_C_NODISCARD double ffStrbufToDouble(const FFstrbuf* strbuf, double defaultValue);
|
||||
FF_C_NODISCARD int64_t ffStrbufToSInt(const FFstrbuf* strbuf, int64_t defaultValue);
|
||||
FF_C_NODISCARD uint64_t ffStrbufToUInt(const FFstrbuf* strbuf, uint64_t defaultValue);
|
||||
FF_A_NODISCARD double ffStrbufToDouble(const FFstrbuf* strbuf, double defaultValue);
|
||||
FF_A_NODISCARD int64_t ffStrbufToSInt(const FFstrbuf* strbuf, int64_t defaultValue);
|
||||
FF_A_NODISCARD uint64_t ffStrbufToUInt(const FFstrbuf* strbuf, uint64_t defaultValue);
|
||||
|
||||
void ffStrbufUpperCase(FFstrbuf* strbuf);
|
||||
void ffStrbufLowerCase(FFstrbuf* strbuf);
|
||||
@@ -151,7 +151,7 @@ void ffStrbufAppendUInt(FFstrbuf* strbuf, uint64_t value);
|
||||
// if `precision < 0`, let yyjson decide the precision
|
||||
void ffStrbufAppendDouble(FFstrbuf* strbuf, double value, int8_t precision, bool trailingZeros);
|
||||
|
||||
FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateA(uint32_t allocate) {
|
||||
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateA(uint32_t allocate) {
|
||||
FFstrbuf strbuf;
|
||||
ffStrbufInitA(&strbuf, allocate);
|
||||
return strbuf;
|
||||
@@ -166,7 +166,7 @@ static inline void ffStrbufInitCopy(FFstrbuf* __restrict strbuf, const FFstrbuf*
|
||||
}
|
||||
}
|
||||
|
||||
FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateCopy(const FFstrbuf* src) {
|
||||
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateCopy(const FFstrbuf* src) {
|
||||
FFstrbuf strbuf;
|
||||
ffStrbufInitCopy(&strbuf, src);
|
||||
return strbuf;
|
||||
@@ -182,19 +182,19 @@ static inline void ffStrbufInitMove(FFstrbuf* strbuf, FFstrbuf* src) {
|
||||
}
|
||||
}
|
||||
|
||||
FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateMove(FFstrbuf* src) {
|
||||
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateMove(FFstrbuf* src) {
|
||||
FFstrbuf strbuf;
|
||||
ffStrbufInitMove(&strbuf, src);
|
||||
return strbuf;
|
||||
}
|
||||
|
||||
FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateVF(const char* format, va_list arguments) {
|
||||
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateVF(const char* format, va_list arguments) {
|
||||
FFstrbuf strbuf;
|
||||
ffStrbufInitVF(&strbuf, format, arguments);
|
||||
return strbuf;
|
||||
}
|
||||
|
||||
FF_C_PRINTF(2, 3)
|
||||
FF_A_PRINTF(2, 3)
|
||||
static inline void ffStrbufInitF(FFstrbuf* strbuf, const char* format, ...) {
|
||||
va_list arguments;
|
||||
va_start(arguments, format);
|
||||
@@ -202,8 +202,8 @@ static inline void ffStrbufInitF(FFstrbuf* strbuf, const char* format, ...) {
|
||||
va_end(arguments);
|
||||
}
|
||||
|
||||
FF_C_PRINTF(1, 2)
|
||||
FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateF(const char* format, ...) {
|
||||
FF_A_PRINTF(1, 2)
|
||||
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateF(const char* format, ...) {
|
||||
FFstrbuf strbuf;
|
||||
|
||||
va_list arguments;
|
||||
@@ -227,7 +227,7 @@ static inline void ffStrbufDestroy(FFstrbuf* strbuf) {
|
||||
ffStrbufInit(strbuf);
|
||||
}
|
||||
|
||||
FF_C_NODISCARD static inline uint32_t ffStrbufGetFree(const FFstrbuf* strbuf) {
|
||||
FF_A_NODISCARD static inline uint32_t ffStrbufGetFree(const FFstrbuf* strbuf) {
|
||||
assert(strbuf != NULL);
|
||||
if (strbuf->allocated == 0) {
|
||||
return 0;
|
||||
@@ -283,7 +283,7 @@ static inline void ffStrbufInit(FFstrbuf* strbuf) {
|
||||
strbuf->chars = CHAR_NULL_PTR;
|
||||
}
|
||||
|
||||
FF_C_NODISCARD static inline FFstrbuf ffStrbufCreate(void) {
|
||||
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreate(void) {
|
||||
FFstrbuf strbuf;
|
||||
ffStrbufInit(&strbuf);
|
||||
return strbuf;
|
||||
@@ -300,7 +300,7 @@ static inline void ffStrbufInitStatic(FFstrbuf* strbuf, const char* str) {
|
||||
strbuf->chars = (char*) str;
|
||||
}
|
||||
|
||||
FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateStatic(const char* str) {
|
||||
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateStatic(const char* str) {
|
||||
FFstrbuf strbuf;
|
||||
ffStrbufInitStatic(&strbuf, str);
|
||||
return strbuf;
|
||||
@@ -323,7 +323,7 @@ static inline void ffStrbufInitNS(FFstrbuf* strbuf, uint32_t length, const char*
|
||||
ffStrbufAppendNS(strbuf, length, str);
|
||||
}
|
||||
|
||||
FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateNS(uint32_t length, const char* str) {
|
||||
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateNS(uint32_t length, const char* str) {
|
||||
FFstrbuf strbuf;
|
||||
ffStrbufInitNS(&strbuf, length, str);
|
||||
return strbuf;
|
||||
@@ -339,7 +339,7 @@ static inline void ffStrbufInitS(FFstrbuf* strbuf, const char* str) {
|
||||
ffStrbufAppendS(strbuf, str);
|
||||
}
|
||||
|
||||
FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateS(const char* str) {
|
||||
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateS(const char* str) {
|
||||
FFstrbuf strbuf;
|
||||
ffStrbufInitS(&strbuf, str);
|
||||
return strbuf;
|
||||
@@ -367,72 +367,72 @@ static inline void ffStrbufPrependS(FFstrbuf* strbuf, const char* value) {
|
||||
ffStrbufPrependNS(strbuf, (uint32_t) strlen(value), value);
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD int ffStrbufComp(const FFstrbuf* strbuf, const FFstrbuf* comp) {
|
||||
static inline FF_A_NODISCARD int ffStrbufComp(const FFstrbuf* strbuf, const FFstrbuf* comp) {
|
||||
uint32_t length = strbuf->length > comp->length ? comp->length : strbuf->length;
|
||||
return memcmp(strbuf->chars, comp->chars, length + 1);
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufEqual(const FFstrbuf* strbuf, const FFstrbuf* comp) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufEqual(const FFstrbuf* strbuf, const FFstrbuf* comp) {
|
||||
return ffStrbufComp(strbuf, comp) == 0;
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD int ffStrbufCompS(const FFstrbuf* strbuf, const char* comp) {
|
||||
static inline FF_A_NODISCARD int ffStrbufCompS(const FFstrbuf* strbuf, const char* comp) {
|
||||
return strcmp(strbuf->chars, comp);
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufEqualS(const FFstrbuf* strbuf, const char* comp) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufEqualS(const FFstrbuf* strbuf, const char* comp) {
|
||||
return ffStrbufCompS(strbuf, comp) == 0;
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD int ffStrbufIgnCaseCompS(const FFstrbuf* strbuf, const char* comp) {
|
||||
static inline FF_A_NODISCARD int ffStrbufIgnCaseCompS(const FFstrbuf* strbuf, const char* comp) {
|
||||
return strcasecmp(strbuf->chars, comp);
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufIgnCaseEqualS(const FFstrbuf* strbuf, const char* comp) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufIgnCaseEqualS(const FFstrbuf* strbuf, const char* comp) {
|
||||
return ffStrbufIgnCaseCompS(strbuf, comp) == 0;
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD int ffStrbufIgnCaseComp(const FFstrbuf* strbuf, const FFstrbuf* comp) {
|
||||
static inline FF_A_NODISCARD int ffStrbufIgnCaseComp(const FFstrbuf* strbuf, const FFstrbuf* comp) {
|
||||
return ffStrbufIgnCaseCompS(strbuf, comp->chars);
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufIgnCaseEqual(const FFstrbuf* strbuf, const FFstrbuf* comp) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufIgnCaseEqual(const FFstrbuf* strbuf, const FFstrbuf* comp) {
|
||||
return ffStrbufIgnCaseComp(strbuf, comp) == 0;
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufContainC(const FFstrbuf* strbuf, char c) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufContainC(const FFstrbuf* strbuf, char c) {
|
||||
return memchr(strbuf->chars, c, strbuf->length) != NULL;
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufContainS(const FFstrbuf* strbuf, const char* str) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufContainS(const FFstrbuf* strbuf, const char* str) {
|
||||
return strstr(strbuf->chars, str) != NULL;
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufContain(const FFstrbuf* strbuf, const FFstrbuf* str) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufContain(const FFstrbuf* strbuf, const FFstrbuf* str) {
|
||||
return ffStrbufContainS(strbuf, str->chars);
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufContainIgnCaseS(const FFstrbuf* strbuf, const char* str) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufContainIgnCaseS(const FFstrbuf* strbuf, const char* str) {
|
||||
return strcasestr(strbuf->chars, str) != NULL;
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufContainIgnCase(const FFstrbuf* strbuf, const FFstrbuf* str) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufContainIgnCase(const FFstrbuf* strbuf, const FFstrbuf* str) {
|
||||
return ffStrbufContainIgnCaseS(strbuf, str->chars);
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD uint32_t ffStrbufFirstIndexC(const FFstrbuf* strbuf, char c) {
|
||||
static inline FF_A_NODISCARD uint32_t ffStrbufFirstIndexC(const FFstrbuf* strbuf, char c) {
|
||||
return ffStrbufNextIndexC(strbuf, 0, c);
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD uint32_t ffStrbufFirstIndex(const FFstrbuf* strbuf, const FFstrbuf* searched) {
|
||||
static inline FF_A_NODISCARD uint32_t ffStrbufFirstIndex(const FFstrbuf* strbuf, const FFstrbuf* searched) {
|
||||
return ffStrbufNextIndexS(strbuf, 0, searched->chars);
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD uint32_t ffStrbufFirstIndexS(const FFstrbuf* strbuf, const char* str) {
|
||||
static inline FF_A_NODISCARD uint32_t ffStrbufFirstIndexS(const FFstrbuf* strbuf, const char* str) {
|
||||
return ffStrbufNextIndexS(strbuf, 0, str);
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf, char c) {
|
||||
static inline FF_A_NODISCARD uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf, char c) {
|
||||
if (strbuf->length == 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -448,11 +448,11 @@ static inline bool ffStrbufSubstrBeforeLastC(FFstrbuf* strbuf, char c) {
|
||||
return ffStrbufSubstrBefore(strbuf, ffStrbufLastIndexC(strbuf, c));
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufStartsWithC(const FFstrbuf* strbuf, char c) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufStartsWithC(const FFstrbuf* strbuf, char c) {
|
||||
return strbuf->chars[0] == c;
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufStartsWithSN(const FFstrbuf* strbuf, const char* start, uint32_t length) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufStartsWithSN(const FFstrbuf* strbuf, const char* start, uint32_t length) {
|
||||
if (length > strbuf->length) {
|
||||
return false;
|
||||
}
|
||||
@@ -460,34 +460,34 @@ static inline FF_C_NODISCARD bool ffStrbufStartsWithSN(const FFstrbuf* strbuf, c
|
||||
return memcmp(strbuf->chars, start, length) == 0;
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufStartsWithS(const FFstrbuf* strbuf, const char* start) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufStartsWithS(const FFstrbuf* strbuf, const char* start) {
|
||||
return ffStrbufStartsWithSN(strbuf, start, (uint32_t) strlen(start));
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufStartsWith(const FFstrbuf* strbuf, const FFstrbuf* start) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufStartsWith(const FFstrbuf* strbuf, const FFstrbuf* start) {
|
||||
return ffStrbufStartsWithSN(strbuf, start->chars, start->length);
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufStartsWithIgnCaseNS(const FFstrbuf* strbuf, uint32_t length, const char* start) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufStartsWithIgnCaseNS(const FFstrbuf* strbuf, uint32_t length, const char* start) {
|
||||
if (length > strbuf->length) {
|
||||
return false;
|
||||
}
|
||||
return strncasecmp(strbuf->chars, start, length) == 0;
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufStartsWithIgnCaseS(const FFstrbuf* strbuf, const char* start) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufStartsWithIgnCaseS(const FFstrbuf* strbuf, const char* start) {
|
||||
return ffStrbufStartsWithIgnCaseNS(strbuf, (uint32_t) strlen(start), start);
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufStartsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* start) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufStartsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* start) {
|
||||
return ffStrbufStartsWithIgnCaseNS(strbuf, start->length, start->chars);
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufEndsWithC(const FFstrbuf* strbuf, char c) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufEndsWithC(const FFstrbuf* strbuf, char c) {
|
||||
return strbuf->length == 0 ? false : strbuf->chars[strbuf->length - 1] == c;
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufEndsWithNS(const FFstrbuf* strbuf, uint32_t endLength, const char* end) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufEndsWithNS(const FFstrbuf* strbuf, uint32_t endLength, const char* end) {
|
||||
if (endLength > strbuf->length) {
|
||||
return false;
|
||||
}
|
||||
@@ -495,30 +495,30 @@ static inline FF_C_NODISCARD bool ffStrbufEndsWithNS(const FFstrbuf* strbuf, uin
|
||||
return memcmp(strbuf->chars + strbuf->length - endLength, end, endLength) == 0;
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufEndsWithS(const FFstrbuf* strbuf, const char* end) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufEndsWithS(const FFstrbuf* strbuf, const char* end) {
|
||||
return ffStrbufEndsWithNS(strbuf, (uint32_t) strlen(end), end);
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufEndsWithFn(const FFstrbuf* strbuf, int (*const fn)(int)) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufEndsWithFn(const FFstrbuf* strbuf, int (*const fn)(int)) {
|
||||
return strbuf->length == 0 ? false : fn(strbuf->chars[strbuf->length - 1]);
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufEndsWith(const FFstrbuf* strbuf, const FFstrbuf* end) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufEndsWith(const FFstrbuf* strbuf, const FFstrbuf* end) {
|
||||
return ffStrbufEndsWithNS(strbuf, end->length, end->chars);
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufEndsWithIgnCaseNS(const FFstrbuf* strbuf, uint32_t endLength, const char* end) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufEndsWithIgnCaseNS(const FFstrbuf* strbuf, uint32_t endLength, const char* end) {
|
||||
if (endLength > strbuf->length) {
|
||||
return false;
|
||||
}
|
||||
return strcasecmp(strbuf->chars + strbuf->length - endLength, end) == 0;
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufEndsWithIgnCaseS(const FFstrbuf* strbuf, const char* end) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufEndsWithIgnCaseS(const FFstrbuf* strbuf, const char* end) {
|
||||
return ffStrbufEndsWithIgnCaseNS(strbuf, (uint32_t) strlen(end), end);
|
||||
}
|
||||
|
||||
static inline FF_C_NODISCARD bool ffStrbufEndsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* end) {
|
||||
static inline FF_A_NODISCARD bool ffStrbufEndsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* end) {
|
||||
return ffStrbufEndsWithIgnCaseNS(strbuf, end->length, end->chars);
|
||||
}
|
||||
|
||||
@@ -567,4 +567,4 @@ static inline bool ffStrbufSeparatedContainIgnCase(const FFstrbuf* strbuf, const
|
||||
// Returns true if the strbuf is modified
|
||||
bool ffStrbufDecodeHexEscapeSequences(FFstrbuf* strbuf);
|
||||
|
||||
#define FF_STRBUF_AUTO_DESTROY FFstrbuf __attribute__((__cleanup__(ffStrbufDestroy)))
|
||||
#define FF_STRBUF_AUTO_DESTROY FFstrbuf FF_A_CLEANUP(ffStrbufDestroy)
|
||||
|
||||
@@ -28,7 +28,7 @@ static inline void cfReleaseWrapper(void* type) {
|
||||
}
|
||||
}
|
||||
|
||||
#define FF_CFTYPE_AUTO_RELEASE __attribute__((__cleanup__(cfReleaseWrapper)))
|
||||
#define FF_CFTYPE_AUTO_RELEASE FF_A_CLEANUP(cfReleaseWrapper)
|
||||
|
||||
static inline void wrapIoObjectRelease(io_object_t* service) {
|
||||
assert(service);
|
||||
@@ -36,4 +36,4 @@ static inline void wrapIoObjectRelease(io_object_t* service) {
|
||||
IOObjectRelease(*service);
|
||||
}
|
||||
}
|
||||
#define FF_IOOBJECT_AUTO_RELEASE __attribute__((__cleanup__(wrapIoObjectRelease)))
|
||||
#define FF_IOOBJECT_AUTO_RELEASE FF_A_CLEANUP(wrapIoObjectRelease)
|
||||
|
||||
@@ -10,7 +10,7 @@ typedef struct FFArgBuffer {
|
||||
uint32_t length;
|
||||
} FFArgBuffer;
|
||||
|
||||
typedef enum __attribute__((__packed__)) FFArgType {
|
||||
typedef enum FF_A_PACKED FFArgType {
|
||||
FF_ARG_TYPE_NULL = 0,
|
||||
FF_ARG_TYPE_UINT,
|
||||
FF_ARG_TYPE_UINT64,
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define __attribute__(x)
|
||||
#endif
|
||||
|
||||
#define FF_A_FALLTHROUGH __attribute__((__fallthrough__))
|
||||
#define FF_A_DEPRECATED __attribute__((__deprecated__))
|
||||
#define FF_A_CLEANUP(func) __attribute__((__cleanup__(func)))
|
||||
#define FF_A_NODISCARD __attribute__((__warn_unused_result__))
|
||||
#define FF_A_PRINTF(formatStrIndex, argsStartIndex) __attribute__((__format__(printf, formatStrIndex, argsStartIndex)))
|
||||
#define FF_A_SCANF(formatStrIndex, argsStartIndex) __attribute__((__format__(scanf, formatStrIndex, argsStartIndex)))
|
||||
#define FF_A_NONNULL(argIndex, ...) __attribute__((__nonnull__(argIndex, ##__VA_ARGS__)))
|
||||
#define FF_A_RETURNS_NONNULL __attribute__((__returns_nonnull__))
|
||||
#define FF_A_UNUSED __attribute__((__unused__))
|
||||
#define FF_A_PACKED __attribute__((__packed__))
|
||||
#define FF_A_WEAK_IMPORT __attribute__((__weak_import__))
|
||||
+1
-1
@@ -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 __attribute__((__cleanup__(ffDBusDestroyData)))
|
||||
# define FF_DBUS_AUTO_DESTROY_DATA FF_A_CLEANUP(ffDBusDestroyData)
|
||||
|
||||
#endif // FF_HAVE_DBUS
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "common/FFstrbuf.h"
|
||||
|
||||
typedef enum __attribute__((__packed__)) FFDataResultDocType {
|
||||
typedef enum FF_A_PACKED FFDataResultDocType {
|
||||
FF_RESULT_DOC_TYPE_DEFAULT = 0,
|
||||
FF_RESULT_DOC_TYPE_JSON,
|
||||
FF_RESULT_DOC_TYPE_CONFIG,
|
||||
|
||||
@@ -79,7 +79,7 @@ void ffPrepareCommandOption(FFdata* data) {
|
||||
case 'D':
|
||||
case 'd':
|
||||
FF_IF_MODULE_MATCH(FF_DISKIO_MODULE_NAME) {
|
||||
__attribute__((__cleanup__(ffDestroyDiskIOOptions))) FFDiskIOOptions options;
|
||||
FF_A_CLEANUP(ffDestroyDiskIOOptions) FFDiskIOOptions options;
|
||||
ffInitDiskIOOptions(&options);
|
||||
ffPrepareDiskIO(&options);
|
||||
}
|
||||
@@ -88,7 +88,7 @@ void ffPrepareCommandOption(FFdata* data) {
|
||||
case 'N':
|
||||
case 'n':
|
||||
FF_IF_MODULE_MATCH(FF_NETIO_MODULE_NAME) {
|
||||
__attribute__((__cleanup__(ffDestroyNetIOOptions))) FFNetIOOptions options;
|
||||
FF_A_CLEANUP(ffDestroyNetIOOptions) FFNetIOOptions options;
|
||||
ffInitNetIOOptions(&options);
|
||||
ffPrepareNetIO(&options);
|
||||
}
|
||||
@@ -97,7 +97,7 @@ void ffPrepareCommandOption(FFdata* data) {
|
||||
case 'P':
|
||||
case 'p':
|
||||
FF_IF_MODULE_MATCH(FF_PUBLICIP_MODULE_NAME) {
|
||||
__attribute__((__cleanup__(ffDestroyPublicIpOptions))) FFPublicIPOptions options;
|
||||
FF_A_CLEANUP(ffDestroyPublicIpOptions) FFPublicIPOptions options;
|
||||
ffInitPublicIpOptions(&options);
|
||||
ffPreparePublicIp(&options);
|
||||
}
|
||||
@@ -106,7 +106,7 @@ void ffPrepareCommandOption(FFdata* data) {
|
||||
case 'W':
|
||||
case 'w':
|
||||
FF_IF_MODULE_MATCH(FF_WEATHER_MODULE_NAME) {
|
||||
__attribute__((__cleanup__(ffDestroyWeatherOptions))) FFWeatherOptions options;
|
||||
FF_A_CLEANUP(ffDestroyWeatherOptions) FFWeatherOptions options;
|
||||
ffInitWeatherOptions(&options);
|
||||
ffPrepareWeather(&options);
|
||||
}
|
||||
|
||||
@@ -86,12 +86,12 @@ static void resetConsole(void) {
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
BOOL WINAPI consoleHandler(FF_MAYBE_UNUSED DWORD signal) {
|
||||
BOOL WINAPI consoleHandler(FF_A_UNUSED DWORD signal) {
|
||||
resetConsole();
|
||||
exit(0);
|
||||
}
|
||||
#else
|
||||
static void exitSignalHandler(FF_MAYBE_UNUSED int signal) {
|
||||
static void exitSignalHandler(FF_A_UNUSED int signal) {
|
||||
resetConsole();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) {
|
||||
case 'c':
|
||||
case 'C': {
|
||||
if (ffStrEqualsIgnCase(type, FF_COMMAND_MODULE_NAME)) {
|
||||
__attribute__((__cleanup__(ffDestroyCommandOptions))) FFCommandOptions options;
|
||||
FF_A_CLEANUP(ffDestroyCommandOptions) FFCommandOptions options;
|
||||
ffInitCommandOptions(&options);
|
||||
if (module) {
|
||||
ffCommandModuleInfo.parseJsonObject(&options, module);
|
||||
@@ -155,7 +155,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) {
|
||||
case 'd':
|
||||
case 'D': {
|
||||
if (ffStrEqualsIgnCase(type, FF_DISKIO_MODULE_NAME)) {
|
||||
__attribute__((__cleanup__(ffDestroyDiskIOOptions))) FFDiskIOOptions options;
|
||||
FF_A_CLEANUP(ffDestroyDiskIOOptions) FFDiskIOOptions options;
|
||||
ffInitDiskIOOptions(&options);
|
||||
if (module) {
|
||||
ffDiskIOModuleInfo.parseJsonObject(&options, module);
|
||||
@@ -167,7 +167,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) {
|
||||
case 'n':
|
||||
case 'N': {
|
||||
if (ffStrEqualsIgnCase(type, FF_NETIO_MODULE_NAME)) {
|
||||
__attribute__((__cleanup__(ffDestroyNetIOOptions))) FFNetIOOptions options;
|
||||
FF_A_CLEANUP(ffDestroyNetIOOptions) FFNetIOOptions options;
|
||||
ffInitNetIOOptions(&options);
|
||||
if (module) {
|
||||
ffNetIOModuleInfo.parseJsonObject(&options, module);
|
||||
@@ -179,7 +179,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) {
|
||||
case 'p':
|
||||
case 'P': {
|
||||
if (ffStrEqualsIgnCase(type, FF_PUBLICIP_MODULE_NAME)) {
|
||||
__attribute__((__cleanup__(ffDestroyPublicIpOptions))) FFPublicIPOptions options;
|
||||
FF_A_CLEANUP(ffDestroyPublicIpOptions) FFPublicIPOptions options;
|
||||
ffInitPublicIpOptions(&options);
|
||||
if (module) {
|
||||
ffPublicIPModuleInfo.parseJsonObject(&options, module);
|
||||
@@ -191,7 +191,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) {
|
||||
case 'w':
|
||||
case 'W': {
|
||||
if (ffStrEqualsIgnCase(type, FF_WEATHER_MODULE_NAME)) {
|
||||
__attribute__((__cleanup__(ffDestroyWeatherOptions))) FFWeatherOptions options;
|
||||
FF_A_CLEANUP(ffDestroyWeatherOptions) FFWeatherOptions options;
|
||||
ffInitWeatherOptions(&options);
|
||||
if (module) {
|
||||
ffWeatherModuleInfo.parseJsonObject(&options, module);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <sys/module.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
typedef struct __attribute__((__packed__)) FFNbsdModList {
|
||||
typedef struct FF_A_PACKED FFNbsdModList {
|
||||
int len;
|
||||
modstat_t mods[];
|
||||
} FFNbsdModList;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "common/kmod.h"
|
||||
|
||||
bool ffKmodLoaded(FF_MAYBE_UNUSED const char* modName) {
|
||||
bool ffKmodLoaded(FF_A_UNUSED const char* modName) {
|
||||
return true; // Don't generate kernel module related errors
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ void* ffLibraryLoad(const char* path, int maxVersion, ...) {
|
||||
|
||||
#if _WIN32
|
||||
|
||||
void* dlopen(const char* path, FF_MAYBE_UNUSED int mode) {
|
||||
void* dlopen(const char* path, FF_A_UNUSED int mode) {
|
||||
wchar_t pathW[MAX_PATH + 1];
|
||||
ULONG pathWBytes = 0;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) {
|
||||
|
||||
uint32_t pid = ffNetifGetNetlinkPortId(sock_fd);
|
||||
|
||||
struct __attribute__((__packed__)) {
|
||||
struct FF_A_PACKED {
|
||||
struct nlmsghdr nlh;
|
||||
struct rtmsg rtm;
|
||||
struct rtattr rta;
|
||||
@@ -97,7 +97,7 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) {
|
||||
|
||||
uint8_t buffer[1024 * 16]; // 16 KB buffer should be sufficient
|
||||
uint32_t minMetric = UINT32_MAX;
|
||||
FF_MAYBE_UNUSED int routeCount = 0;
|
||||
FF_A_UNUSED int routeCount = 0;
|
||||
|
||||
while (true) {
|
||||
ssize_t received = recvfrom(sock_fd, buffer, sizeof(buffer), 0, (struct sockaddr*) &src_addr, &src_addr_len);
|
||||
@@ -254,7 +254,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) {
|
||||
|
||||
uint32_t pid = ffNetifGetNetlinkPortId(sock_fd);
|
||||
|
||||
struct __attribute__((__packed__)) {
|
||||
struct FF_A_PACKED {
|
||||
struct nlmsghdr nlh;
|
||||
struct rtmsg rtm;
|
||||
struct rtattr rta;
|
||||
@@ -307,7 +307,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) {
|
||||
|
||||
uint8_t buffer[1024 * 16]; // 16 KB buffer should be sufficient
|
||||
uint32_t minMetric = UINT32_MAX;
|
||||
FF_MAYBE_UNUSED int routeCount = 0;
|
||||
FF_A_UNUSED int routeCount = 0;
|
||||
|
||||
while (true) {
|
||||
ssize_t received = recvfrom(sock_fd, buffer, sizeof(buffer), 0, (struct sockaddr*) &src_addr, &src_addr_len);
|
||||
@@ -382,7 +382,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) {
|
||||
switch (rta->rta_type) {
|
||||
case RTA_DST:
|
||||
if (RTA_PAYLOAD(rta) >= sizeof(struct in6_addr)) {
|
||||
FF_MAYBE_UNUSED char str[INET6_ADDRSTRLEN];
|
||||
FF_A_UNUSED char str[INET6_ADDRSTRLEN];
|
||||
FF_DEBUG("Unexpected RTA_DST: %s", inet_ntop(AF_INET6, RTA_DATA(rta), str, sizeof(str)));
|
||||
goto next;
|
||||
}
|
||||
@@ -399,7 +399,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) {
|
||||
if (IN6_IS_ADDR_UNSPECIFIED(gw)) {
|
||||
goto next;
|
||||
}
|
||||
FF_MAYBE_UNUSED char str[INET6_ADDRSTRLEN];
|
||||
FF_A_UNUSED char str[INET6_ADDRSTRLEN];
|
||||
FF_DEBUG("Found gateway: %s", inet_ntop(AF_INET6, gw, str, sizeof(str)));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -254,7 +254,7 @@ static const char* initNetworkingState(FFNetworkingState* state, const char* hos
|
||||
|
||||
if (state->timeout > 0) {
|
||||
FF_DEBUG("Setting connection timeout: %u ms", state->timeout);
|
||||
FF_MAYBE_UNUSED uint32_t sec = state->timeout / 1000;
|
||||
FF_A_UNUSED uint32_t sec = state->timeout / 1000;
|
||||
if (sec == 0) {
|
||||
sec = 1;
|
||||
}
|
||||
@@ -410,7 +410,7 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf
|
||||
}
|
||||
|
||||
FF_DEBUG("Starting data reception");
|
||||
FF_MAYBE_UNUSED int recvCount = 0;
|
||||
FF_A_UNUSED int recvCount = 0;
|
||||
uint32_t contentLength = 0;
|
||||
uint32_t headerEnd = 0;
|
||||
|
||||
|
||||
@@ -275,7 +275,7 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf
|
||||
}
|
||||
|
||||
FF_DEBUG("Starting data reception");
|
||||
FF_MAYBE_UNUSED int recvCount = 0;
|
||||
FF_A_UNUSED int recvCount = 0;
|
||||
uint32_t contentLength = 0;
|
||||
uint32_t headerEnd = 0;
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ static bool parseSmbiosTable(const uint8_t* data, uint32_t length) {
|
||||
const FFSmbiosHeader* endOfTable = NULL;
|
||||
|
||||
FF_DEBUG("Parsing SMBIOS table structures with length %u bytes", length);
|
||||
FF_MAYBE_UNUSED int structureCount = 0, totalCount = 0;
|
||||
FF_A_UNUSED int structureCount = 0, totalCount = 0;
|
||||
for (
|
||||
const FFSmbiosHeader* header = (const FFSmbiosHeader*) data;
|
||||
(const uint8_t*) header + sizeof(FFSmbiosHeader) < (const uint8_t*) data + length;
|
||||
@@ -194,7 +194,7 @@ typedef struct FFSmbios20EntryPoint {
|
||||
uint32_t StructureTableAddress;
|
||||
uint16_t NumberOfSmbiosStructures;
|
||||
uint8_t SmbiosBcdRevision;
|
||||
} __attribute__((__packed__)) FFSmbios20EntryPoint;
|
||||
} FF_A_PACKED FFSmbios20EntryPoint;
|
||||
static_assert(offsetof(FFSmbios20EntryPoint, SmbiosBcdRevision) == 0x1E,
|
||||
"FFSmbios20EntryPoint: Wrong struct alignment");
|
||||
|
||||
@@ -209,7 +209,7 @@ typedef struct FFSmbios30EntryPoint {
|
||||
uint8_t Reversed;
|
||||
uint32_t StructureTableMaximumSize;
|
||||
uint64_t StructureTableAddress;
|
||||
} __attribute__((__packed__)) FFSmbios30EntryPoint;
|
||||
} FF_A_PACKED FFSmbios30EntryPoint;
|
||||
|
||||
static_assert(offsetof(FFSmbios30EntryPoint, StructureTableAddress) == 0x10,
|
||||
"FFSmbios30EntryPoint: Wrong struct alignment");
|
||||
|
||||
+26
-26
@@ -49,7 +49,7 @@ static inline bool ffIsValidNativeFD(FFNativeFD fd) {
|
||||
#endif
|
||||
}
|
||||
|
||||
FF_C_NONNULL(1)
|
||||
FF_A_NONNULL(1)
|
||||
static inline bool wrapClose(FFNativeFD* pfd) {
|
||||
assert(pfd);
|
||||
|
||||
@@ -65,7 +65,7 @@ static inline bool wrapClose(FFNativeFD* pfd) {
|
||||
|
||||
return true;
|
||||
}
|
||||
#define FF_AUTO_CLOSE_FD __attribute__((__cleanup__(wrapClose)))
|
||||
#define FF_AUTO_CLOSE_FD FF_A_CLEANUP(wrapClose)
|
||||
|
||||
static inline FFNativeFD FFUnixFD2NativeFD(int unixfd) {
|
||||
#ifndef _WIN32
|
||||
@@ -75,7 +75,7 @@ static inline FFNativeFD FFUnixFD2NativeFD(int unixfd) {
|
||||
#endif
|
||||
}
|
||||
|
||||
FF_C_NONNULL(3)
|
||||
FF_A_NONNULL(3)
|
||||
static inline bool ffWriteFDData(FFNativeFD fd, size_t dataSize, const void* data) {
|
||||
#ifndef _WIN32
|
||||
return write(fd, data, dataSize) != -1;
|
||||
@@ -85,20 +85,20 @@ static inline bool ffWriteFDData(FFNativeFD fd, size_t dataSize, const void* dat
|
||||
#endif
|
||||
}
|
||||
|
||||
FF_C_NONNULL(2)
|
||||
FF_A_NONNULL(2)
|
||||
static inline bool ffWriteFDBuffer(FFNativeFD fd, const FFstrbuf* content) {
|
||||
return ffWriteFDData(fd, content->length, content->chars);
|
||||
}
|
||||
|
||||
FF_C_NONNULL(1, 3)
|
||||
FF_A_NONNULL(1, 3)
|
||||
bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data);
|
||||
|
||||
FF_C_NONNULL(1, 2)
|
||||
FF_A_NONNULL(1, 2)
|
||||
static inline bool ffWriteFileBuffer(const char* fileName, const FFstrbuf* buffer) {
|
||||
return ffWriteFileData(fileName, buffer->length, buffer->chars);
|
||||
}
|
||||
|
||||
FF_C_NONNULL(3)
|
||||
FF_A_NONNULL(3)
|
||||
static inline ssize_t ffReadFDData(FFNativeFD fd, size_t dataSize, void* data) {
|
||||
#ifndef _WIN32
|
||||
return read(fd, data, dataSize);
|
||||
@@ -112,10 +112,10 @@ static inline ssize_t ffReadFDData(FFNativeFD fd, size_t dataSize, void* data) {
|
||||
#endif
|
||||
}
|
||||
|
||||
FF_C_NONNULL(2)
|
||||
FF_A_NONNULL(2)
|
||||
bool ffAppendFDBuffer(FFNativeFD fd, FFstrbuf* buffer);
|
||||
|
||||
FF_C_NONNULL(1, 3)
|
||||
FF_A_NONNULL(1, 3)
|
||||
static inline ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data) {
|
||||
FFNativeFD FF_AUTO_CLOSE_FD fd =
|
||||
#ifndef _WIN32
|
||||
@@ -131,7 +131,7 @@ static inline ssize_t ffReadFileData(const char* fileName, size_t dataSize, void
|
||||
return ffReadFDData(fd, dataSize, data);
|
||||
}
|
||||
|
||||
FF_C_NONNULL(2, 4)
|
||||
FF_A_NONNULL(2, 4)
|
||||
static inline ssize_t ffReadFileDataRelative(FFNativeFD dfd, const char* fileName, size_t dataSize, void* data) {
|
||||
FFNativeFD FF_AUTO_CLOSE_FD fd = openat(dfd, fileName, O_RDONLY | O_CLOEXEC);
|
||||
if (!ffIsValidNativeFD(fd)) {
|
||||
@@ -141,7 +141,7 @@ static inline ssize_t ffReadFileDataRelative(FFNativeFD dfd, const char* fileNam
|
||||
return ffReadFDData(fd, dataSize, data);
|
||||
}
|
||||
|
||||
FF_C_NONNULL(1, 2)
|
||||
FF_A_NONNULL(1, 2)
|
||||
static inline bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer) {
|
||||
FFNativeFD FF_AUTO_CLOSE_FD fd =
|
||||
#ifndef _WIN32
|
||||
@@ -157,7 +157,7 @@ static inline bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer) {
|
||||
return ffAppendFDBuffer(fd, buffer);
|
||||
}
|
||||
|
||||
FF_C_NONNULL(2, 3)
|
||||
FF_A_NONNULL(2, 3)
|
||||
static inline bool ffAppendFileBufferRelative(FFNativeFD dfd, const char* fileName, FFstrbuf* buffer) {
|
||||
FFNativeFD FF_AUTO_CLOSE_FD fd = openat(dfd, fileName, O_RDONLY | O_CLOEXEC);
|
||||
if (!ffIsValidNativeFD(fd)) {
|
||||
@@ -167,32 +167,32 @@ static inline bool ffAppendFileBufferRelative(FFNativeFD dfd, const char* fileNa
|
||||
return ffAppendFDBuffer(fd, buffer);
|
||||
}
|
||||
|
||||
FF_C_NONNULL(2)
|
||||
FF_A_NONNULL(2)
|
||||
static inline bool ffReadFDBuffer(FFNativeFD fd, FFstrbuf* buffer) {
|
||||
ffStrbufClear(buffer);
|
||||
return ffAppendFDBuffer(fd, buffer);
|
||||
}
|
||||
|
||||
FF_C_NONNULL(1, 2)
|
||||
FF_A_NONNULL(1, 2)
|
||||
static inline bool ffReadFileBuffer(const char* fileName, FFstrbuf* buffer) {
|
||||
ffStrbufClear(buffer);
|
||||
return ffAppendFileBuffer(fileName, buffer);
|
||||
}
|
||||
|
||||
FF_C_NONNULL(2, 3)
|
||||
FF_A_NONNULL(2, 3)
|
||||
static inline bool ffReadFileBufferRelative(FFNativeFD dfd, const char* fileName, FFstrbuf* buffer) {
|
||||
ffStrbufClear(buffer);
|
||||
return ffAppendFileBufferRelative(dfd, fileName, buffer);
|
||||
}
|
||||
|
||||
typedef enum __attribute__((__packed__)) FFPathType {
|
||||
typedef enum FF_A_PACKED FFPathType {
|
||||
FF_PATHTYPE_FILE = 1 << 0,
|
||||
FF_PATHTYPE_DIRECTORY = 1 << 1,
|
||||
FF_PATHTYPE_ANY = FF_PATHTYPE_FILE | FF_PATHTYPE_DIRECTORY,
|
||||
FF_PATHTYPE_FORCE_UNSIGNED = UINT8_MAX,
|
||||
} FFPathType;
|
||||
|
||||
FF_C_NONNULL(1)
|
||||
FF_A_NONNULL(1)
|
||||
static inline bool ffPathExists(const char* path, FFPathType pathType) {
|
||||
#ifdef _WIN32
|
||||
|
||||
@@ -242,13 +242,13 @@ static inline bool ffPathExists(const char* path, FFPathType pathType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FF_C_NONNULL(1, 2)
|
||||
FF_A_NONNULL(1, 2)
|
||||
bool ffPathExpandEnv(const char* in, FFstrbuf* out);
|
||||
|
||||
#define FF_IO_TERM_RESP_WAIT_MS 100 // #554
|
||||
|
||||
FF_C_SCANF(3, 4)
|
||||
FF_C_NONNULL(1, 3)
|
||||
FF_A_SCANF(3, 4)
|
||||
FF_A_NONNULL(1, 3)
|
||||
const char* ffGetTerminalResponse(const char* request, int nParams, const char* format, ...);
|
||||
|
||||
// Not thread safe!
|
||||
@@ -262,11 +262,11 @@ static inline void ffUnsuppressIO(bool* suppressed) {
|
||||
*suppressed = false;
|
||||
}
|
||||
|
||||
#define FF_SUPPRESS_IO() bool __attribute__((__cleanup__(ffUnsuppressIO), __unused__)) io_suppressed__ = ffSuppressIO(true)
|
||||
#define FF_SUPPRESS_IO() bool FF_A_CLEANUP(ffUnsuppressIO) FF_A_UNUSED io_suppressed__ = ffSuppressIO(true)
|
||||
|
||||
void ffListFilesRecursively(const char* path, bool pretty);
|
||||
|
||||
FF_C_NONNULL(1)
|
||||
FF_A_NONNULL(1)
|
||||
static inline bool wrapFclose(FILE** pfile) {
|
||||
assert(pfile);
|
||||
if (!*pfile) {
|
||||
@@ -275,9 +275,9 @@ static inline bool wrapFclose(FILE** pfile) {
|
||||
fclose(*pfile);
|
||||
return true;
|
||||
}
|
||||
#define FF_AUTO_CLOSE_FILE __attribute__((__cleanup__(wrapFclose)))
|
||||
#define FF_AUTO_CLOSE_FILE FF_A_CLEANUP(wrapFclose)
|
||||
|
||||
FF_C_NONNULL(1)
|
||||
FF_A_NONNULL(1)
|
||||
#ifndef _WIN32
|
||||
static inline bool wrapClosedir(DIR** pdir) {
|
||||
assert(pdir);
|
||||
@@ -297,9 +297,9 @@ static inline bool wrapClosedir(HANDLE* pdir) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#define FF_AUTO_CLOSE_DIR __attribute__((__cleanup__(wrapClosedir)))
|
||||
#define FF_AUTO_CLOSE_DIR FF_A_CLEANUP(wrapClosedir)
|
||||
|
||||
FF_C_NONNULL(1, 2, 3)
|
||||
FF_A_NONNULL(1, 2, 3)
|
||||
static inline bool ffSearchUserConfigFile(const FFlist* configDirs, const char* fileSubpath, FFstrbuf* result) {
|
||||
// configDirs is a list of FFstrbufs include the trailing slash
|
||||
FF_LIST_FOR_EACH (FFstrbuf, dir, *configDirs) {
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include "common/FFcheckmacros.h"
|
||||
|
||||
#ifndef FF_DISABLE_DLOPEN
|
||||
|
||||
# if defined(_WIN32)
|
||||
# define FF_DLOPEN_FLAGS 0
|
||||
FF_C_NODISCARD void* dlopen(const char* path, int mode);
|
||||
FF_C_NODISCARD void* dlsym(void* handle, const char* symbol);
|
||||
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>
|
||||
@@ -37,7 +36,7 @@ static inline void ffLibraryUnload(void** handle) {
|
||||
__typeof__(&symbolName) ff##symbolName;
|
||||
|
||||
# define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \
|
||||
void* __attribute__((__cleanup__(ffLibraryUnload))) libraryObjectName = ffLibraryLoad(__VA_ARGS__, NULL); \
|
||||
void* FF_A_CLEANUP(ffLibraryUnload) libraryObjectName = ffLibraryLoad(__VA_ARGS__, NULL); \
|
||||
if (libraryObjectName == NULL) \
|
||||
return returnValue;
|
||||
|
||||
@@ -77,7 +76,7 @@ void* ffLibraryLoad(const char* path, int maxVersion, ...);
|
||||
__typeof__(&symbolName) ff##symbolName;
|
||||
|
||||
# define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \
|
||||
FF_MAYBE_UNUSED void* libraryObjectName = NULL; // Placeholder
|
||||
FF_A_UNUSED void* libraryObjectName = NULL; // Placeholder
|
||||
|
||||
# define FF_LIBRARY_LOAD_MESSAGE(libraryObjectName, libraryFileName, maxVersion, ...) \
|
||||
FF_LIBRARY_LOAD(libraryObjectName, , libraryFileName, maxVersion, ##__VA_ARGS__)
|
||||
@@ -86,13 +85,13 @@ void* ffLibraryLoad(const char* path, int maxVersion, ...);
|
||||
symbolMapping = (__typeof__(&symbolName)) &symbolName;
|
||||
|
||||
# define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \
|
||||
FF_MAYBE_UNUSED __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, 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) \
|
||||
FF_MAYBE_UNUSED __auto_type ff##symbolName = (__typeof__(&symbolName)) &symbolName;
|
||||
FF_A_UNUSED __auto_type ff##symbolName = (__typeof__(&symbolName)) &symbolName;
|
||||
|
||||
# define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \
|
||||
FF_MAYBE_UNUSED __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, "dlsym " #symbolName " failed");
|
||||
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) \
|
||||
FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName).ff##symbolName, symbolName, returnValue);
|
||||
|
||||
@@ -20,7 +20,7 @@ static inline void ffWrapFree(const void* pPtr) {
|
||||
}
|
||||
}
|
||||
|
||||
#define FF_AUTO_FREE __attribute__((__cleanup__(ffWrapFree)))
|
||||
#define FF_AUTO_FREE FF_A_CLEANUP(ffWrapFree)
|
||||
|
||||
// ptr MUST be a malloc'ed pointer
|
||||
static inline size_t ffMallocUsableSize(const void* ptr) {
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
typedef enum __attribute__((__packed__)) FFNetifDefaultRouteResultStatus {
|
||||
typedef enum FF_A_PACKED FFNetifDefaultRouteResultStatus {
|
||||
FF_NETIF_UNINITIALIZED,
|
||||
FF_NETIF_INVALID,
|
||||
FF_NETIF_OK
|
||||
|
||||
+5
-5
@@ -36,7 +36,7 @@ typedef struct FFModuleBaseInfo {
|
||||
FFModuleFormatArgList formatArgs;
|
||||
} FFModuleBaseInfo;
|
||||
|
||||
typedef enum __attribute__((__packed__)) FFModuleKeyType {
|
||||
typedef enum FF_A_PACKED FFModuleKeyType {
|
||||
FF_MODULE_KEY_TYPE_NONE = 0,
|
||||
FF_MODULE_KEY_TYPE_STRING = 1 << 0,
|
||||
FF_MODULE_KEY_TYPE_ICON = 1 << 1,
|
||||
@@ -66,10 +66,10 @@ typedef struct FFKeyValuePair {
|
||||
|
||||
const char* ffOptionTestPrefix(const char* argumentKey, const char* moduleName);
|
||||
void ffOptionParseString(const char* argumentKey, const char* value, FFstrbuf* buffer);
|
||||
FF_C_NODISCARD uint32_t ffOptionParseUInt32(const char* argumentKey, const char* value);
|
||||
FF_C_NODISCARD int32_t ffOptionParseInt32(const char* argumentKey, const char* value);
|
||||
FF_C_NODISCARD int ffOptionParseEnum(const char* argumentKey, const char* requestedKey, FFKeyValuePair pairs[]);
|
||||
FF_C_NODISCARD bool ffOptionParseBoolean(const char* str);
|
||||
FF_A_NODISCARD uint32_t ffOptionParseUInt32(const char* argumentKey, const char* value);
|
||||
FF_A_NODISCARD int32_t ffOptionParseInt32(const char* argumentKey, const char* value);
|
||||
FF_A_NODISCARD int ffOptionParseEnum(const char* argumentKey, const char* requestedKey, FFKeyValuePair pairs[]);
|
||||
FF_A_NODISCARD bool ffOptionParseBoolean(const char* str);
|
||||
void ffOptionParseColorNoClear(const char* value, FFstrbuf* buffer);
|
||||
static inline void ffOptionParseColor(const char* value, FFstrbuf* buffer) {
|
||||
ffStrbufClear(buffer);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "common/parsing.h"
|
||||
#include "common/option.h"
|
||||
|
||||
typedef enum __attribute__((__packed__)) FFPercentageTypeFlags {
|
||||
typedef enum FF_A_PACKED FFPercentageTypeFlags {
|
||||
FF_PERCENTAGE_TYPE_NONE = 0,
|
||||
FF_PERCENTAGE_TYPE_NUM_BIT = 1 << 0,
|
||||
FF_PERCENTAGE_TYPE_BAR_BIT = 1 << 1,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/format.h"
|
||||
|
||||
typedef enum __attribute__((__packed__)) FFPrintType {
|
||||
typedef enum FF_A_PACKED FFPrintType {
|
||||
FF_PRINT_TYPE_DEFAULT = 0,
|
||||
FF_PRINT_TYPE_NO_CUSTOM_KEY = 1 << 0, // key has been formatted outside
|
||||
FF_PRINT_TYPE_NO_CUSTOM_KEY_COLOR = 1 << 1,
|
||||
@@ -16,7 +16,7 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu
|
||||
void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, uint32_t numArgs, const FFformatarg* arguments);
|
||||
#define FF_PRINT_FORMAT_CHECKED(moduleName, moduleIndex, moduleArgs, printType, arguments) \
|
||||
ffPrintFormat((moduleName), (moduleIndex), (moduleArgs), (printType), (sizeof(arguments) / sizeof(*arguments)), (arguments));
|
||||
FF_C_PRINTF(5, 6)
|
||||
FF_A_PRINTF(5, 6)
|
||||
void ffPrintError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, ...);
|
||||
void ffPrintColor(const FFstrbuf* colorValue);
|
||||
void ffPrintCharTimes(char c, uint32_t times);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
typedef enum __attribute__((__packed__)) FFvarianttype {
|
||||
typedef enum FF_A_PACKED FFvarianttype {
|
||||
FF_VARIANT_TYPE_STRING,
|
||||
FF_VARIANT_TYPE_BOOL,
|
||||
FF_VARIANT_TYPE_INT
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ static inline void ffCleanUpSmbiosValue(FFstrbuf* value) {
|
||||
// https://github.com/KunYi/DumpSMBIOS
|
||||
// https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.7.0.pdf
|
||||
|
||||
typedef enum __attribute__((__packed__)) FFSmbiosType // : uint8_t
|
||||
typedef enum FF_A_PACKED FFSmbiosType // : uint8_t
|
||||
{
|
||||
FF_SMBIOS_TYPE_BIOS = 0,
|
||||
FF_SMBIOS_TYPE_SYSTEM_INFO = 1,
|
||||
@@ -79,7 +79,7 @@ typedef struct FFSmbiosHeader {
|
||||
// Unique handle, used to reference this structure from other structures.
|
||||
// Not guaranteed to be consistent across reboots or even multiple reads of the same table.
|
||||
uint16_t Handle;
|
||||
} __attribute__((__packed__)) FFSmbiosHeader;
|
||||
} FF_A_PACKED FFSmbiosHeader;
|
||||
static_assert(sizeof(FFSmbiosHeader) == 4, "FFSmbiosHeader should be 4 bytes");
|
||||
|
||||
static inline const char* ffSmbiosLocateString(const char* start, uint8_t index /* start from 1 */) {
|
||||
|
||||
+5
-6
@@ -1,18 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include "common/FFcheckmacros.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
const char* ffSysctlGetString(int mib1, int mib2, FFstrbuf* result);
|
||||
FF_C_NODISCARD int ffSysctlGetInt(int mib1, int mib2, int defaultValue);
|
||||
FF_C_NODISCARD int64_t ffSysctlGetInt64(int mib1, int mib2, int64_t defaultValue);
|
||||
FF_A_NODISCARD int ffSysctlGetInt(int mib1, int mib2, int defaultValue);
|
||||
FF_A_NODISCARD int64_t ffSysctlGetInt64(int mib1, int mib2, int64_t defaultValue);
|
||||
#else
|
||||
const char* ffSysctlGetString(const char* propName, FFstrbuf* result);
|
||||
FF_C_NODISCARD int ffSysctlGetInt(const char* propName, int defaultValue);
|
||||
FF_C_NODISCARD int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue);
|
||||
FF_A_NODISCARD int ffSysctlGetInt(const char* propName, int defaultValue);
|
||||
FF_A_NODISCARD int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue);
|
||||
#endif
|
||||
FF_C_NODISCARD void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength);
|
||||
FF_A_NODISCARD void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength);
|
||||
|
||||
+3
-3
@@ -87,7 +87,7 @@ static inline FFThreadType ffThreadCreate(void* (*func)(void*), void* data) {
|
||||
static inline void ffThreadDetach(FFThreadType thread) {
|
||||
pthread_detach(thread);
|
||||
}
|
||||
static inline bool ffThreadJoin(FFThreadType thread, FF_MAYBE_UNUSED uint32_t timeout) {
|
||||
static inline bool ffThreadJoin(FFThreadType thread, FF_A_UNUSED uint32_t timeout) {
|
||||
# if HAVE_TIMEDJOIN_NP
|
||||
if (timeout > 0) {
|
||||
struct timespec ts;
|
||||
@@ -109,7 +109,7 @@ static inline bool ffThreadJoin(FFThreadType thread, FF_MAYBE_UNUSED uint32_t ti
|
||||
#else // FF_HAVE_THREADS
|
||||
# define FF_THREAD_MUTEX_INITIALIZER 0
|
||||
typedef char FFThreadMutex;
|
||||
static inline void ffThreadMutexLock(FF_MAYBE_UNUSED FFThreadMutex* mutex) {}
|
||||
static inline void ffThreadMutexUnlock(FF_MAYBE_UNUSED FFThreadMutex* mutex) {}
|
||||
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)
|
||||
#endif // FF_HAVE_THREADS
|
||||
|
||||
@@ -4,8 +4,3 @@ static inline void ffUnused(int dummy, ...) {
|
||||
(void) dummy;
|
||||
}
|
||||
#define FF_UNUSED(...) ffUnused(0, __VA_ARGS__);
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
# define FF_MAYBE_UNUSED __attribute__((__unused__))
|
||||
#else
|
||||
# define FF_MAYBE_UNUSED
|
||||
#endif
|
||||
|
||||
@@ -13,7 +13,7 @@ static inline void ffReleaseComObject(void* ppUnknown) {
|
||||
}
|
||||
}
|
||||
|
||||
# define FF_AUTO_RELEASE_COM_OBJECT __attribute__((__cleanup__(ffReleaseComObject)))
|
||||
# define FF_AUTO_RELEASE_COM_OBJECT FF_A_CLEANUP(ffReleaseComObject)
|
||||
|
||||
#else
|
||||
// Win32 COM headers requires C++ compiler
|
||||
|
||||
@@ -21,7 +21,7 @@ static const char* parseTermuxApi(FFBatteryOptions* options, FFlist* results) {
|
||||
return "Starting `" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` failed";
|
||||
}
|
||||
|
||||
yyjson_doc* __attribute__((__cleanup__(wrapYyjsonFree))) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, NULL, NULL);
|
||||
yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, NULL, NULL);
|
||||
if (!doc) {
|
||||
return "Failed to parse battery info";
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <sys/fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* results) {
|
||||
const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* results) {
|
||||
// https://www.freebsd.org/cgi/man.cgi?acpi_battery(4)
|
||||
// https://gitlab.xfce.org/panel-plugins/xfce4-battery-plugin/-/blob/master/panel-plugin/libacpi.c
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ const char* parseBattery(int dfd, const char* battId, FFlist* results) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* results) {
|
||||
const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* results) {
|
||||
FF_AUTO_CLOSE_DIR DIR* dir = opendir("/dev/power/acpi_battery/");
|
||||
if (!dir) {
|
||||
return "opendir(/dev/power/acpi_battery) failed";
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* results) {
|
||||
const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* results) {
|
||||
FF_AUTO_CLOSE_FD int fd = open(_PATH_SYSMON, O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
return "open(_PATH_SYSMON, O_RDONLY | O_CLOEXEC) failed";
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* result) {
|
||||
const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* result) {
|
||||
FF_AUTO_CLOSE_FD int devfd = open("/dev/apm", O_RDONLY | O_CLOEXEC);
|
||||
|
||||
if (devfd < 0) {
|
||||
|
||||
@@ -186,7 +186,7 @@ typedef struct FFSmbiosPortableBattery {
|
||||
uint8_t SbdsDeviceChemistry; // string
|
||||
uint8_t DesignCapacityMultiplier; // varies
|
||||
uint16_t OEMSpecific; // varies
|
||||
} __attribute__((__packed__)) FFSmbiosPortableBattery;
|
||||
} FF_A_PACKED FFSmbiosPortableBattery;
|
||||
|
||||
static_assert(offsetof(FFSmbiosPortableBattery, OEMSpecific) == 0x16,
|
||||
"FFSmbiosPortableBattery: Wrong struct alignment");
|
||||
@@ -256,7 +256,7 @@ static const char* detectBySmbios(FFBatteryResult* battery) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char* detectWithNtApi(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* results) {
|
||||
static const char* detectWithNtApi(FF_A_UNUSED FFBatteryOptions* options, FFlist* results) {
|
||||
SYSTEM_BATTERY_STATE info;
|
||||
if (NT_SUCCESS(NtPowerInformation(SystemBatteryState, NULL, 0, &info, sizeof(info))) && info.BatteryPresent) {
|
||||
FFBatteryResult* battery = (FFBatteryResult*) ffListAdd(results);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "bios.h"
|
||||
|
||||
const char* ffDetectBios(FF_MAYBE_UNUSED FFBiosResult* bios) {
|
||||
const char* ffDetectBios(FF_A_UNUSED FFBiosResult* bios) {
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ typedef struct FFSmbiosBios {
|
||||
|
||||
// 3.1+
|
||||
uint16_t ExtendedBiosRomSize; // bit field
|
||||
} __attribute__((__packed__)) FFSmbiosBios;
|
||||
} FF_A_PACKED FFSmbiosBios;
|
||||
|
||||
static_assert(offsetof(FFSmbiosBios, ExtendedBiosRomSize) == 0x18,
|
||||
"FFSmbiosBios: Wrong struct alignment");
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#define L2CAP_SOCKET_CHECKED
|
||||
#include <bluetooth.h>
|
||||
|
||||
static int enumDev(FF_MAYBE_UNUSED int sockfd, struct bt_devinfo const* dev, FFlist* devices) {
|
||||
static int enumDev(FF_A_UNUSED int sockfd, struct bt_devinfo const* dev, FFlist* devices) {
|
||||
FFBluetoothResult* device = ffListAdd(devices);
|
||||
ffStrbufInitS(&device->name,
|
||||
#if __FreeBSD__
|
||||
@@ -20,7 +20,7 @@ static int enumDev(FF_MAYBE_UNUSED int sockfd, struct bt_devinfo const* dev, FFl
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* ffDetectBluetooth(FF_MAYBE_UNUSED FFBluetoothOptions* options, FF_MAYBE_UNUSED FFlist* devices /* FFBluetoothResult */) {
|
||||
const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FF_A_UNUSED FFlist* devices /* FFBluetoothResult */) {
|
||||
// struct hostent* ent = bt_gethostent();
|
||||
if (bt_devenum((void*) enumDev, devices) < 0) {
|
||||
return "bt_devenum() failed";
|
||||
|
||||
@@ -5,7 +5,7 @@ extern "C" {
|
||||
|
||||
#include <bluetooth/LocalDevice.h>
|
||||
|
||||
const char* ffDetectBluetooth(FF_MAYBE_UNUSED FFBluetoothOptions* options, FFlist* devices /* FFBluetoothResult */) {
|
||||
const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FFlist* devices /* FFBluetoothResult */) {
|
||||
using namespace Bluetooth;
|
||||
FF_SUPPRESS_IO();
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ static uint32_t connectedDevices(void) {
|
||||
|
||||
#endif
|
||||
|
||||
const char* ffDetectBluetooth(FF_MAYBE_UNUSED FFBluetoothOptions* options, FF_MAYBE_UNUSED FFlist* devices /* FFBluetoothResult */) {
|
||||
const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FF_A_UNUSED FFlist* devices /* FFBluetoothResult */) {
|
||||
#ifdef FF_HAVE_DBUS
|
||||
int32_t connectedCount = -1;
|
||||
if (!options->showDisconnected) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "bluetooth.h"
|
||||
|
||||
const char* ffDetectBluetooth(FF_MAYBE_UNUSED FFBluetoothOptions* options, FF_MAYBE_UNUSED FFlist* devices /* FFBluetoothResult */) {
|
||||
const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FF_A_UNUSED FFlist* devices /* FFBluetoothResult */) {
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "bluetoothradio.h"
|
||||
|
||||
const char* ffDetectBluetoothRadio(FF_MAYBE_UNUSED FFlist* devices /* FFBluetoothRadioResult */) {
|
||||
const char* ffDetectBluetoothRadio(FF_A_UNUSED FFlist* devices /* FFBluetoothRadioResult */) {
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ typedef struct _BTH_RADIO_INFO {
|
||||
|
||||
// LMP version
|
||||
UCHAR lmpVersion;
|
||||
} __attribute__((__packed__)) BTH_RADIO_INFO;
|
||||
} FF_A_PACKED BTH_RADIO_INFO;
|
||||
|
||||
typedef struct _BTH_LOCAL_RADIO_INFO {
|
||||
// Local BTH_ADDR, class of device, and radio name
|
||||
@@ -44,7 +44,7 @@ typedef struct _BTH_LOCAL_RADIO_INFO {
|
||||
|
||||
// More information about the local radio (LMP, MFG)
|
||||
BTH_RADIO_INFO radioInfo;
|
||||
} __attribute__((__packed__)) BTH_LOCAL_RADIO_INFO;
|
||||
} FF_A_PACKED BTH_LOCAL_RADIO_INFO;
|
||||
static_assert(sizeof(BTH_LOCAL_RADIO_INFO) == 292, "BTH_LOCAL_RADIO_INFO should be 292 bytes");
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wpointer-sign"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "board.h"
|
||||
|
||||
const char* ffDetectBoard(FF_MAYBE_UNUSED FFBoardResult* board) {
|
||||
const char* ffDetectBoard(FF_A_UNUSED FFBoardResult* board) {
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ typedef struct FFSmbiosBaseboard {
|
||||
uint8_t BoardType; // enum
|
||||
uint8_t NumberOfContainedObjectHandles; // varies
|
||||
uint16_t ContainedObjectHandles[]; // varies
|
||||
} __attribute__((__packed__)) FFSmbiosBaseboard;
|
||||
} FF_A_PACKED FFSmbiosBaseboard;
|
||||
|
||||
static_assert(offsetof(FFSmbiosBaseboard, ContainedObjectHandles) == 0x0F,
|
||||
"FFSmbiosBaseboard: Wrong struct alignment");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "bootmgr.h"
|
||||
|
||||
const char* ffDetectBootmgr(FF_MAYBE_UNUSED FFBootmgrResult* result) {
|
||||
const char* ffDetectBootmgr(FF_A_UNUSED FFBootmgrResult* result) {
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
|
||||
@@ -8,21 +8,21 @@
|
||||
// DDC/CI
|
||||
#ifdef __aarch64__
|
||||
typedef CFTypeRef IOAVServiceRef;
|
||||
extern IOAVServiceRef IOAVServiceCreate(CFAllocatorRef allocator) __attribute__((weak_import));
|
||||
extern IOAVServiceRef IOAVServiceCreateWithService(CFAllocatorRef allocator, io_service_t service) __attribute__((weak_import));
|
||||
extern IOReturn IOAVServiceCopyEDID(IOAVServiceRef service, CFDataRef* x2) __attribute__((weak_import));
|
||||
extern IOReturn IOAVServiceReadI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t offset, void* outputBuffer, uint32_t outputBufferSize) __attribute__((weak_import));
|
||||
extern IOReturn IOAVServiceWriteI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t dataAddress, void* inputBuffer, uint32_t inputBufferSize) __attribute__((weak_import));
|
||||
extern IOAVServiceRef IOAVServiceCreate(CFAllocatorRef allocator) FF_A_WEAK_IMPORT;
|
||||
extern IOAVServiceRef IOAVServiceCreateWithService(CFAllocatorRef allocator, io_service_t service) FF_A_WEAK_IMPORT;
|
||||
extern IOReturn IOAVServiceCopyEDID(IOAVServiceRef service, CFDataRef* x2) FF_A_WEAK_IMPORT;
|
||||
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>
|
||||
extern void CGSServiceForDisplayNumber(CGDirectDisplayID display, io_service_t* service) __attribute__((weak_import));
|
||||
extern void CGSServiceForDisplayNumber(CGDirectDisplayID display, io_service_t* service) FF_A_WEAK_IMPORT;
|
||||
#endif
|
||||
|
||||
// ACPI
|
||||
extern int DisplayServicesGetBrightness(CGDirectDisplayID display, float* brightness) __attribute__((weak_import));
|
||||
extern int DisplayServicesGetBrightness(CGDirectDisplayID display, float* brightness) FF_A_WEAK_IMPORT;
|
||||
|
||||
// Works for internal display
|
||||
static const char* detectWithDisplayServices(const FFDisplayServerResult* displayServer, FFlist* result) {
|
||||
@@ -50,7 +50,7 @@ static const char* detectWithDisplayServices(const FFDisplayServerResult* displa
|
||||
#ifdef __aarch64__
|
||||
// https://github.com/waydabber/m1ddc
|
||||
// Works for Apple Silicon and USB-C adapter connection ( but not HTMI )
|
||||
static const char* detectWithDdcci(FF_MAYBE_UNUSED const FFDisplayServerResult* displayServer, FFBrightnessOptions* options, FFlist* result) {
|
||||
static const char* detectWithDdcci(FF_A_UNUSED const FFDisplayServerResult* displayServer, FFBrightnessOptions* options, FFlist* result) {
|
||||
if (!IOAVServiceCreate || !IOAVServiceReadI2C || !IOAVServiceWriteI2C) {
|
||||
return "IOAVService is not available";
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
# include <sys/fcntl.h>
|
||||
# include <unistd.h>
|
||||
|
||||
const char* ffDetectBrightness(FF_MAYBE_UNUSED FFBrightnessOptions* options, FFlist* result) {
|
||||
const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) {
|
||||
// https://man.freebsd.org/cgi/man.cgi?query=backlight&sektion=9
|
||||
char path[] = "/dev/backlight/backlight0";
|
||||
|
||||
@@ -46,7 +46,7 @@ const char* ffDetectBrightness(FF_MAYBE_UNUSED FFBrightnessOptions* options, FFl
|
||||
|
||||
#else
|
||||
|
||||
const char* ffDetectBrightness(FF_MAYBE_UNUSED FFBrightnessOptions* options, FF_MAYBE_UNUSED FFlist* result) {
|
||||
const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FF_A_UNUSED FFlist* result) {
|
||||
return "Backlight is supported only on FreeBSD 13 and newer";
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ double ddca_set_default_sleep_multiplier(double multiplier); // ddcutil 1.4
|
||||
DDCA_Status ddca_init(const char* libopts, int syslog_level, int opts);
|
||||
# endif
|
||||
|
||||
static const char* detectWithDdcci(FF_MAYBE_UNUSED FFBrightnessOptions* options, FFlist* result) {
|
||||
static const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) {
|
||||
FF_LIBRARY_LOAD_MESSAGE(libddcutil, "libddcutil" FF_LIBRARY_EXTENSION, 5);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_get_display_info_list2)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_open_display2)
|
||||
@@ -160,7 +160,7 @@ static const char* detectWithDdcci(FF_MAYBE_UNUSED FFBrightnessOptions* options,
|
||||
}
|
||||
#endif
|
||||
|
||||
const char* ffDetectBrightness(FF_MAYBE_UNUSED FFBrightnessOptions* options, FFlist* result) {
|
||||
const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) {
|
||||
detectWithBacklight(result);
|
||||
|
||||
#ifdef FF_HAVE_DDCUTIL
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "common/sysctl.h"
|
||||
|
||||
const char* ffDetectBrightness(FF_MAYBE_UNUSED FFBrightnessOptions* options, FFlist* result) {
|
||||
const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) {
|
||||
// https://man.netbsd.org/NetBSD-10.1/acpiout.4#DESCRIPTION
|
||||
char key[] = "hw.acpi.acpiout0.brightness";
|
||||
char* pn = key + strlen("hw.acpi.acpiout");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "brightness.h"
|
||||
|
||||
const char* ffDetectBrightness(FF_MAYBE_UNUSED FFBrightnessOptions* options, FF_MAYBE_UNUSED FFlist* result) {
|
||||
const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FF_A_UNUSED FFlist* result) {
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
const char* ffDetectBrightness(FF_MAYBE_UNUSED FFBrightnessOptions* options, FFlist* result) {
|
||||
const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) {
|
||||
char path[] = "/dev/ttyCX";
|
||||
for (char i = '0'; i <= '9'; ++i) {
|
||||
path[strlen("/dev/ttyC")] = i;
|
||||
|
||||
@@ -126,7 +126,7 @@ static bool hasBuiltinDisplay(const FFDisplayServerResult* displayServer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
extern "C" const char* ffDetectBrightness(FF_MAYBE_UNUSED FFBrightnessOptions* options, FFlist* result) {
|
||||
extern "C" const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) {
|
||||
const FFDisplayServerResult* displayServer = ffConnectDisplayServer();
|
||||
|
||||
if (hasBuiltinDisplay(displayServer)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "btrfs.h"
|
||||
|
||||
const char* ffDetectBtrfs(FF_MAYBE_UNUSED FFlist* result) {
|
||||
const char* ffDetectBtrfs(FF_A_UNUSED FFlist* result) {
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
|
||||
@@ -13,14 +13,14 @@ static inline void wrapYyjsonFree(yyjson_doc** doc) {
|
||||
}
|
||||
}
|
||||
|
||||
const char* ffDetectCamera(FF_MAYBE_UNUSED FFlist* result) {
|
||||
const char* ffDetectCamera(FF_A_UNUSED FFlist* result) {
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
|
||||
if (ffProcessAppendStdOut(&buffer, (char* const[]) { FF_TERMUX_API_PATH, FF_TERMUX_API_PARAM, NULL })) {
|
||||
return "Starting `" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` failed";
|
||||
}
|
||||
|
||||
yyjson_doc* __attribute__((__cleanup__(wrapYyjsonFree))) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, NULL, NULL);
|
||||
yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, NULL, NULL);
|
||||
if (!doc) {
|
||||
return "Failed to parse camera info";
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#ifdef MAC_OS_VERSION_14_0
|
||||
// To make fastfetch compiled on newer macOS versions runs on older ones
|
||||
AVF_EXPORT __attribute__((weak_import)) AVCaptureDeviceType const AVCaptureDeviceTypeExternal;
|
||||
AVF_EXPORT FF_A_WEAK_IMPORT AVCaptureDeviceType const AVCaptureDeviceTypeExternal;
|
||||
#endif
|
||||
|
||||
const char* ffDetectCamera(FFlist* result)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "camera.h"
|
||||
|
||||
const char* ffDetectCamera(FF_MAYBE_UNUSED FFlist* result) {
|
||||
const char* ffDetectCamera(FF_A_UNUSED FFlist* result) {
|
||||
return "Not support on this platform";
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ extern "C" {
|
||||
#include <mfapi.h>
|
||||
#include <mfidl.h>
|
||||
|
||||
extern "C" const char* ffDetectCamera(FF_MAYBE_UNUSED FFlist* result) {
|
||||
extern "C" const char* ffDetectCamera(FF_A_UNUSED FFlist* result) {
|
||||
FF_LIBRARY_LOAD_MESSAGE(mfplat, "mfplat" FF_LIBRARY_EXTENSION, 1)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(mfplat, MFCreateAttributes)
|
||||
FF_LIBRARY_LOAD_MESSAGE(mf, "mf" FF_LIBRARY_EXTENSION, 1)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "chassis.h"
|
||||
|
||||
const char* ffDetectChassis(FF_MAYBE_UNUSED FFChassisResult* result) {
|
||||
const char* ffDetectChassis(FF_A_UNUSED FFChassisResult* result) {
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ typedef struct FFSmbiosSystemEnclosure {
|
||||
uint8_t ContainedElementCount; // varies
|
||||
uint8_t ContainedRecordLength; // varies
|
||||
uint8_t ContainedElements[]; // varies
|
||||
} __attribute__((__packed__)) FFSmbiosSystemEnclosure;
|
||||
} FF_A_PACKED FFSmbiosSystemEnclosure;
|
||||
|
||||
static_assert(offsetof(FFSmbiosSystemEnclosure, ContainedElements) == 0x15,
|
||||
"FFSmbiosSystemEnclosure: Wrong struct alignment");
|
||||
|
||||
@@ -505,14 +505,14 @@ void ffCPUDetectByCpuid(FFCPUResult* cpu) {
|
||||
}
|
||||
}
|
||||
# else
|
||||
void ffCPUDetectByCpuid(FF_MAYBE_UNUSED FFCPUResult* cpu) {
|
||||
void ffCPUDetectByCpuid(FF_A_UNUSED FFCPUResult* cpu) {
|
||||
// Unsupported system
|
||||
}
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
||||
void ffCPUDetectByCpuid(FF_MAYBE_UNUSED FFCPUResult* cpu) {
|
||||
void ffCPUDetectByCpuid(FF_A_UNUSED FFCPUResult* cpu) {
|
||||
// Unsupported architecture
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <OS.h>
|
||||
#include <private/shared/cpu_type.h>
|
||||
|
||||
const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
const char* ffDetectCPUImpl(FF_A_UNUSED const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
system_info sysInfo;
|
||||
if (get_system_info(&sysInfo) != B_OK) {
|
||||
return "get_system_info() failed";
|
||||
|
||||
@@ -553,11 +553,11 @@ static void detectArmName(FFstrbuf* cpuinfo, FFCPUResult* cpu, uint32_t implId)
|
||||
static const char* parseCpuInfo(
|
||||
FFstrbuf* cpuinfo,
|
||||
FFCPUResult* cpu,
|
||||
FF_MAYBE_UNUSED FFstrbuf* physicalCoresBuffer,
|
||||
FF_MAYBE_UNUSED FFstrbuf* cpuMHz,
|
||||
FF_MAYBE_UNUSED FFstrbuf* cpuIsa,
|
||||
FF_MAYBE_UNUSED FFstrbuf* cpuUarch,
|
||||
FF_MAYBE_UNUSED FFstrbuf* cpuImplementer) {
|
||||
FF_A_UNUSED FFstrbuf* physicalCoresBuffer,
|
||||
FF_A_UNUSED FFstrbuf* cpuMHz,
|
||||
FF_A_UNUSED FFstrbuf* cpuIsa,
|
||||
FF_A_UNUSED FFstrbuf* cpuUarch,
|
||||
FF_A_UNUSED FFstrbuf* cpuImplementer) {
|
||||
char* line = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
@@ -709,7 +709,7 @@ static bool detectFrequency(FFCPUResult* cpu, const FFCPUOptions* options) {
|
||||
|
||||
#if __i386__ || __x86_64__
|
||||
|
||||
FF_MAYBE_UNUSED static uint16_t getPackageCount(FFstrbuf* cpuinfo) {
|
||||
FF_A_UNUSED static uint16_t getPackageCount(FFstrbuf* cpuinfo) {
|
||||
const char* p = cpuinfo->chars;
|
||||
uint64_t low = 0, high = 0;
|
||||
|
||||
@@ -728,7 +728,7 @@ FF_MAYBE_UNUSED static uint16_t getPackageCount(FFstrbuf* cpuinfo) {
|
||||
return (uint16_t) (__builtin_popcountll(low) + __builtin_popcountll(high));
|
||||
}
|
||||
|
||||
FF_MAYBE_UNUSED static const char* detectCPUX86(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
FF_A_UNUSED static const char* detectCPUX86(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
FF_STRBUF_AUTO_DESTROY cpuinfo = ffStrbufCreateA(PROC_FILE_BUFFSIZ);
|
||||
if (!ffReadFileBuffer(FF_CPUINFO_PATH, &cpuinfo) || cpuinfo.length == 0) {
|
||||
return "ffReadFileBuffer(\"" FF_CPUINFO_PATH "\") failed";
|
||||
@@ -843,7 +843,7 @@ static const char* detectPhysicalCores(FFCPUResult* cpu) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FF_MAYBE_UNUSED static void parseIsa(FFstrbuf* cpuIsa) {
|
||||
FF_A_UNUSED static void parseIsa(FFstrbuf* cpuIsa) {
|
||||
// Always use the last part of the ISA string. Ref: #590 #1204
|
||||
ffStrbufSubstrAfterLastC(cpuIsa, ' ');
|
||||
|
||||
@@ -863,7 +863,7 @@ FF_MAYBE_UNUSED static void parseIsa(FFstrbuf* cpuIsa) {
|
||||
}
|
||||
}
|
||||
|
||||
FF_MAYBE_UNUSED static void detectSocName(FFCPUResult* cpu) {
|
||||
FF_A_UNUSED static void detectSocName(FFCPUResult* cpu) {
|
||||
if (cpu->name.length > 0) {
|
||||
return;
|
||||
}
|
||||
@@ -983,7 +983,7 @@ FF_MAYBE_UNUSED static void detectSocName(FFCPUResult* cpu) {
|
||||
}
|
||||
|
||||
# ifdef __loongarch__
|
||||
FF_MAYBE_UNUSED static uint16_t getLoongarchPropCount(FFstrbuf* cpuinfo, const char* key) {
|
||||
FF_A_UNUSED static uint16_t getLoongarchPropCount(FFstrbuf* cpuinfo, const char* key) {
|
||||
const char* p = cpuinfo->chars;
|
||||
uint64_t low = 0, high = 0;
|
||||
uint32_t keylen = (uint32_t) strlen(key);
|
||||
@@ -1004,7 +1004,7 @@ FF_MAYBE_UNUSED static uint16_t getLoongarchPropCount(FFstrbuf* cpuinfo, const c
|
||||
}
|
||||
# endif
|
||||
|
||||
FF_MAYBE_UNUSED static const char* detectCPUOthers(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
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();
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ static const char* detectCpuTemp(const FFCPUOptions* options, double* current) {
|
||||
return "open(_PATH_SYSMON, O_RDONLY | O_CLOEXEC) failed";
|
||||
}
|
||||
|
||||
__attribute__((__cleanup__(freePropDict))) prop_dictionary_t root = NULL;
|
||||
FF_A_CLEANUP(freePropDict) prop_dictionary_t root = NULL;
|
||||
if (prop_dictionary_recv_ioctl(fd, ENVSYS_GETDICTIONARY, &root) < 0) {
|
||||
return "prop_dictionary_recv_ioctl(ENVSYS_GETDICTIONARY) failed";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "cpu.h"
|
||||
|
||||
const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFCPUOptions* options, FF_MAYBE_UNUSED FFCPUResult* cpu) {
|
||||
const char* ffDetectCPUImpl(FF_A_UNUSED const FFCPUOptions* options, FF_A_UNUSED FFCPUResult* cpu) {
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ static inline uint16_t countTypeId(kstat_ctl_t* kc, const char* type) {
|
||||
}
|
||||
|
||||
const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) {
|
||||
__attribute__((__cleanup__(kstatFreeWrap))) kstat_ctl_t* kc = kstat_open();
|
||||
FF_A_CLEANUP(kstatFreeWrap) kstat_ctl_t* kc = kstat_open();
|
||||
if (!kc) {
|
||||
return "kstat_open() failed";
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ const char* detectThermalTemp(const FFCPUOptions* options, double* result) {
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((__cleanup__(ffPerfCloseQueryHandle)))
|
||||
FF_A_CLEANUP(ffPerfCloseQueryHandle)
|
||||
HANDLE hQuery = NULL;
|
||||
|
||||
if (PerfOpenQueryHandle(NULL, &hQuery) != ERROR_SUCCESS) {
|
||||
@@ -181,7 +181,7 @@ typedef struct FFSmbiosProcessorInfo {
|
||||
|
||||
// 3.6+
|
||||
uint16_t ThreadEnabled; // varies
|
||||
} __attribute__((__packed__)) FFSmbiosProcessorInfo;
|
||||
} FF_A_PACKED FFSmbiosProcessorInfo;
|
||||
|
||||
static_assert(offsetof(FFSmbiosProcessorInfo, ThreadEnabled) == 0x30,
|
||||
"FFSmbiosProcessorInfo: Wrong struct alignment");
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "fastfetch.h"
|
||||
#include "modules/cpucache/option.h"
|
||||
|
||||
typedef enum __attribute__((__packed__)) FFCPUCacheType {
|
||||
typedef enum FF_A_PACKED FFCPUCacheType {
|
||||
FF_CPU_CACHE_TYPE_UNIFIED = 0,
|
||||
FF_CPU_CACHE_TYPE_INSTRUCTION = 1,
|
||||
FF_CPU_CACHE_TYPE_DATA = 2,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "cpucache.h"
|
||||
|
||||
const char* ffDetectCPUCache(FF_MAYBE_UNUSED FFCPUCacheResult* result) {
|
||||
const char* ffDetectCPUCache(FF_A_UNUSED FFCPUCacheResult* result) {
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ typedef struct FFSmbiosCacheInfo {
|
||||
// 3.1+
|
||||
uint32_t MaximumCacheSize2; // bit field
|
||||
uint32_t InstalledCacheSize2; // bit field
|
||||
} __attribute__((__packed__)) FFSmbiosCacheInfo;
|
||||
} FF_A_PACKED FFSmbiosCacheInfo;
|
||||
|
||||
static_assert(offsetof(FFSmbiosCacheInfo, InstalledCacheSize2) == 0x17,
|
||||
"FFSmbiosCacheInfo: Wrong struct alignment");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "fastfetch.h"
|
||||
#include "detection/cpuusage/cpuusage.h"
|
||||
|
||||
const char* ffGetCpuUsageInfo(FF_MAYBE_UNUSED FFlist* cpuTimes) {
|
||||
const char* ffGetCpuUsageInfo(FF_A_UNUSED FFlist* cpuTimes) {
|
||||
return "Not support on this platform";
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ static inline void kstatFreeWrap(kstat_ctl_t** pkc) {
|
||||
}
|
||||
|
||||
const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
|
||||
__attribute__((__cleanup__(kstatFreeWrap))) kstat_ctl_t* kc = kstat_open();
|
||||
FF_A_CLEANUP(kstatFreeWrap) kstat_ctl_t* kc = kstat_open();
|
||||
if (!kc) {
|
||||
return "kstat_open() failed";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "cursor.h"
|
||||
|
||||
void ffDetectCursor(FF_MAYBE_UNUSED FFCursorResult* result) {
|
||||
void ffDetectCursor(FF_A_UNUSED FFCursorResult* result) {
|
||||
ffStrbufInitS(&result->error, "Not supported on this platform");
|
||||
}
|
||||
|
||||
+11
-11
@@ -22,7 +22,7 @@
|
||||
# define _PATH_LOCALBASE "/usr/pkg"
|
||||
#endif
|
||||
|
||||
static void getKDE(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) {
|
||||
static void getKDE(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
|
||||
#ifdef _PATH_LOCALBASE
|
||||
ffParsePropFile(_PATH_LOCALBASE "/share/wayland-sessions/plasma.desktop", "X-KDE-PluginInfo-Version =", result);
|
||||
if (result->length == 0) {
|
||||
@@ -56,7 +56,7 @@ static void getKDE(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) {
|
||||
}
|
||||
}
|
||||
|
||||
static const char* getGnomeByDbus(FF_MAYBE_UNUSED FFstrbuf* result) {
|
||||
static const char* getGnomeByDbus(FF_A_UNUSED FFstrbuf* result) {
|
||||
#ifdef FF_HAVE_DBUS
|
||||
FF_DBUS_AUTO_DESTROY_DATA FFDBusData dbus = {};
|
||||
if (ffDBusLoadData(DBUS_BUS_SESSION, &dbus) != NULL) {
|
||||
@@ -70,7 +70,7 @@ static const char* getGnomeByDbus(FF_MAYBE_UNUSED FFstrbuf* result) {
|
||||
#endif // FF_HAVE_DBUS
|
||||
}
|
||||
|
||||
static void getGnome(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) {
|
||||
static void getGnome(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
|
||||
getGnomeByDbus(result);
|
||||
|
||||
if (result->length == 0) {
|
||||
@@ -80,7 +80,7 @@ static void getGnome(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) {
|
||||
}
|
||||
}
|
||||
|
||||
static void getCinnamon(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) {
|
||||
static void getCinnamon(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
|
||||
ffStrbufSetS(result, getenv("CINNAMON_VERSION"));
|
||||
|
||||
if (result->length == 0) {
|
||||
@@ -94,7 +94,7 @@ static void getCinnamon(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options)
|
||||
}
|
||||
}
|
||||
|
||||
static void getMate(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) {
|
||||
static void getMate(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
|
||||
FF_STRBUF_AUTO_DESTROY major = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY minor = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY micro = ffStrbufCreate();
|
||||
@@ -124,7 +124,7 @@ static const char* getXfce4ByLib(FFstrbuf* result) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static void getXFCE4(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) {
|
||||
static void getXFCE4(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
|
||||
getXfce4ByLib(result);
|
||||
|
||||
if (result->length == 0) {
|
||||
@@ -137,7 +137,7 @@ static void getXFCE4(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) {
|
||||
}
|
||||
}
|
||||
|
||||
static void getLXQt(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) {
|
||||
static void getLXQt(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
|
||||
ffParsePropFileData("gconfig/lxqt.pc", "Version:", result);
|
||||
|
||||
if (result->length == 0) {
|
||||
@@ -156,11 +156,11 @@ static void getLXQt(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) {
|
||||
}
|
||||
}
|
||||
|
||||
static void getBudgie(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) {
|
||||
static void getBudgie(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
|
||||
ffParsePropFileData("budgie/budgie-version.xml", "<str>", result);
|
||||
}
|
||||
|
||||
static void getUnity(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) {
|
||||
static void getUnity(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
|
||||
if (ffParsePropFile("/usr/bin/unity", "parser = OptionParser(version= \"%prog ", result)) {
|
||||
ffStrbufSubstrBeforeFirstC(result, '"');
|
||||
}
|
||||
@@ -177,7 +177,7 @@ static bool extractTdeVersion(const char* line, uint32_t len, void* userdata) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static const char* getTrinity(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) {
|
||||
static const char* getTrinity(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
|
||||
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate();
|
||||
const char* error = ffFindExecutableInPath("tde-config", &path);
|
||||
if (error) {
|
||||
@@ -200,7 +200,7 @@ static const char* getTrinity(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* opt
|
||||
return "All methods failed";
|
||||
}
|
||||
|
||||
static const char* getCosmic(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) {
|
||||
static const char* getCosmic(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
|
||||
if (ffProcessAppendStdOut(result, (char* const[]) { "cosmic-comp", "--version", NULL }) == NULL) {
|
||||
// cosmic-comp 0.1.0 (git commit fa88002ba41d2edec25dd7ffdee9719fbb928fc0)
|
||||
ffStrbufSubstrAfterFirstC(result, ' ');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "de.h"
|
||||
|
||||
const char* ffDetectDEVersion(FF_MAYBE_UNUSED const FFstrbuf* deName, FF_MAYBE_UNUSED FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) {
|
||||
const char* ffDetectDEVersion(FF_A_UNUSED const FFstrbuf* deName, FF_A_UNUSED FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "common/mallocHelper.h"
|
||||
#include "common/stringUtils.h"
|
||||
|
||||
#include <stdalign.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -53,7 +54,7 @@ static const char* detectFsLabel(struct statfs* fs, FFDisk* disk) {
|
||||
return NULL;
|
||||
}
|
||||
# else
|
||||
static const char* detectFsLabel(FF_MAYBE_UNUSED struct statfs* fs, FF_MAYBE_UNUSED FFDisk* disk) {
|
||||
static const char* detectFsLabel(FF_A_UNUSED struct statfs* fs, FF_A_UNUSED FFDisk* disk) {
|
||||
return "Fastfetch was compiled without libgeom support";
|
||||
}
|
||||
# endif
|
||||
@@ -87,7 +88,7 @@ struct CmnAttrBuf {
|
||||
uint32_t length;
|
||||
attrreference_t nameRef;
|
||||
char nameSpace[NAME_MAX * 3 + 1];
|
||||
} __attribute__((aligned(4), packed));
|
||||
} FF_A_PACKED;
|
||||
|
||||
void detectFsInfo(struct statfs* fs, FFDisk* disk) {
|
||||
if (fs->f_flags & MNT_DONTBROWSE) {
|
||||
@@ -98,7 +99,7 @@ void detectFsInfo(struct statfs* fs, FFDisk* disk) {
|
||||
disk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
|
||||
}
|
||||
|
||||
struct CmnAttrBuf attrBuf;
|
||||
alignas(4) struct CmnAttrBuf attrBuf;
|
||||
if (getattrlist(disk->mountpoint.chars, &(struct attrlist) {
|
||||
.bitmapcount = ATTR_BIT_MAP_COUNT,
|
||||
.commonattr = ATTR_CMN_NAME,
|
||||
|
||||
@@ -162,7 +162,7 @@ static void detectName(FFDisk* disk) {
|
||||
|
||||
#ifdef __ANDROID__
|
||||
|
||||
static void detectType(FF_MAYBE_UNUSED const FFlist* disks, FFDisk* currentDisk, FF_MAYBE_UNUSED struct mntent* device) {
|
||||
static void detectType(FF_A_UNUSED const FFlist* disks, FFDisk* currentDisk, FF_A_UNUSED struct mntent* device) {
|
||||
if (ffStrbufEqualS(¤tDisk->mountpoint, "/") || ffStrbufEqualS(¤tDisk->mountpoint, "/storage/emulated")) {
|
||||
currentDisk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
|
||||
} else if (ffStrbufStartsWithS(¤tDisk->mountpoint, "/mnt/media_rw/")) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "disk.h"
|
||||
|
||||
const char* ffDetectDisksImpl(FF_MAYBE_UNUSED FFDiskOptions* options, FF_MAYBE_UNUSED FFlist* disks) {
|
||||
const char* ffDetectDisksImpl(FF_A_UNUSED FFDiskOptions* options, FF_A_UNUSED FFlist* disks) {
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
# include <libgeom.h>
|
||||
|
||||
const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
__attribute__((__cleanup__(geom_deletetree))) struct gmesh geomTree = {};
|
||||
FF_A_CLEANUP(geom_deletetree) struct gmesh geomTree = {};
|
||||
if (geom_gettree(&geomTree) < 0) {
|
||||
return "geom_gettree() failed";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "diskio.h"
|
||||
|
||||
const char* ffDiskIOGetIoCounters(FF_MAYBE_UNUSED FFlist* result, FF_MAYBE_UNUSED FFDiskIOOptions* options) {
|
||||
const char* ffDiskIOGetIoCounters(FF_A_UNUSED FFlist* result, FF_A_UNUSED FFDiskIOOptions* options) {
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ static inline void kstatFreeWrap(kstat_ctl_t** pkc) {
|
||||
}
|
||||
|
||||
const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
|
||||
__attribute__((__cleanup__(kstatFreeWrap))) kstat_ctl_t* kc = kstat_open();
|
||||
FF_A_CLEANUP(kstatFreeWrap) kstat_ctl_t* kc = kstat_open();
|
||||
if (!kc) {
|
||||
return "kstat_open() failed";
|
||||
}
|
||||
|
||||
@@ -46,20 +46,20 @@
|
||||
#define FF_WM_PROTOCOL_WAYLAND "Wayland"
|
||||
#define FF_WM_PROTOCOL_SURFACEFLINGER "SurfaceFlinger"
|
||||
|
||||
typedef enum __attribute__((__packed__)) FFDisplayType {
|
||||
typedef enum FF_A_PACKED FFDisplayType {
|
||||
FF_DISPLAY_TYPE_UNKNOWN,
|
||||
FF_DISPLAY_TYPE_BUILTIN,
|
||||
FF_DISPLAY_TYPE_EXTERNAL,
|
||||
} FFDisplayType;
|
||||
|
||||
typedef enum __attribute__((__packed__)) FFDisplayHdrStatus {
|
||||
typedef enum FF_A_PACKED FFDisplayHdrStatus {
|
||||
FF_DISPLAY_HDR_STATUS_UNKNOWN,
|
||||
FF_DISPLAY_HDR_STATUS_UNSUPPORTED,
|
||||
FF_DISPLAY_HDR_STATUS_SUPPORTED,
|
||||
FF_DISPLAY_HDR_STATUS_ENABLED,
|
||||
} FFDisplayHdrStatus;
|
||||
|
||||
typedef enum __attribute__((__packed__)) FFDisplayVrrStatus {
|
||||
typedef enum FF_A_PACKED FFDisplayVrrStatus {
|
||||
FF_DISPLAY_DRR_STATUS_UNKNOWN,
|
||||
FF_DISPLAY_DRR_STATUS_DISABLED,
|
||||
FF_DISPLAY_DRR_STATUS_ENABLED,
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
#include <CoreVideo/CVDisplayLink.h>
|
||||
|
||||
#ifdef MAC_OS_X_VERSION_10_15
|
||||
extern Boolean CoreDisplay_Display_SupportsHDRMode(CGDirectDisplayID display) __attribute__((weak_import));
|
||||
extern Boolean CoreDisplay_Display_IsHDRModeEnabled(CGDirectDisplayID display) __attribute__((weak_import));
|
||||
extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display) __attribute__((weak_import));
|
||||
extern Boolean CoreDisplay_Display_SupportsHDRMode(CGDirectDisplayID display) FF_A_WEAK_IMPORT;
|
||||
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>
|
||||
#endif
|
||||
|
||||
@@ -13,7 +13,7 @@ static inline void freeArgBuffer(FFArgBuffer* buffer) {
|
||||
buffer->data = NULL;
|
||||
buffer->length = 0;
|
||||
}
|
||||
#define FF_AUTO_FREE_ARG_BUFFER __attribute__((__cleanup__(freeArgBuffer)))
|
||||
#define FF_AUTO_FREE_ARG_BUFFER FF_A_CLEANUP(freeArgBuffer)
|
||||
|
||||
// http://undoc.airesoft.co.uk/user32.dll/IsThreadDesktopComposited.php
|
||||
BOOL WINAPI IsThreadDesktopComposited();
|
||||
|
||||
@@ -166,7 +166,7 @@ static inline const char* drmType2Name(uint32_t connector_type) {
|
||||
}
|
||||
}
|
||||
|
||||
FF_MAYBE_UNUSED static const char* drmGetEdidByConnId(uint32_t connId, uint8_t* edidData, ssize_t* edidLength) {
|
||||
FF_A_UNUSED static const char* drmGetEdidByConnId(uint32_t connId, uint8_t* edidData, ssize_t* edidLength) {
|
||||
const char* drmDirPath = "/sys/class/drm/";
|
||||
|
||||
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(drmDirPath);
|
||||
@@ -420,7 +420,7 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result) {
|
||||
|
||||
#endif
|
||||
|
||||
const char* ffdsConnectDrm(FF_MAYBE_UNUSED FFDisplayServerResult* result) {
|
||||
const char* ffdsConnectDrm(FF_A_UNUSED FFDisplayServerResult* result) {
|
||||
#ifdef FF_HAVE_DRM
|
||||
if (instance.config.general.dsForceDrm != FF_DS_FORCE_DRM_TYPE_SYSFS_ONLY) {
|
||||
if (drmConnectLibdrm(result) == NULL) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# include "common/stringUtils.h"
|
||||
# include "xdg-output-unstable-v1-client-protocol.h"
|
||||
|
||||
static void waylandOutputModeListener(void* data, FF_MAYBE_UNUSED struct wl_output* output, uint32_t flags, int32_t width, int32_t height, int32_t refreshRate) {
|
||||
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;
|
||||
|
||||
if (flags & WL_OUTPUT_MODE_CURRENT) {
|
||||
@@ -19,20 +19,20 @@ static void waylandOutputModeListener(void* data, FF_MAYBE_UNUSED struct wl_outp
|
||||
}
|
||||
}
|
||||
|
||||
static void waylandOutputScaleListener(void* data, FF_MAYBE_UNUSED struct wl_output* output, int32_t scale) {
|
||||
static void waylandOutputScaleListener(void* data, FF_A_UNUSED struct wl_output* output, int32_t scale) {
|
||||
WaylandDisplay* display = data;
|
||||
display->dpi = 96 * (uint32_t) scale;
|
||||
}
|
||||
|
||||
static void waylandOutputGeometryListener(void* data,
|
||||
FF_MAYBE_UNUSED struct wl_output* output,
|
||||
FF_MAYBE_UNUSED int32_t x,
|
||||
FF_MAYBE_UNUSED int32_t y,
|
||||
FF_A_UNUSED struct wl_output* output,
|
||||
FF_A_UNUSED int32_t x,
|
||||
FF_A_UNUSED int32_t y,
|
||||
int32_t physical_width,
|
||||
int32_t physical_height,
|
||||
FF_MAYBE_UNUSED int32_t subpixel,
|
||||
FF_MAYBE_UNUSED const char* make,
|
||||
FF_MAYBE_UNUSED const char* model,
|
||||
FF_A_UNUSED int32_t subpixel,
|
||||
FF_A_UNUSED const char* make,
|
||||
FF_A_UNUSED const char* model,
|
||||
int32_t transform) {
|
||||
WaylandDisplay* display = data;
|
||||
display->physicalWidth = physical_width;
|
||||
@@ -40,7 +40,7 @@ static void waylandOutputGeometryListener(void* data,
|
||||
display->transform = (enum wl_output_transform) transform;
|
||||
}
|
||||
|
||||
static void handleXdgLogicalSize(void* data, FF_MAYBE_UNUSED struct zxdg_output_v1* _, int32_t width, FF_MAYBE_UNUSED int32_t height) {
|
||||
static void handleXdgLogicalSize(void* data, FF_A_UNUSED struct zxdg_output_v1* _, int32_t width, FF_A_UNUSED int32_t height) {
|
||||
WaylandDisplay* display = data;
|
||||
// Seems the values are only useful when ractional scale is enabled
|
||||
if (width < display->width) {
|
||||
|
||||
@@ -14,18 +14,18 @@ typedef struct WaylandKdeMode {
|
||||
struct kde_output_device_mode_v2* pMode;
|
||||
} WaylandKdeMode;
|
||||
|
||||
static void waylandKdeModeSizeListener(void* data, FF_MAYBE_UNUSED struct kde_output_device_mode_v2* _, int32_t width, int32_t height) {
|
||||
static void waylandKdeModeSizeListener(void* data, FF_A_UNUSED struct kde_output_device_mode_v2* _, int32_t width, int32_t height) {
|
||||
WaylandKdeMode* mode = (WaylandKdeMode*) data;
|
||||
mode->width = width;
|
||||
mode->height = height;
|
||||
}
|
||||
|
||||
static void waylandKdeModeRefreshListener(void* data, FF_MAYBE_UNUSED struct kde_output_device_mode_v2* _, int32_t rate) {
|
||||
static void waylandKdeModeRefreshListener(void* data, FF_A_UNUSED struct kde_output_device_mode_v2* _, int32_t rate) {
|
||||
WaylandKdeMode* mode = (WaylandKdeMode*) data;
|
||||
mode->refreshRate = rate;
|
||||
}
|
||||
|
||||
static void waylandKdeModePreferredListener(void* data, FF_MAYBE_UNUSED struct kde_output_device_mode_v2* _) {
|
||||
static void waylandKdeModePreferredListener(void* data, FF_A_UNUSED struct kde_output_device_mode_v2* _) {
|
||||
WaylandKdeMode* mode = (WaylandKdeMode*) data;
|
||||
mode->preferred = true;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ static const struct kde_output_device_mode_v2_listener modeListener = {
|
||||
.flags = (void*) stubListener,
|
||||
};
|
||||
|
||||
static void waylandKdeModeListener(void* data, FF_MAYBE_UNUSED struct kde_output_device_v2* _, struct kde_output_device_mode_v2* mode) {
|
||||
static void waylandKdeModeListener(void* data, FF_A_UNUSED struct kde_output_device_v2* _, struct kde_output_device_mode_v2* mode) {
|
||||
WaylandDisplay* wldata = (WaylandDisplay*) data;
|
||||
if (!wldata->internal) {
|
||||
return;
|
||||
@@ -51,7 +51,7 @@ static void waylandKdeModeListener(void* data, FF_MAYBE_UNUSED struct kde_output
|
||||
wldata->parent->ffwl_proxy_add_listener((struct wl_proxy*) mode, (void (**)(void)) &modeListener, newMode);
|
||||
}
|
||||
|
||||
static void waylandKdeCurrentModeListener(void* data, FF_MAYBE_UNUSED struct kde_output_device_v2* _, struct kde_output_device_mode_v2* mode) {
|
||||
static void waylandKdeCurrentModeListener(void* data, FF_A_UNUSED struct kde_output_device_v2* _, struct kde_output_device_mode_v2* mode) {
|
||||
// waylandKdeModeListener is always run before this
|
||||
WaylandDisplay* wldata = (WaylandDisplay*) data;
|
||||
if (!wldata->internal) {
|
||||
@@ -79,12 +79,12 @@ static void waylandKdeCurrentModeListener(void* data, FF_MAYBE_UNUSED struct kde
|
||||
}
|
||||
}
|
||||
|
||||
static void waylandKdeScaleListener(void* data, FF_MAYBE_UNUSED struct kde_output_device_v2* _, wl_fixed_t scale) {
|
||||
static void waylandKdeScaleListener(void* data, FF_A_UNUSED struct kde_output_device_v2* _, wl_fixed_t scale) {
|
||||
WaylandDisplay* wldata = (WaylandDisplay*) data;
|
||||
wldata->dpi = (uint32_t) scale * 3 / 8; // wl_fixed_to_double(scale) * 96;
|
||||
}
|
||||
|
||||
static void waylandKdeEdidListener(void* data, FF_MAYBE_UNUSED struct kde_output_device_v2* _, const char* raw) {
|
||||
static void waylandKdeEdidListener(void* data, FF_A_UNUSED struct kde_output_device_v2* _, const char* raw) {
|
||||
if (!*raw) {
|
||||
return;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ static void waylandKdeEdidListener(void* data, FF_MAYBE_UNUSED struct kde_output
|
||||
wldata->hdrInfoAvailable = true;
|
||||
}
|
||||
|
||||
static void waylandKdeEnabledListener(void* data, FF_MAYBE_UNUSED struct kde_output_device_v2* _, int32_t enabled) {
|
||||
static void waylandKdeEnabledListener(void* data, FF_A_UNUSED struct kde_output_device_v2* _, int32_t enabled) {
|
||||
WaylandDisplay* wldata = (WaylandDisplay*) data;
|
||||
if (!enabled) {
|
||||
wldata->internal = NULL;
|
||||
@@ -108,14 +108,14 @@ static void waylandKdeEnabledListener(void* data, FF_MAYBE_UNUSED struct kde_out
|
||||
}
|
||||
|
||||
static void waylandKdeGeometryListener(void* data,
|
||||
FF_MAYBE_UNUSED struct kde_output_device_v2* kde_output_device_v2,
|
||||
FF_MAYBE_UNUSED int32_t x,
|
||||
FF_MAYBE_UNUSED int32_t y,
|
||||
FF_A_UNUSED struct kde_output_device_v2* kde_output_device_v2,
|
||||
FF_A_UNUSED int32_t x,
|
||||
FF_A_UNUSED int32_t y,
|
||||
int32_t physical_width,
|
||||
int32_t physical_height,
|
||||
FF_MAYBE_UNUSED int32_t subpixel,
|
||||
FF_MAYBE_UNUSED const char* make,
|
||||
FF_MAYBE_UNUSED const char* model,
|
||||
FF_A_UNUSED int32_t subpixel,
|
||||
FF_A_UNUSED const char* make,
|
||||
FF_A_UNUSED const char* model,
|
||||
int32_t transform) {
|
||||
WaylandDisplay* display = data;
|
||||
display->physicalWidth = physical_width;
|
||||
@@ -123,7 +123,7 @@ static void waylandKdeGeometryListener(void* data,
|
||||
display->transform = (enum wl_output_transform) transform;
|
||||
}
|
||||
|
||||
static void waylandKdeNameListener(void* data, FF_MAYBE_UNUSED struct kde_output_device_v2* kde_output_device_v2, const char* name) {
|
||||
static void waylandKdeNameListener(void* data, FF_A_UNUSED struct kde_output_device_v2* kde_output_device_v2, const char* name) {
|
||||
WaylandDisplay* display = data;
|
||||
display->type = ffdsGetDisplayType(name);
|
||||
// As display->id is used as an internal identifier, we don't need it to be NUL terminated
|
||||
@@ -132,12 +132,12 @@ static void waylandKdeNameListener(void* data, FF_MAYBE_UNUSED struct kde_output
|
||||
ffStrbufAppendS(&display->name, name);
|
||||
}
|
||||
|
||||
static void waylandKdeHdrListener(void* data, FF_MAYBE_UNUSED struct kde_output_device_v2* kde_output_device_v2, uint32_t hdr_enabled) {
|
||||
static void waylandKdeHdrListener(void* data, FF_A_UNUSED struct kde_output_device_v2* kde_output_device_v2, uint32_t hdr_enabled) {
|
||||
WaylandDisplay* display = data;
|
||||
display->hdrEnabled = !!hdr_enabled;
|
||||
}
|
||||
|
||||
static void waylandKdeMaxBitsPerColorListener(void* data, FF_MAYBE_UNUSED struct kde_output_device_v2* kde_output_device_v2, uint32_t max_bpc) {
|
||||
static void waylandKdeMaxBitsPerColorListener(void* data, FF_A_UNUSED struct kde_output_device_v2* kde_output_device_v2, uint32_t max_bpc) {
|
||||
WaylandDisplay* display = data;
|
||||
display->bitDepth = (uint8_t) max_bpc;
|
||||
}
|
||||
@@ -258,7 +258,7 @@ const char* ffWaylandHandleKdeOutput(WaylandData* wldata, struct wl_registry* re
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void waylandKdeOutputOrderListener(void* data, FF_MAYBE_UNUSED struct kde_output_order_v1* _, const char* output_name) {
|
||||
static void waylandKdeOutputOrderListener(void* data, FF_A_UNUSED struct kde_output_order_v1* _, const char* output_name) {
|
||||
uint64_t* id = (uint64_t*) data;
|
||||
if (*id == 0) {
|
||||
*id = ffWaylandGenerateIdFromName(output_name);
|
||||
|
||||
@@ -103,7 +103,7 @@ static void waylandGlobalAddListener(void* data, struct wl_registry* registry, u
|
||||
}
|
||||
}
|
||||
|
||||
static FF_MAYBE_UNUSED bool matchDrmConnector(const char* connName, WaylandDisplay* wldata) {
|
||||
static FF_A_UNUSED bool matchDrmConnector(const char* connName, WaylandDisplay* wldata) {
|
||||
// https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_output-event-name
|
||||
// The doc says that "do not assume that the name is a reflection of an underlying DRM connector, X11 connection, etc."
|
||||
// However I can't find a better method to get the edid data
|
||||
@@ -141,7 +141,7 @@ static FF_MAYBE_UNUSED bool matchDrmConnector(const char* connName, WaylandDispl
|
||||
return false;
|
||||
}
|
||||
|
||||
void ffWaylandOutputNameListener(void* data, FF_MAYBE_UNUSED void* output, const char* name) {
|
||||
void ffWaylandOutputNameListener(void* data, FF_A_UNUSED void* output, const char* name) {
|
||||
WaylandDisplay* display = data;
|
||||
if (display->id) {
|
||||
return;
|
||||
@@ -157,7 +157,7 @@ void ffWaylandOutputNameListener(void* data, FF_MAYBE_UNUSED void* output, const
|
||||
ffStrbufAppendS(&display->name, name);
|
||||
}
|
||||
|
||||
void ffWaylandOutputDescriptionListener(void* data, FF_MAYBE_UNUSED void* output, const char* description) {
|
||||
void ffWaylandOutputDescriptionListener(void* data, FF_A_UNUSED void* output, const char* description) {
|
||||
WaylandDisplay* display = data;
|
||||
if (display->description.length) {
|
||||
return;
|
||||
@@ -333,7 +333,7 @@ const char* ffdsConnectWayland(FFDisplayServerResult* result) {
|
||||
|
||||
#else
|
||||
|
||||
const char* ffdsConnectWayland(FF_MAYBE_UNUSED FFDisplayServerResult* result) {
|
||||
const char* ffdsConnectWayland(FF_A_UNUSED FFDisplayServerResult* result) {
|
||||
return "Fastfetch was compiled without Wayland support";
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
# include "../displayserver_linux.h"
|
||||
|
||||
typedef enum __attribute__((__packed__)) WaylandProtocolType {
|
||||
typedef enum FF_A_PACKED WaylandProtocolType {
|
||||
FF_WAYLAND_PROTOCOL_TYPE_NONE,
|
||||
FF_WAYLAND_PROTOCOL_TYPE_GLOBAL,
|
||||
FF_WAYLAND_PROTOCOL_TYPE_ZWLR,
|
||||
@@ -71,8 +71,8 @@ inline static uint64_t ffWaylandGenerateIdFromName(const char* name) {
|
||||
return id;
|
||||
}
|
||||
|
||||
void ffWaylandOutputNameListener(void* data, FF_MAYBE_UNUSED void* output, const char* name);
|
||||
void ffWaylandOutputDescriptionListener(void* data, FF_MAYBE_UNUSED void* output, const char* description);
|
||||
void ffWaylandOutputNameListener(void* data, FF_A_UNUSED void* output, const char* name);
|
||||
void ffWaylandOutputDescriptionListener(void* data, FF_A_UNUSED void* output, const char* description);
|
||||
// Modifies content of display. Don't call this function when calling ffdsAppendDisplay
|
||||
uint32_t ffWaylandHandleRotation(WaylandDisplay* display);
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
# include "wayland.h"
|
||||
# include "wlr-output-management-unstable-v1-client-protocol.h"
|
||||
|
||||
static void waylandZwlrTransformListener(void* data, FF_MAYBE_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, int32_t transform) {
|
||||
static void waylandZwlrTransformListener(void* data, FF_A_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, int32_t transform) {
|
||||
WaylandDisplay* wldata = (WaylandDisplay*) data;
|
||||
wldata->transform = (enum wl_output_transform) transform;
|
||||
}
|
||||
|
||||
static void waylandZwlrScaleListener(void* data, FF_MAYBE_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, wl_fixed_t scale) {
|
||||
static void waylandZwlrScaleListener(void* data, FF_A_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, wl_fixed_t scale) {
|
||||
WaylandDisplay* wldata = (WaylandDisplay*) data;
|
||||
wldata->dpi = (uint32_t) scale * 3 / 8; // wl_fixed_to_double(scale) * 96;
|
||||
}
|
||||
@@ -21,18 +21,18 @@ typedef struct WaylandZwlrMode {
|
||||
struct zwlr_output_mode_v1* pMode;
|
||||
} WaylandZwlrMode;
|
||||
|
||||
static void waylandZwlrModeSizeListener(void* data, FF_MAYBE_UNUSED struct zwlr_output_mode_v1* zwlr_output_mode_v1, int32_t width, int32_t height) {
|
||||
static void waylandZwlrModeSizeListener(void* data, FF_A_UNUSED struct zwlr_output_mode_v1* zwlr_output_mode_v1, int32_t width, int32_t height) {
|
||||
WaylandZwlrMode* mode = (WaylandZwlrMode*) data;
|
||||
mode->width = width;
|
||||
mode->height = height;
|
||||
}
|
||||
|
||||
static void waylandZwlrModeRefreshListener(void* data, FF_MAYBE_UNUSED struct zwlr_output_mode_v1* zwlr_output_mode_v1, int32_t rate) {
|
||||
static void waylandZwlrModeRefreshListener(void* data, FF_A_UNUSED struct zwlr_output_mode_v1* zwlr_output_mode_v1, int32_t rate) {
|
||||
WaylandZwlrMode* mode = (WaylandZwlrMode*) data;
|
||||
mode->refreshRate = rate;
|
||||
}
|
||||
|
||||
static void waylandZwlrModePreferredListener(void* data, FF_MAYBE_UNUSED struct zwlr_output_mode_v1* zwlr_output_mode_v1) {
|
||||
static void waylandZwlrModePreferredListener(void* data, FF_A_UNUSED struct zwlr_output_mode_v1* zwlr_output_mode_v1) {
|
||||
WaylandZwlrMode* mode = (WaylandZwlrMode*) data;
|
||||
mode->preferred = true;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ static const struct zwlr_output_mode_v1_listener modeListener = {
|
||||
.finished = (void*) stubListener,
|
||||
};
|
||||
|
||||
static void waylandZwlrModeListener(void* data, FF_MAYBE_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, struct zwlr_output_mode_v1* mode) {
|
||||
static void waylandZwlrModeListener(void* data, FF_A_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, struct zwlr_output_mode_v1* mode) {
|
||||
WaylandDisplay* wldata = (WaylandDisplay*) data;
|
||||
if (!wldata->internal) {
|
||||
return;
|
||||
@@ -57,7 +57,7 @@ static void waylandZwlrModeListener(void* data, FF_MAYBE_UNUSED struct zwlr_outp
|
||||
wldata->parent->ffwl_proxy_add_listener((struct wl_proxy*) mode, (void (**)(void)) &modeListener, newMode);
|
||||
}
|
||||
|
||||
static void waylandZwlrCurrentModeListener(void* data, FF_MAYBE_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, struct zwlr_output_mode_v1* mode) {
|
||||
static void waylandZwlrCurrentModeListener(void* data, FF_A_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, struct zwlr_output_mode_v1* mode) {
|
||||
// waylandZwlrModeListener is always run before this
|
||||
WaylandDisplay* wldata = (WaylandDisplay*) data;
|
||||
if (!wldata->internal) {
|
||||
@@ -85,13 +85,13 @@ static void waylandZwlrCurrentModeListener(void* data, FF_MAYBE_UNUSED struct zw
|
||||
}
|
||||
}
|
||||
|
||||
static void waylandZwlrPhysicalSizeListener(void* data, FF_MAYBE_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, int32_t width, int32_t height) {
|
||||
static void waylandZwlrPhysicalSizeListener(void* data, FF_A_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, int32_t width, int32_t height) {
|
||||
WaylandDisplay* wldata = (WaylandDisplay*) data;
|
||||
wldata->physicalWidth = width;
|
||||
wldata->physicalHeight = height;
|
||||
}
|
||||
|
||||
static void waylandZwlrEnabledListener(void* data, FF_MAYBE_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, bool enabled) {
|
||||
static void waylandZwlrEnabledListener(void* data, FF_A_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, bool enabled) {
|
||||
WaylandDisplay* wldata = (WaylandDisplay*) data;
|
||||
if (!enabled) {
|
||||
wldata->internal = NULL;
|
||||
@@ -115,7 +115,7 @@ static const struct zwlr_output_head_v1_listener headListener = {
|
||||
.adaptive_sync = (void*) stubListener,
|
||||
};
|
||||
|
||||
static void waylandHandleZwlrHead(void* data, FF_MAYBE_UNUSED struct zwlr_output_manager_v1* zwlr_output_manager_v1, struct zwlr_output_head_v1* head) {
|
||||
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));
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
static bool extractNvimVersionFromBinary(const char* str, FF_MAYBE_UNUSED uint32_t len, void* userdata) {
|
||||
static bool extractNvimVersionFromBinary(const char* str, FF_A_UNUSED uint32_t len, void* userdata) {
|
||||
if (!ffStrStartsWith(str, "NVIM v")) {
|
||||
return true;
|
||||
}
|
||||
@@ -15,7 +15,7 @@ static bool extractNvimVersionFromBinary(const char* str, FF_MAYBE_UNUSED uint32
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool extractVimVersionFromBinary(const char* str, FF_MAYBE_UNUSED uint32_t len, void* userdata) {
|
||||
static bool extractVimVersionFromBinary(const char* str, FF_A_UNUSED uint32_t len, void* userdata) {
|
||||
if (!ffStrStartsWith(str, "VIM - Vi IMproved ")) {
|
||||
return true;
|
||||
}
|
||||
@@ -24,7 +24,7 @@ static bool extractVimVersionFromBinary(const char* str, FF_MAYBE_UNUSED uint32_
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool extractNanoVersionFromBinary(const char* str, FF_MAYBE_UNUSED uint32_t len, void* userdata) {
|
||||
static bool extractNanoVersionFromBinary(const char* str, FF_A_UNUSED uint32_t len, void* userdata) {
|
||||
if (!ffStrStartsWith(str, "GNU nano ")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "fastfetch.h"
|
||||
#include "font.h"
|
||||
|
||||
const char* ffDetectFontImpl(FF_MAYBE_UNUSED FFFontResult* result) {
|
||||
const char* ffDetectFontImpl(FF_A_UNUSED FFFontResult* result) {
|
||||
FF_UNUSED(result);
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "gamepad.h"
|
||||
|
||||
const char* ffDetectGamepad(FF_MAYBE_UNUSED FFlist* devices /* List of FFGamepadDevice */) {
|
||||
const char* ffDetectGamepad(FF_A_UNUSED FFlist* devices /* List of FFGamepadDevice */) {
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
#include <assert.h>
|
||||
#include <stdalign.h>
|
||||
|
||||
#if _WIN32
|
||||
# include <ntdef.h>
|
||||
@@ -43,7 +44,7 @@ typedef int32_t NTSTATUS; // 0 for success, -1 for failure
|
||||
# define _In_range_(low, hi)
|
||||
#endif
|
||||
|
||||
#define D3DKMT_ALIGN64 __attribute__((aligned(8)))
|
||||
#define D3DKMT_ALIGN64 alignas(8)
|
||||
|
||||
typedef struct D3DKMT_HANDLE {
|
||||
union {
|
||||
@@ -308,12 +309,12 @@ typedef struct _DXGK_NODEMETADATA {
|
||||
DXGK_NODEMETADATA_FLAGS Flags; // WDDM 2.2
|
||||
BOOLEAN GpuMmuSupported; // WDDM 2.0 ???
|
||||
BOOLEAN IoMmuSupported;
|
||||
} __attribute__((packed)) DXGK_NODEMETADATA;
|
||||
} FF_A_PACKED DXGK_NODEMETADATA;
|
||||
|
||||
typedef struct _D3DKMT_NODEMETADATA {
|
||||
UINT NodeOrdinalAndAdapterIndex; // WDDMv2: High word is physical adapter index, low word is node ordinal
|
||||
DXGK_NODEMETADATA NodeData;
|
||||
} __attribute__((packed)) D3DKMT_NODEMETADATA;
|
||||
} FF_A_PACKED D3DKMT_NODEMETADATA;
|
||||
static_assert(sizeof(D3DKMT_NODEMETADATA) == 0x4E, "D3DKMT_NODEMETADATA structure size mismatch");
|
||||
|
||||
// Functions
|
||||
|
||||
@@ -84,7 +84,7 @@ const char* detectByOpenGL(FFlist* gpus) {
|
||||
ffStrbufInit(&result.slv);
|
||||
ffStrbufInit(&result.library);
|
||||
|
||||
__attribute__((__cleanup__(ffDestroyOpenGLOptions))) FFOpenGLOptions options;
|
||||
FF_A_CLEANUP(ffDestroyOpenGLOptions) FFOpenGLOptions options;
|
||||
ffInitOpenGLOptions(&options);
|
||||
const char* error = ffDetectOpenGL(&options, &result);
|
||||
FF_DEBUG("OpenGL detection returns: %s", error ?: "success");
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "common/debug.h"
|
||||
|
||||
// Helper function to convert ADL status code to string
|
||||
FF_MAYBE_UNUSED static const char* ffAdlStatusToString(int status) {
|
||||
FF_A_UNUSED static const char* ffAdlStatusToString(int status) {
|
||||
switch (status) {
|
||||
#define FF_ADL_STATUS_CASE(name) \
|
||||
case name: \
|
||||
@@ -41,7 +41,7 @@ FF_MAYBE_UNUSED static const char* ffAdlStatusToString(int status) {
|
||||
}
|
||||
|
||||
// Memory allocation function
|
||||
static void* __attribute__((__stdcall__)) ffAdlMainMemoryAlloc(int iSize) {
|
||||
static void* __stdcall ffAdlMainMemoryAlloc(int iSize) {
|
||||
return malloc((size_t) iSize);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "gpu.h"
|
||||
|
||||
typedef enum __attribute__((__packed__)) FFGpuDriverConditionType {
|
||||
typedef enum FF_A_PACKED FFGpuDriverConditionType {
|
||||
FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID = 1 << 0,
|
||||
FF_GPU_DRIVER_CONDITION_TYPE_DEVICE_ID = 1 << 1,
|
||||
FF_GPU_DRIVER_CONDITION_TYPE_LUID = 1 << 2,
|
||||
@@ -47,7 +47,7 @@ const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDrive
|
||||
# define FF_GPU_DRIVER_DLLNAME_PATH_PREFIX
|
||||
#endif
|
||||
|
||||
FF_MAYBE_UNUSED static inline bool getDriverSpecificDetectionFn(const char* vendor, __typeof__(&ffDetectNvidiaGpuInfo)* pDetectFn, const char** pDllName) {
|
||||
FF_A_UNUSED static inline bool getDriverSpecificDetectionFn(const char* vendor, __typeof__(&ffDetectNvidiaGpuInfo)* pDetectFn, const char** pDllName) {
|
||||
if (vendor == FF_GPU_VENDOR_NAME_NVIDIA) {
|
||||
*pDetectFn = ffDetectNvidiaGpuInfo;
|
||||
#ifdef _WIN32
|
||||
|
||||
@@ -15,7 +15,7 @@ enum {
|
||||
PCI_CONF_SIZE = 0x40,
|
||||
};
|
||||
|
||||
const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpus) {
|
||||
const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpus) {
|
||||
int dDomainFd = open(_SERVERS_BUS "/pci/0000", O_RDONLY | O_CLOEXEC);
|
||||
if (dDomainFd < 0) {
|
||||
return "open(_SERVERS_BUS \"/pci/0000\") failed";
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user