carll | eabf9ff | 2015-07-20 18:53:56 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Check if the passed in (CAPABILITY_WORD) matches a value found in the |
| 4 | # current hwcap aux vector. |
| 5 | |
| 6 | # return '0' to indicate the capability was found. |
| 7 | # return '1' for not found, or any other error condition. |
| 8 | |
| 9 | CAPABILITY_WORD=$1 |
| 10 | |
| 11 | # SANITY CHECK Begin: |
| 12 | # These are potential hwcap values as found in the glibc dl-procinfo.c |
| 13 | # sources as of July 2015. |
| 14 | P_HWCAP_1=" vsx arch_2_06 power6x dfp pa6t arch_2_05 ic_snoop smt booke" |
| 15 | P_HWCAP_2=" cellbe power5+ power5 power4 notb efpdouble efpsingle spe" |
| 16 | P_HWCAP_3=" ucache 4xxmac mmu fpu altivec ppc601 ppc64 ppc32 " |
Elliott Hughes | a0664b9 | 2017-04-18 17:46:52 -0700 | [diff] [blame] | 17 | P_HWCAP2_1=" tar isel ebb dscr htm arch_2_07 arch_3_00 " |
carll | eabf9ff | 2015-07-20 18:53:56 +0000 | [diff] [blame] | 18 | CAPABILITY_FOUND="no" |
| 19 | for POTENTIAL_CAP in $P_HWCAP_1 $P_HWCAP_2 $P_HWCAP_3 $P_HWCAP2_1 ; do |
| 20 | if [ "x$CAPABILITY_WORD" = "x$POTENTIAL_CAP" ]; then |
| 21 | CAPABILITY_FOUND="yes" |
| 22 | break |
| 23 | fi |
| 24 | done |
| 25 | if [ x$CAPABILITY_FOUND = "xno" ]; then |
| 26 | echo "Warning: did not find $CAPABILITY_WORD in the potential capabilities list." |
| 27 | echo " LD_SHOW_AUXV=1 /bin/true | grep ^AT_HWCAP " |
| 28 | echo " Double-check that the input value [$CAPABILITY_WORD] is valid." |
| 29 | fi |
| 30 | # SANITY CHECK End |
| 31 | |
| 32 | # Capability Check Begin: |
| 33 | LD_SHOW_AUXV=1 /bin/true | grep ^AT_HWCAP | grep -w $CAPABILITY_WORD 2>&1 > /dev/null |
| 34 | if [ "$?" -eq "0" ]; then |
| 35 | #echo "found the capability" |
| 36 | exit 0 |
| 37 | elif [ "$?" -eq "2" ]; then |
| 38 | # echo "grep failure" |
| 39 | exit 1 |
| 40 | else |
| 41 | #echo "did not find the capability" |
| 42 | exit 1 |
| 43 | fi |
| 44 | |