From 9bd2d0857cdc6375ad7570516f064eb264530378 Mon Sep 17 00:00:00 2001 From: Mathis Rosenhauer Date: Fri, 19 Aug 2016 09:49:58 +0200 Subject: OS X and clang fixes --- src/decode.c | 5 ++++- tests/bdec.sh | 2 +- tests/benc.sh | 2 +- tests/sampledata.sh | 10 +++++++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/decode.c b/src/decode.c index 4efbee3..886228b 100644 --- a/src/decode.c +++ b/src/decode.c @@ -322,7 +322,10 @@ static inline uint32_t direct_get_fs(struct aec_stream *strm) state->bitp = 56; } -#if HAVE_DECL___BUILTIN_CLZLL +#ifndef __has_builtin +#define __has_builtin(x) 0 /* Compatibility with non-clang compilers. */ +#endif +#if HAVE_DECL___BUILTIN_CLZLL || __has_builtin(__builtin_clzll) i = 63 - __builtin_clzll(state->acc); #elif HAVE_BSR64 _BitScanReverse64(&i, state->acc); diff --git a/tests/bdec.sh b/tests/bdec.sh index a47fe49..99d7136 100755 --- a/tests/bdec.sh +++ b/tests/bdec.sh @@ -8,7 +8,7 @@ if [ ! -f bench.rz ]; then "${path}"/benc.sh fi rm -f dec.dat -bsize=$(stat -c "%s" bench.dat) +bsize=$(wc -c bench.dat | awk '{print $1}') utime=$(../src/utime $AEC -d -n16 -j64 -r256 -m bench.rz dec.dat 2>&1) perf=$(echo "$bsize/1048576/$utime" | bc) echo "*** Decoding with $perf MiB/s user time ***" diff --git a/tests/benc.sh b/tests/benc.sh index 0d20aa3..5ca7ae3 100755 --- a/tests/benc.sh +++ b/tests/benc.sh @@ -23,6 +23,6 @@ if [ ! -f bench.dat ]; then fi rm -f bench.rz utime=$(../src/utime $AEC -n16 -j64 -r256 -m bench.dat bench.rz 2>&1) -bsize=$(stat -c "%s" bench.dat) +bsize=$(wc -c bench.dat | awk '{print $1}') perf=$(echo "$bsize/1048576/$utime" | bc) echo "*** Encoding with $perf MiB/s user time ***" diff --git a/tests/sampledata.sh b/tests/sampledata.sh index 4cacde7..988b7e1 100755 --- a/tests/sampledata.sh +++ b/tests/sampledata.sh @@ -19,9 +19,13 @@ if [ ! -f $archive ]; then fi unzip -oq $archive +filesize () { + wc -c $1 | awk '{print $1}' +} + decode () { $AEC -d $3 $1 test.dat - cmp -n $(stat -c "%s" $2) $2 test.dat + cmp -n $(filesize $2) $2 test.dat } code () { @@ -31,7 +35,7 @@ code () { code_size () { $AEC $3 $2 test.rz - if [ ! $(stat -c "%s" test.rz) -eq $(stat -c "%s" $1) ]; then + if [ ! $(filesize test.rz) -eq $(filesize $1) ]; then echo "$1 size mismatch" exit 1 fi @@ -48,7 +52,7 @@ cosdec () { } echo All Options -ln -f ${ALLO}/test_P512n22.dat ${ALLO}/test_p512n22.dat +mv -f ${ALLO}/test_P512n22.dat ${ALLO}/test_p512n22.dat for i in 01 02 03 04 do uf=$ALLO/test_p256n${i}.dat -- cgit v1.2.3