mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 09:58:03 +02:00
Global: replaces __typeof__ to typeof
This commit is contained in:
+2
-2
@@ -134,9 +134,9 @@ static inline void* ffListAdd(FFlist* list, uint32_t elementSize) {
|
||||
|
||||
#define FF_LIST_CONTAINS(listVar, pCompElement, compFunc) \
|
||||
({ \
|
||||
typedef __typeof__(*(pCompElement)) compElementType; \
|
||||
typedef typeof(*(pCompElement)) compElementType; \
|
||||
typedef bool compFuncType(const compElementType*, const compElementType*); \
|
||||
static_assert(__builtin_types_compatible_p(__typeof__(compFunc), compFuncType), "Incompatible callback function"); \
|
||||
static_assert(__builtin_types_compatible_p(typeof(compFunc), compFuncType), "Incompatible callback function"); \
|
||||
ffListContains(&(listVar), (uint32_t) sizeof(*(pCompElement)), (pCompElement), (bool (*)(const void*, const void*)) compFunc); \
|
||||
})
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
#if !__cplusplus && FF_SUPPORTS_COUNT_OF
|
||||
#define ARRAY_SIZE(x) _Countof(x)
|
||||
#elif __has_builtin(__is_array)
|
||||
#define ARRAY_SIZE(x) ({ static_assert(__is_array(__typeof__(x)), "Must be an array"); (uint32_t) (sizeof(x) / sizeof(*(x))); })
|
||||
#define ARRAY_SIZE(x) ({ static_assert(__is_array(typeof(x)), "Must be an array"); (uint32_t) (sizeof(x) / sizeof(*(x))); })
|
||||
#elif __has_builtin(__builtin_types_compatible_p)
|
||||
#define ARRAY_SIZE(x) ({ static_assert(!__builtin_types_compatible_p(__typeof__(x), __typeof__(&*(x))), "Must not be a pointer"); (uint32_t) (sizeof(x) / sizeof(*(x))); })
|
||||
#define ARRAY_SIZE(x) ({ static_assert(!__builtin_types_compatible_p(typeof(x), typeof(&*(x))), "Must not be a pointer"); (uint32_t) (sizeof(x) / sizeof(*(x))); })
|
||||
#endif
|
||||
#endif
|
||||
#ifndef ARRAY_SIZE
|
||||
|
||||
@@ -163,7 +163,7 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) {
|
||||
}
|
||||
|
||||
FF_DEBUG("Processing IPv4 default route candidate #%d", routeCount);
|
||||
entry = (__typeof__(entry)) {}; // Default to zero metric (no RTA_PRIORITY found)
|
||||
entry = (typeof(entry)) {}; // Default to zero metric (no RTA_PRIORITY found)
|
||||
|
||||
// Parse route attributes
|
||||
size_t rtm_len = RTM_PAYLOAD(nlh);
|
||||
@@ -372,7 +372,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) {
|
||||
}
|
||||
|
||||
FF_DEBUG("Processing IPv6 default route candidate #%d", routeCount);
|
||||
entry = (__typeof__(entry)) {}; // Default to zero metric (no RTA_PRIORITY found)
|
||||
entry = (typeof(entry)) {}; // Default to zero metric (no RTA_PRIORITY found)
|
||||
|
||||
// Parse route attributes
|
||||
size_t rtm_len = RTM_PAYLOAD(nlh);
|
||||
|
||||
@@ -406,7 +406,7 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf
|
||||
FF_DEBUG("Setting receive timeout: %u ms", timeout);
|
||||
struct timeval timev;
|
||||
timev.tv_sec = timeout / 1000;
|
||||
timev.tv_usec = (__typeof__(timev.tv_usec)) ((timeout % 1000) * 1000); // milliseconds to microseconds
|
||||
timev.tv_usec = (typeof(timev.tv_usec)) ((timeout % 1000) * 1000); // milliseconds to microseconds
|
||||
setsockopt(state->sockfd, SOL_SOCKET, SO_RCVTIMEO, &timev, sizeof(timev));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -33,7 +33,7 @@ static inline void ffLibraryUnload(void** handle) {
|
||||
#endif
|
||||
|
||||
#define FF_LIBRARY_SYMBOL(symbolName) \
|
||||
__typeof__(&symbolName) ff##symbolName;
|
||||
typeof(&symbolName) ff##symbolName;
|
||||
|
||||
#define FF_LIBRARY_LOAD(libraryObjectName, returnValue, libraryFileName, maxVersion, ...) \
|
||||
[[gnu::cleanup(ffLibraryUnload)]] void* libraryObjectName = ffLibraryLoadSingle(libraryFileName, maxVersion); \
|
||||
@@ -45,7 +45,7 @@ static inline void ffLibraryUnload(void** handle) {
|
||||
FF_LIBRARY_LOAD(libraryObjectName, "dlopen(" libraryFileName ") failed", libraryFileName, maxVersion, ##__VA_ARGS__)
|
||||
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, symbolMapping, symbolName, returnValue) \
|
||||
symbolMapping = (__typeof__(&symbolName)) dlsym(library, #symbolName); \
|
||||
symbolMapping = (typeof(&symbolName)) dlsym(library, #symbolName); \
|
||||
if (__builtin_expect(symbolMapping == nullptr, false)) \
|
||||
return returnValue;
|
||||
|
||||
@@ -53,7 +53,7 @@ static inline void ffLibraryUnload(void** handle) {
|
||||
__auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, returnValue);
|
||||
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_LAZY(library, symbolName) \
|
||||
__auto_type ff##symbolName = (__typeof__(&symbolName)) dlsym(library, #symbolName);
|
||||
__auto_type ff##symbolName = (typeof(&symbolName)) dlsym(library, #symbolName);
|
||||
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \
|
||||
__auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, "dlsym " #symbolName " failed");
|
||||
@@ -75,7 +75,7 @@ void* ffLibraryLoadMulti(const char* path, int maxVersion, ...);
|
||||
#define FF_LIBRARY_EXTENSION ""
|
||||
|
||||
#define FF_LIBRARY_SYMBOL(symbolName) \
|
||||
__typeof__(&symbolName) ff##symbolName;
|
||||
typeof(&symbolName) ff##symbolName;
|
||||
|
||||
#define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \
|
||||
[[maybe_unused]] void* libraryObjectName = nullptr; // Placeholder
|
||||
@@ -84,13 +84,13 @@ void* ffLibraryLoadMulti(const char* path, int maxVersion, ...);
|
||||
FF_LIBRARY_LOAD(libraryObjectName, , libraryFileName, maxVersion, ##__VA_ARGS__)
|
||||
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, symbolMapping, symbolName, returnValue) \
|
||||
symbolMapping = (__typeof__(&symbolName)) &symbolName;
|
||||
symbolMapping = (typeof(&symbolName)) &symbolName;
|
||||
|
||||
#define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \
|
||||
[[maybe_unused]] __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, returnValue);
|
||||
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_LAZY(library, symbolName) \
|
||||
[[maybe_unused]] __auto_type ff##symbolName = (__typeof__(&symbolName)) &symbolName;
|
||||
[[maybe_unused]] __auto_type ff##symbolName = (typeof(&symbolName)) &symbolName;
|
||||
|
||||
#define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \
|
||||
[[maybe_unused]] __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, "dlsym " #symbolName " failed");
|
||||
|
||||
@@ -37,8 +37,8 @@ static bool ffCodecIsLikelySoftware(const char* codecName) {
|
||||
|
||||
static bool ffCodecIsHardwareAccelerated(
|
||||
AMediaCodec* codec,
|
||||
__typeof__(&AMediaCodec_getName) ffAMediaCodec_getName,
|
||||
__typeof__(&AMediaCodec_releaseName) ffAMediaCodec_releaseName) {
|
||||
typeof(&AMediaCodec_getName) ffAMediaCodec_getName,
|
||||
typeof(&AMediaCodec_releaseName) ffAMediaCodec_releaseName) {
|
||||
if (!codec) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ static const FFCodecMftEncoderSubtype FF_D3D11VA_MFT_ENCODER_SUBTYPES[] = {
|
||||
{ &MFVideoFormat_AV1, FF_CODEC_TYPE_AV1 },
|
||||
};
|
||||
|
||||
static FFCodecType ffDetectD3d11vaDecoders(IDXGIAdapter1* adapter, __typeof__(&D3D11CreateDevice) ffD3D11CreateDevice) {
|
||||
static FFCodecType ffDetectD3d11vaDecoders(IDXGIAdapter1* adapter, typeof(&D3D11CreateDevice) ffD3D11CreateDevice) {
|
||||
FF_AUTO_RELEASE_COM_OBJECT ID3D11Device* d3dDevice = nullptr;
|
||||
D3D_FEATURE_LEVEL featureLevel;
|
||||
if (FAILED(ffD3D11CreateDevice(
|
||||
@@ -319,7 +319,7 @@ static FFCodecType ffDetectD3d11vaDecoders(IDXGIAdapter1* adapter, __typeof__(&D
|
||||
return decoders;
|
||||
}
|
||||
|
||||
static FFCodecType ffDetectD3d11MftEncoders(const LUID& adapterLuid, __typeof__(&MFCreateAttributes) ffMFCreateAttributes, __typeof__(&MFTEnum2) ffMFTEnum2) {
|
||||
static FFCodecType ffDetectD3d11MftEncoders(const LUID& adapterLuid, typeof(&MFCreateAttributes) ffMFCreateAttributes, typeof(&MFTEnum2) ffMFTEnum2) {
|
||||
FF_AUTO_RELEASE_COM_OBJECT IMFAttributes* attributes = nullptr;
|
||||
if (FAILED(ffMFCreateAttributes(&attributes, 1)) || !attributes) {
|
||||
return FF_CODEC_TYPE_NONE;
|
||||
|
||||
@@ -48,7 +48,7 @@ const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDrive
|
||||
#define FF_GPU_DRIVER_DLLNAME_PATH_PREFIX
|
||||
#endif
|
||||
|
||||
[[maybe_unused]] static inline bool getDriverSpecificDetectionFn(const char* vendor, __typeof__(&ffDetectNvidiaGpuInfo)* pDetectFn, const char** pDllName) {
|
||||
[[maybe_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
|
||||
|
||||
@@ -371,7 +371,7 @@ const char* ffDrmDetectNouveau(FFGPUResult* gpu, int fd) {
|
||||
|
||||
const char* ffGPUDetectDriverSpecific(const FFGPUOptions* options, FFGPUResult* gpu, FFGpuDriverPciBusId pciBusId) {
|
||||
#if !__OpenBSD__
|
||||
__typeof__(&ffDetectNvidiaGpuInfo) detectFn;
|
||||
typeof(&ffDetectNvidiaGpuInfo) detectFn;
|
||||
const char* soName;
|
||||
if (getDriverSpecificDetectionFn(gpu->vendor.chars, &detectFn, &soName) && (options->temp || options->driverSpecific)) {
|
||||
return detectFn(&(FFGpuDriverCondition) {
|
||||
|
||||
@@ -52,7 +52,7 @@ static const char* detectMoreByNvapi(FFGpuDriverResult* result) {
|
||||
1);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libnvapi, nvapi_QueryInterface)
|
||||
#define FF_NVAPI_INTERFACE(iName, iOffset) \
|
||||
__typeof__(&iName) ff##iName = ffnvapi_QueryInterface(iOffset); \
|
||||
typeof(&iName) ff##iName = ffnvapi_QueryInterface(iOffset); \
|
||||
if (ff##iName == nullptr) return "nvapi_QueryInterface " #iName " failed";
|
||||
|
||||
FF_NVAPI_INTERFACE(nvapi_Initialize, NVAPI_INTERFACE_OFFSET_INITIALIZE)
|
||||
|
||||
@@ -403,7 +403,7 @@ ffGPUDetectWsl2
|
||||
FF_DEBUG("KMTQAITYPE_UMD_DRIVER_VERSION query failed for adapter #%u: %s", i, ffDebugNtStatus(status));
|
||||
}
|
||||
|
||||
__typeof__(&ffDetectNvidiaGpuInfo) detectFn;
|
||||
typeof(&ffDetectNvidiaGpuInfo) detectFn;
|
||||
const char* dllName;
|
||||
if (options->driverSpecific && getDriverSpecificDetectionFn(gpu->vendor.chars, &detectFn, &dllName)) {
|
||||
FF_DEBUG("Calling driver-specific detection function for vendor: %s, DLL: %s", gpu->vendor.chars, dllName);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/OpenGL.h> // This brings in CGL, not GL
|
||||
|
||||
void ffOpenGLHandleResult(FFOpenGLResult* result, __typeof__(&glGetString) ffglGetString);
|
||||
void ffOpenGLHandleResult(FFOpenGLResult* result, typeof(&glGetString) ffglGetString);
|
||||
|
||||
static const char* cglHandleContext(FFOpenGLResult* result, CGLContextObj context) {
|
||||
if (CGLSetCurrentContext(context) != kCGLNoError) {
|
||||
|
||||
@@ -6,7 +6,7 @@ extern "C" {
|
||||
#if FF_HAVE_EGL
|
||||
const char* ffOpenGLDetectByEGL(FFOpenGLResult* result);
|
||||
#endif
|
||||
void ffOpenGLHandleResult(FFOpenGLResult* result, __typeof__(&glGetString) ffglGetString);
|
||||
void ffOpenGLHandleResult(FFOpenGLResult* result, typeof(&glGetString) ffglGetString);
|
||||
}
|
||||
|
||||
static const char* oglDetectOpenGL(FFOpenGLResult* result) {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include <GL/gl.h>
|
||||
|
||||
void ffOpenGLHandleResult(FFOpenGLResult* result, __typeof__(&glGetString) ffglGetString);
|
||||
void ffOpenGLHandleResult(FFOpenGLResult* result, typeof(&glGetString) ffglGetString);
|
||||
|
||||
#endif // FF_HAVE_GL
|
||||
|
||||
@@ -109,7 +109,7 @@ static const char* glxHandleDisplay(FFOpenGLResult* result, GLXData* data) {
|
||||
}
|
||||
|
||||
static const char* glxHandleData(FFOpenGLResult* result, GLXData* data) {
|
||||
data->ffglGetString = (__typeof__(data->ffglGetString)) data->ffglXGetProcAddress((const GLubyte*) "glGetString");
|
||||
data->ffglGetString = (typeof(data->ffglGetString)) data->ffglXGetProcAddress((const GLubyte*) "glGetString");
|
||||
if (data->ffglGetString == nullptr) {
|
||||
return "glXGetProcAddress(glGetString) returned nullptr";
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
|
||||
#endif
|
||||
|
||||
void ffOpenGLHandleResult(FFOpenGLResult* result, __typeof__(&glGetString) ffglGetString) {
|
||||
void ffOpenGLHandleResult(FFOpenGLResult* result, typeof(&glGetString) ffglGetString) {
|
||||
ffStrbufAppendS(&result->version, (const char*) ffglGetString(GL_VERSION));
|
||||
ffStrbufAppendS(&result->renderer, (const char*) ffglGetString(GL_RENDERER));
|
||||
ffStrbufAppendS(&result->vendor, (const char*) ffglGetString(GL_VENDOR));
|
||||
@@ -166,7 +166,7 @@ const char* ffOpenGLDetectByEGL(FFOpenGLResult* result) {
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(egl, eglData, eglTerminate);
|
||||
|
||||
FF_DEBUG("Resolving glGetString via eglGetProcAddress()");
|
||||
eglData.ffglGetString = (__typeof__(&glGetString)) ffeglGetProcAddress("glGetString");
|
||||
eglData.ffglGetString = (typeof(&glGetString)) ffeglGetProcAddress("glGetString");
|
||||
if (!eglData.ffglGetString) {
|
||||
FF_DEBUG("eglGetProcAddress('glGetString') returned nullptr");
|
||||
return "eglGetProcAddress(glGetString) returned nullptr";
|
||||
|
||||
@@ -13,7 +13,7 @@ typedef struct WGLData {
|
||||
FF_LIBRARY_SYMBOL(wglDeleteContext)
|
||||
} WGLData;
|
||||
|
||||
void ffOpenGLHandleResult(FFOpenGLResult* result, __typeof__(&glGetString) ffglGetString);
|
||||
void ffOpenGLHandleResult(FFOpenGLResult* result, typeof(&glGetString) ffglGetString);
|
||||
|
||||
static const char* wglHandleContext(WGLData* wglData, FFOpenGLResult* result, HDC hdc, HGLRC context) {
|
||||
if (wglData->ffwglMakeCurrent(hdc, context) == FALSE) {
|
||||
|
||||
Reference in New Issue
Block a user