]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUILD: compiler: add a macro to detect if another one is set and equals 1
authorWilly Tarreau <w@1wt.eu>
Sun, 13 Nov 2022 10:32:45 +0000 (11:32 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 14 Nov 2022 10:14:02 +0000 (11:14 +0100)
commit08e09f0b3c5803286fb1db13f56273a793a5826e
tree9f0afe8e0fadcbcba0b3a0b1771efc4086ce3f5a
parent71de04134e3f614f4603d1731790314aa7716dc9
BUILD: compiler: add a macro to detect if another one is set and equals 1

In order to simplify compiler-specific checks, we'll need to check if some
attributes exist. In order to ease declarations, we'll only focus on those
that exist and will set them to 1. Let's first add a macro aimed at doing
this. Passed a macro name in argument, it will return 1 if the macro is
defined and equals 1, otherwise it will return 0. This is based on the
concatenation of the macro's value with a name to form the name of a macro
which contains one comma, resulting in some other macros arguments being
shifted by one when the macro is defined. As such it's only a matter of
pushing both a 1 and a 0 and picking the correct argument to see the
desired one. It was verified to work since at least gcc-3.4 so it should
be portable enough.
include/haproxy/compiler.h