MINOR: compiler: add a __has_builtin() macro to detect features more easily
authorWilly Tarreau <w@1wt.eu>
Tue, 17 Dec 2024 07:54:23 +0000 (08:54 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 17 Apr 2025 15:04:35 +0000 (17:04 +0200)
commitd92f2e7b721a490b1e210ec47587dd60c4db5eb2
tree46cc6ac9e89fafa80e572105708cd23ac3cb3ed1
parentea97524977950be1162b022058f1dbcaa16167d3
MINOR: compiler: add a __has_builtin() macro to detect features more easily

We already have a __has_attribute() macro to detect when the compiler
supports a specific attribute, but we didn't have the equivalent for
builtins. clang-3 and gcc-10 have __has_builtin() for this. Let's just
bring it using the same mechanism as __has_attribute(), which will allow
us to simply define the macro's value for older compilers. It will save
us from keeping that many compiler-specific tests that are incomplete
(e.g. the __builtin_unreachable() test currently doesn't cover clang).

(cherry picked from commit 96cfcb1df36fdf8fb963371ad5e167c733d842b1)
Signed-off-by: Willy Tarreau <w@1wt.eu>
include/haproxy/compiler.h