summaryrefslogtreecommitdiff
path: root/tools/include
diff options
context:
space:
mode:
authorThomas Weißschuh <linux@weissschuh.net>2025-12-20 14:55:56 +0100
committerThomas Weißschuh <linux@weissschuh.net>2026-01-06 12:08:07 +0100
commitdd6659efe0529e7177e9270a0fc044a0b17deb8a (patch)
treeecd5a6153579a7db935ca80a0c5c3310ba70021e /tools/include
parent6c9be90527207f9beca78e698dd45969813f4c0e (diff)
tools/nolibc: add compiler version detection macros
Some upcoming logic needs to depend on the version of GCC or clang. Add some helper macros to keep the conditionals readable. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Link: https://patch.msgid.link/20251220-nolibc-uapi-types-v3-12-c662992f75d7@weissschuh.net
Diffstat (limited to 'tools/include')
-rw-r--r--tools/include/nolibc/compiler.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/include/nolibc/compiler.h b/tools/include/nolibc/compiler.h
index 87090bbc53e0..c9ffd0496dae 100644
--- a/tools/include/nolibc/compiler.h
+++ b/tools/include/nolibc/compiler.h
@@ -47,4 +47,20 @@
# define __nolibc_fallthrough do { } while (0)
#endif /* __nolibc_has_attribute(fallthrough) */
+#define __nolibc_version(_major, _minor, _patch) ((_major) * 10000 + (_minor) * 100 + (_patch))
+
+#ifdef __GNUC__
+# define __nolibc_gnuc_version \
+ __nolibc_version(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
+#else
+# define __nolibc_gnuc_version 0
+#endif /* __GNUC__ */
+
+#ifdef __clang__
+# define __nolibc_clang_version \
+ __nolibc_version(__clang_major__, __clang_minor__, __clang_patchlevel__)
+#else
+# define __nolibc_clang_version 0
+#endif /* __clang__ */
+
#endif /* _NOLIBC_COMPILER_H */