H. Peter Anvin | d181764 | 2011-11-11 15:55:49 -0800 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | |
| 3 | in="$1" |
| 4 | out="$2" |
| 5 | my_abis=`echo "$3" | tr ',' ' '` |
| 6 | prefix="$4" |
| 7 | offset="$5" |
| 8 | |
| 9 | fileguard=_ASM_X86_`basename "$out" | sed \ |
| 10 | -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ |
| 11 | -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'` |
| 12 | |
| 13 | in_list () { |
| 14 | local x |
| 15 | for x in $1; do |
| 16 | if [ x"$x" = x"$2" ]; then |
| 17 | return 0 |
| 18 | fi |
| 19 | done |
| 20 | return 1 |
| 21 | } |
| 22 | |
| 23 | grep '^[0-9]' "$in" | sort -n | ( |
| 24 | echo "#ifndef ${fileguard}" |
| 25 | echo "#define ${fileguard} 1" |
| 26 | echo "" |
| 27 | |
| 28 | while read nr abi name entry ; do |
| 29 | if in_list "$my_abis" "$abi"; then |
| 30 | echo "#define __NR_${prefix}${name}" $((nr+offset)) |
| 31 | fi |
| 32 | done |
| 33 | |
| 34 | echo "" |
| 35 | echo "#endif /* ${fileguard} */" |
| 36 | ) > "$out" |