[pulseaudio-discuss] [PATCH] netbsd: Replace nonstandard __WORDSIZE with a more portable solution
David Henningsson
david.henningsson at canonical.com
Mon Dec 14 06:46:57 PST 2015
On 2015-12-10 06:23, Kamil Rytarowski wrote:
> 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.
There is also a reference to __WORDSIZE in src/pulsecore/sample-util.h.
> This change fixes build on NetBSD.
What error are you getting, and how come it does not affect
src/pulsecore/sample-util.h as well?
> ---
> 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.");
>
--
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
More information about the pulseaudio-discuss
mailing list