From 6a3db09e554655e6d1150d827b987abb644d56e8 Mon Sep 17 00:00:00 2001 From: Travis Geiselbrecht Date: Thu, 9 May 2024 18:50:44 -0700 Subject: [PATCH] [compiler] GCC 14.1 supports __has_feature Enable it if not present, not just if its clang. --- lib/libc/include/sys/cdefs.h | 19 ------------------- top/include/lk/compiler.h | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/lib/libc/include/sys/cdefs.h b/lib/libc/include/sys/cdefs.h index 5f794618..e30c1ff7 100644 --- a/lib/libc/include/sys/cdefs.h +++ b/lib/libc/include/sys/cdefs.h @@ -56,25 +56,6 @@ #define __BEGIN_DECLS __BEGIN_CDECLS #define __END_DECLS __END_CDECLS -/* - * Testing against Clang-specific extensions. - */ -#ifndef __has_attribute -#define __has_attribute(x) 0 -#endif -#ifndef __has_extension -#define __has_extension __has_feature -#endif -#ifndef __has_feature -#define __has_feature(x) 0 -#endif -#ifndef __has_include -#define __has_include(x) 0 -#endif -#ifndef __has_builtin -#define __has_builtin(x) 0 -#endif - /*- * Deal with _ANSI_SOURCE: * If it is defined, and no other compilation environment is explicitly diff --git a/top/include/lk/compiler.h b/top/include/lk/compiler.h index 04236826..d00104b0 100644 --- a/top/include/lk/compiler.h +++ b/top/include/lk/compiler.h @@ -138,11 +138,26 @@ #define __FALLTHROUGH do {} while (0) #endif +#ifndef __has_attribute +#define __has_attribute(x) 0 +#endif +#ifndef __has_extension +#define __has_extension __has_feature +#endif +#ifndef __has_feature +#define __has_feature(x) 0 +#endif +#ifndef __has_include +#define __has_include(x) 0 +#endif +#ifndef __has_builtin +#define __has_builtin(x) 0 +#endif + #ifndef __clang__ #define __LEAF_FN __attribute__((__leaf__)) #define __OPTIMIZE(x) __attribute__((optimize(x))) #define __THREAD_ANNOTATION(x) -#define __has_feature(x) 0 #else #define __LEAF_FN #define __OPTIMIZE(x)