]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
build: detect wordsize in a portable way
authorNatanael Copa <ncopa@alpinelinux.org>
Tue, 4 Mar 2014 12:32:34 +0000 (12:32 +0000)
committerNatanael Copa <ncopa@alpinelinux.org>
Tue, 4 Mar 2014 12:40:29 +0000 (12:40 +0000)
There are no standard that says that __WORDSIZE should be defined or
in what include file. So in case its not defined we fallback to a
POSIX compliant way to determine wordsize.

This fixes build with 64 bit musl libc.

See https://tvheadend.org/issues/1983

src/tvheadend.h

index 218ac5db786a8303bc333d356fad58d80d1df9a7..a52185100484d1900fd6b1c6891f85f743272cdc 100644 (file)
@@ -31,6 +31,7 @@
 #include <string.h>
 #include <assert.h>
 #include <unistd.h>
+#include <limits.h>
 #if ENABLE_LOCKOWNER
 #include <sys/syscall.h>
 #endif
@@ -611,6 +612,14 @@ qsort_r(void *base, size_t nmemb, size_t size,
 #endif /* ENABLE_QSORT_R */
 
 /* printing */
+#ifndef __WORDSIZE
+# if ULONG_MAX == 0xffffffffffffffff
+#  define __WORDSIZE 64
+# elif ULONG_MAX == 0xffffffff
+#  define __WORDSIZE 32
+# endif /* ULONG_MAX */
+#endif /* __WORDSIZE */
+
 # if __WORDSIZE == 64
 #define PRIsword_t      PRId64
 #define PRIuword_t      PRIu64