[pulseaudio-discuss] [PATCH v4] NetBSD: Stop depending upon nonstandard __WORDSIZE
David Henningsson
david.henningsson at canonical.com
Fri Jan 8 05:27:08 PST 2016
Applied now. Thanks!
On 2015-12-20 01:25, Kamil Rytarowski wrote:
> There is no way to check CPU type in a portable way across ABIs.
>
> Assume if pointers are 64-bit that CPU is capable to perform fast
> 64-bit operations. Add an extra check to handle x32-ABI.
>
> PulseAudio by default builds with -Wundef. If we add -Werror=undef this
> missing define is fatal. By default build log is full of entries like:
>
> In file included from ./pulsecore/core.h:47:0,
> from ./pulsecore/module.h:31,
> from ./pulsecore/sink-input.h:31,
> from pulsecore/sound-file-stream.c:36:
> ./pulsecore/sample-util.h: In function 'pa_mult_s16_volume':
> ./pulsecore/sample-util.h:58:5: warning: "__WORDSIZE" is not defined [-Wundef]
> #if __WORDSIZE == 64 || ((ULONG_MAX) > (UINT_MAX))
> ^
>
> (NetBSD-7.99.21 with default GCC 4.8.5)
>
> This change fixes build issues on NetBSD.
>
> This also address a bug reported by Shawn Walker from Oracle (possibly Solaris):
> Bug 90880 - builds can fail due to non-portable glibc-specific internal macro usage
> ---
> configure.ac | 11 +++++++++++
> src/pulsecore/sample-util.h | 2 +-
> src/tests/mult-s16-test.c | 8 +++-----
> 3 files changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index b9cd3d1..195b265 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -463,6 +463,17 @@ AC_TYPE_OFF_T
> AC_TYPE_UID_T
> AC_CHECK_DECLS(environ)
>
> +AC_CHECK_SIZEOF(void*)
> +
> +fast_64bit_operations="no"
> +# This check covers x32-ABI
> +AC_CHECK_DECL([__x86_64__], [fast_64bit_operations="yes"], [], [])
> +if test "x$fast_64bit_operations" = "xno"; then
> + AS_IF([test $ac_cv_sizeof_voidp -ge 8], [fast_64bit_operations="yes"])
> +fi
> +
> +AS_IF([test "x$fast_64bit_operations" = "xyes"], AC_DEFINE([HAVE_FAST_64BIT_OPERATIONS], 1, [Have CPU with fast 64-bit operations?]))
> +
> # 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/pulsecore/sample-util.h b/src/pulsecore/sample-util.h
> index c817bc9..3d53ebe 100644
> --- a/src/pulsecore/sample-util.h
> +++ b/src/pulsecore/sample-util.h
> @@ -55,7 +55,7 @@ void pa_deinterleave(const void *src, void *dst[], unsigned channels, size_t ss,
> void pa_sample_clamp(pa_sample_format_t format, void *dst, size_t dstr, const void *src, size_t sstr, unsigned n);
>
> static inline int32_t pa_mult_s16_volume(int16_t v, int32_t cv) {
> -#if __WORDSIZE == 64 || ((ULONG_MAX) > (UINT_MAX))
> +#if HAVE_FAST_64BIT_OPERATIONS
> /* Multiply with 64 bit integers on 64 bit platforms */
> return (v * (int64_t) cv) >> 16;
> #else
> diff --git a/src/tests/mult-s16-test.c b/src/tests/mult-s16-test.c
> index d2a351c..845e61c 100644
> --- a/src/tests/mult-s16-test.c
> +++ b/src/tests/mult-s16-test.c
> @@ -93,12 +93,10 @@ int main(int argc, char *argv[]) {
> if (!getenv("MAKE_CHECK"))
> pa_log_set_level(PA_LOG_DEBUG);
>
> -#if __WORDSIZE == 64 || ((ULONG_MAX) > (UINT_MAX))
> - pa_log_debug("This seems to be 64-bit code.");
> -#elif __WORDSIZE == 32
> - pa_log_debug("This seems to be 32-bit code.");
> +#if HAVE_FAST_64BIT_OPERATIONS
> + pa_log_debug("Detected CPU with fast 64-bit operations.");
> #else
> - pa_log_debug("Don't know if this is 32- or 64-bit code.");
> + pa_log_debug("Not detected CPU with fast 64-bit operations.");
> #endif
>
> s = suite_create("Mult-s16");
>
--
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
More information about the pulseaudio-discuss
mailing list