git: 677b28750a86 - main - sys/cdefs.h: Note gcc supports many __has_* macros
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 24 Jun 2024 21:10:56 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=677b28750a86a63d2e94d1187166fe5ccf0e1813
commit 677b28750a86a63d2e94d1187166fe5ccf0e1813
Author: Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-06-24 19:20:57 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-06-24 21:11:05 +0000
sys/cdefs.h: Note gcc supports many __has_* macros
The __has_* macros are no longer clang-speicifc. gcc 5 introduced
__has_include, gcc 9 introduce __has_attribute, gcc 10 introduced
__has_builtin. So all of these are supported by all the versrions of gcc
we support as a project (we have gcc 10 and newer ports, but no older
ones), so just refer to them as supported by gcc. The exact version
doesn't matter so much these days (we provide a fallback for older
compilers still, should anybody still be using them), so don't mention
them in the comments (but here in the commit message they are
discoverable).
gcc 14 adds __has_feature and __has_extension, so note that since it
will be relevant for many years.
Sponsored by: Netflix
---
sys/sys/cdefs.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
index 32050ef81848..58146ddc721c 100644
--- a/sys/sys/cdefs.h
+++ b/sys/sys/cdefs.h
@@ -40,7 +40,10 @@
#endif
/*
- * Testing against Clang-specific extensions.
+ * Provide clang-compatible testing macros. All supported versions of gcc (10+)
+ * provide all of these except has_feature and has_extension which are new in
+ * gcc 14. Keep the older ifndefs, though, for non-gcc compilers that may lack
+ * them like tcc and pcc.
*/
#ifndef __has_attribute
#define __has_attribute(x) 0