]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: compiler: reserve the gcc version checks to the gcc compiler
authorWilly Tarreau <w@1wt.eu>
Thu, 10 Sep 2020 06:33:01 +0000 (08:33 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 10 Sep 2020 06:35:28 +0000 (08:35 +0200)
Some checks on __GNUC__ imply that if it's undefined it will match a
low value but that's not always what we want, like for example in the
VAR_ARRAY definition which is not needed on tcc. Let's always be explicit
on these tests.

include/haproxy/compiler.h

index dbfcb62286100f3dc0e20036160f8742eac12a19..fcf0d9306c9c0725838fb56b6ed901a9c16a2bd6 100644 (file)
@@ -27,7 +27,7 @@
  * Gcc before 3.0 needs [0] to declare a variable-size array
  */
 #ifndef VAR_ARRAY
-#if  __GNUC__  < 3
+#if defined(__GNUC__) && (__GNUC__ < 3)
 #define VAR_ARRAY      0
 #else
 #define VAR_ARRAY
@@ -39,7 +39,7 @@
  * respect our choices.
  */
 #if !defined(forceinline)
-#if __GNUC__ < 3
+#if !defined(__GNUC__) || (__GNUC__ < 3)
 #define forceinline inline
 #else
 #define forceinline inline __attribute__((always_inline))
@@ -89,7 +89,7 @@
  * generally better for the cache and to reduce the number of jumps.
  */
 #if !defined(likely)
-#if __GNUC__ < 3
+#if !defined(__GNUC__) || (__GNUC__ < 3)
 #define __builtin_expect(x,y) (x)
 #define likely(x) (x)
 #define unlikely(x) (x)