[pulseaudio-discuss] [PATCH] netbsd: Replace nonstandard __WORDSIZE with a more portable solution
Kamil Rytarowski
n54 at gmx.com
Wed Dec 9 21:23:30 PST 2015
There is no way to check CPU type in a portable way across ABIs.
Checking for sizeof(void*) is reasonable since most platforms will
report correct values. One exception is x32, but since it's halfbaked
never finished and almost not needed any more - we can ignore it.
The check is needed only to print a debug message, no functional
change.
This change fixes build on NetBSD.
---
configure.ac | 3 +++
src/tests/mult-s16-test.c | 5 +++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index b9cd3d1..7735081 100644
--- a/configure.ac
+++ b/configure.ac
@@ -463,6 +463,9 @@ AC_TYPE_OFF_T
AC_TYPE_UID_T
AC_CHECK_DECLS(environ)
+# Used to deduct CPU word size
+AC_CHECK_SIZEOF(void*)
+
# SIGXCPU
AX_CHECK_DEFINE([signal.h], [SIGXCPU], [HAVE_SIGXCPU=1], [HAVE_SIGXCPU=0])
AS_IF([test "x$HAVE_SIGXCPU" = "x1"], AC_DEFINE([HAVE_SIGXCPU], 1, [Have SIGXCPU?]))
diff --git a/src/tests/mult-s16-test.c b/src/tests/mult-s16-test.c
index d2a351c..ac5a43f 100644
--- a/src/tests/mult-s16-test.c
+++ b/src/tests/mult-s16-test.c
@@ -23,6 +23,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <math.h>
+#include <limits.h>
#include <pulse/rtclock.h>
#include <pulsecore/random.h>
@@ -93,9 +94,9 @@ int main(int argc, char *argv[]) {
if (!getenv("MAKE_CHECK"))
pa_log_set_level(PA_LOG_DEBUG);
-#if __WORDSIZE == 64 || ((ULONG_MAX) > (UINT_MAX))
+#if (SIZEOF_VOIDP * CHAR_BIT) == 64
pa_log_debug("This seems to be 64-bit code.");
-#elif __WORDSIZE == 32
+#elif (SIZEOF_VOIDP * CHAR_BIT) == 32
pa_log_debug("This seems to be 32-bit code.");
#else
pa_log_debug("Don't know if this is 32- or 64-bit code.");
--
2.6.3
More information about the pulseaudio-discuss
mailing list