]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: compat: make sure __WORDSIZE is always defined
authorWilly Tarreau <w@1wt.eu>
Wed, 15 Sep 2021 08:15:03 +0000 (10:15 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 15 Sep 2021 08:32:12 +0000 (10:32 +0200)
-Wundef triggered on a MIPS-based musl build on __WORDSIZE that's used
in ultoa_o() and some Lua initialization. The former will fail to convert
integers larger to 1 billion to proper string in this case. Let's make
sure this macro is defined and fall back to values determined from
__SIZEOF_LONG__ otherwise. A cleaner long-term approach would consist
in removing all remaining occurrences of this macro.

This can be backported to all versions.

include/haproxy/compat.h

index 886b7a3650fd5d199d1ae402b4b895eb9fa83528..84cdbe0d5e90902fb407691a6e7d9c72cb372c90 100644 (file)
@@ -85,6 +85,16 @@ typedef struct { } empty_t;
 #define BITS_PER_INT    (8*sizeof(int))
 #endif
 
+#ifndef __WORDSIZE
+# if defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 4
+#  define __WORDSIZE 32
+# elif defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 8
+#  define __WORDSIZE 64
+# else
+#  error "Unknown machine word size (__WORDSIZE, __SIZEOF_LONG)"
+# endif
+#endif
+
 #ifndef MIN
 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
 #endif