1# Check if APP_ABI=armeabi-v7a use "rev" instructions for __swapXX 2# See https://android-review.googlesource.com/#/c/17144 3# 4 5fail_panic () 6{ 7 if [ $? != 0 ] ; then 8 echo "ERROR: $@" 9 exit 1 10 fi 11} 12 13for opt do 14 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'` 15 case "$opt" in 16 APP_ABI=*) 17 APP_ABI=$optarg 18 ;; 19 esac 20done 21 22if [ -z "$APP_ABI" -o "$APP_ABI" = "all" -o "$APP_ABI" != "${APP_ABI%%armeabi-v7a*}" ]; then 23 # checking armeabi-v7a 24 $NDK/ndk-build -B APP_ABI=armeabi-v7a APP_CFLAGS=-save-temps NDK_DEBUG=1 25 fail_panic "can't compile for APP_ABI=armeabi-v7a" 26 grep -qw rev16 issue17144-byteswap.s 27 fail_panic "armeabi-v7a doesn't use rev16 instruction for __swap16()" 28 grep -qw rev issue17144-byteswap.s 29 fail_panic "armeabi-v7a doesn't use rev instruction for __swap32()" 30fi 31 32if [ -z "$APP_ABI" -o "$APP_ABI" = "all" -o "$APP_ABI" != "${APP_ABI%%x86}" ]; then 33 # checking x86 34 $NDK/ndk-build -B APP_ABI=x86 APP_CFLAGS=-save-temps NDK_DEBUG=1 35 fail_panic "can't compile for x86" 36 grep -qw 'ro[lr]w' issue17144-byteswap.s 37 fail_panic "x86 doesn't use rorw instruction for __swap16()" 38 egrep -qw 'bswapl?' issue17144-byteswap.s 39 fail_panic "x86 doesn't use bswap instruction for __swap32()" 40fi 41 42if [ -z "$APP_ABI" -o "$APP_ABI" = "all" -o "$APP_ABI" != "${APP_ABI%%mips}" ]; then 43 # checking mips 44 # Note that MD_SWAP in machine/endian.h is only defined for r2. Add 45 # -mips32r2 because default Android toolchain support r1 46 $NDK/ndk-build -B APP_ABI=mips APP_CFLAGS="-save-temps -mips32r2" NDK_DEBUG=1 47 fail_panic "can't compile for mips" 48 grep -qw wsbh issue17144-byteswap.s 49 fail_panic "mips doesn't use wsbh instruction for __swap16()" 50 grep -wA1 wsbh issue17144-byteswap.s | egrep -qw 'rot?r' 51 fail_panic "mips doesn't use wsbh/rotr instruction for __swap32()" 52fi 53 54rm -rf libs obj issue17144-byteswap.* 55