Home | History | Annotate | Download | only in issue17144-byteswap
      1 # Check if APP_ABI=armeabi-v7a use "rev" instructions for __swapXX
      2 # See https://android-review.googlesource.com/#/c/17144
      3 #
      4 
      5 fail_panic ()
      6 {
      7     if [ $? != 0 ] ; then
      8         echo "ERROR: $@"
      9         exit 1
     10     fi
     11 }
     12 
     13 for opt do
     14     optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
     15     case "$opt" in
     16     APP_ABI=*)
     17         APP_ABI=$optarg
     18         ;;
     19     esac
     20 done
     21 
     22 if [ -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 instruciton for __swap32()"
     30 fi
     31 
     32 if [ -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 rorw issue17144-byteswap.s
     37     fail_panic "x86 doesn't use rorw instruction for __swap16()"
     38     grep -qw bswap issue17144-byteswap.s
     39     fail_panic "x86 doesn't use bswap instruciton for __swap32()"
     40 fi
     41 
     42 if [ -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 -w rotr issue17144-byteswap.s | grep -qw rotr
     51     fail_panic "mips doesn't use wsbh/rotr instruciton for __swap32()"
     52 fi
     53 
     54 rm -rf libs obj issue17144-byteswap.*