blob: 31fd5f1f38f7618d733a162a4828d8ade9de069f [file] [log] [blame]
H. Peter Anvind1817642011-11-11 15:55:49 -08001#!/bin/sh
2
3in="$1"
4out="$2"
H. Peter Anvinf14525f2011-11-18 16:03:27 -08005my_abis=`echo "($3)" | tr ',' '|'`
H. Peter Anvind1817642011-11-11 15:55:49 -08006prefix="$4"
7offset="$5"
8
9fileguard=_ASM_X86_`basename "$out" | sed \
10 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
11 -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'`
H. Peter Anvinf14525f2011-11-18 16:03:27 -080012grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | (
H. Peter Anvind1817642011-11-11 15:55:49 -080013 echo "#ifndef ${fileguard}"
14 echo "#define ${fileguard} 1"
15 echo ""
16
17 while read nr abi name entry ; do
H. Peter Anvin3f868862011-11-18 17:01:19 -080018 if [ -z "$offset" ]; then
19 echo "#define __NR_${prefix}${name} $nr"
20 else
21 echo "#define __NR_${prefix}${name} ($offset + $nr)"
22 fi
H. Peter Anvind1817642011-11-11 15:55:49 -080023 done
24
25 echo ""
26 echo "#endif /* ${fileguard} */"
27) > "$out"