[PATCH v3] netbsd: Stop depending upon nonstandard __WORDSIZE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 17.12.2015 09:56, David Henningsson wrote:
> 
> 
> On 2015-12-16 10:40, Kamil Rytarowski wrote:
>> There is no way to check CPU type in a portable way across ABIs.
>> 
>> Go for pa_mult_s16_volume() version without need for int64_t. 
>> It's actually the same as in src/tests/mult-s16-test.c.
>> 
>> This change fixes build on NetBSD. --- 
>> src/pulsecore/sample-util.h | 5 ----- src/tests/mult-s16-test.c
>> | 9 ++------- 2 files changed, 2 insertions(+), 12 deletions(-)
>> 
>> diff --git a/src/pulsecore/sample-util.h
>> b/src/pulsecore/sample-util.h index c817bc9..9862938 100644 ---
>> a/src/pulsecore/sample-util.h +++ b/src/pulsecore/sample-util.h 
>> @@ -55,10 +55,6 @@ 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)) -    /* Multiply
>> with 64 bit integers on 64 bit platforms */ -    return (v *
>> (int64_t) cv) >> 16; -#else
> 
> Instead of dropping this (which looks like an optimisation), can't
> you just do - as a quick fix if nothing else:
> 
> #if (defined(__WORDSIZE) && (__WORDSIZE == 64)) || ((ULONG_MAX) > 
> (UINT_MAX))
> 
> Will that allow netbsd to build?
> 
> But, according to the gcc docs [1], "if <symbol> is not defined, it
> will be interpreted as having the value zero". So I'm still not
> understanding why the current code breaks on netbsd? Are you using
> some other compiler which behaves differently?
> 
> [1] https://gcc.gnu.org/onlinedocs/cpp/Defined.html
> 

GCC isn't the only compiler around.

This check for UINT_MAX and ULONG_MAX is wrong, as both can be 32-bit
and equal. Additionally UINT_MAX may be 16 bit..

>> /* Multiplying the 32 bit volume factor with the * 16 bit sample
>> might result in an 48 bit value. We * want to do without 64 bit
>> integers and hence do @@ -68,7 +64,6 @@ static inline int32_t
>> pa_mult_s16_volume(int16_t v, int32_t cv) { int32_t hi = cv >>
>> 16; int32_t lo = cv & 0xFFFF; return ((v * lo) >> 16) + (v *
>> hi); -#endif } pa_usec_t pa_bytes_to_usec_round_up(uint64_t
>> length, const pa_sample_spec *spec); diff --git
>> a/src/tests/mult-s16-test.c b/src/tests/mult-s16-test.c index
>> d2a351c..20ad107 100644 --- a/src/tests/mult-s16-test.c +++
>> b/src/tests/mult-s16-test.c @@ -93,13 +93,8 @@ 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."); -#else -    pa_log_debug("Don't know
>> if this is 32- or 64-bit code."); -#endif +    pa_log_debug("On
>> this platform, integer size is %zu and long size is %zu", +
>> sizeof(int), sizeof(long)); s = suite_create("Mult-s16"); tc =
>> tcase_create("mult-s16");
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJWcpypAAoJEEuzCOmwLnZssfoP/1AUby3Jnvd6d2OwgOxLfoI9
2S0LkdDmgtmx+PRUGNOoO6ZvQIJ8iDsAk23fc0MOYTpKX0pIpRz5/B2+XxX338jz
p6BU22PK678+LrToF3WQeScR8TN26HIJ1o4oHZfdwVqnSCm3snlX57JG8O+gj9rG
+/L26kDh1djNDtOBOfQabZUNzWKOFTe742Ce8ROwklOdGYVpZ1aDTZ6LXSvKYAIv
Bfn007rkwSKNvdB6YGOLKf4kMexp4Sb77FWxUsYG+Y0KzYAHqXQDok6dMl2hEnL4
0H/Q6eWl8KVxqQJ6uqx44AY60MR89Qw5vi+SScbQPO1k5nIC6VwaTNEqBc/nuHES
QYGNVfMg02Kda+Yh1qRKPMnsGLXEwD1nPXRACgZ1SGTAvQV/URY0i37SdU7Qua6t
FIpVn0Gm1DdhpAYgpof9mcCNb2Y1NwiNjiTmx15t1No7FUXjyDEVcq6zqEH9qIr8
m3SCIHmVFzjHLX5imYxsAi4t9buSeBk7KcKj7+qveEbQOuKL9MSw2ZMhAf6E8uSO
Eq2XYpkxYeK56ctIkOLQkdRHih4wB4o01k2Qp/XRBLGGz+8Li5OYSmoeB+rQihzg
vtriD8neFDLgulTRtfis5VH0+zai5RF7UkUC7Yihu6/qkzJLdUIL85DgodtumUll
qm+sAFt9OCZHaHFn4Nis
=ESFR
-----END PGP SIGNATURE-----


[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux