0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 set -e
0016
0017 usage() {
0018 echo >&2 "usage: $0 [--abis ABIS] [--prefix PREFIX] INFILE OUTFILE" >&2
0019 echo >&2
0020 echo >&2 " INFILE input syscall table"
0021 echo >&2 " OUTFILE output header file"
0022 echo >&2
0023 echo >&2 "options:"
0024 echo >&2 " --abis ABIS ABI(s) to handle (By default, all lines are handled)"
0025 echo >&2 " --prefix PREFIX The prefix to the macro like __NR_<PREFIX><NAME>"
0026 exit 1
0027 }
0028
0029
0030 abis=
0031 prefix=
0032
0033 while [ $
0034 do
0035 case $1 in
0036 --abis)
0037 abis=$(echo "($2)" | tr ',' '|')
0038 shift 2;;
0039 --prefix)
0040 prefix=$2
0041 shift 2;;
0042 -*)
0043 echo "$1: unknown option" >&2
0044 usage;;
0045 *)
0046 break;;
0047 esac
0048 done
0049
0050 if [ $
0051 usage
0052 fi
0053
0054 infile="$1"
0055 outfile="$2"
0056
0057 guard=_ASM_$(basename "$outfile" |
0058 sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
0059 -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g')
0060
0061 grep -E "^[0-9A-Fa-fXx]+[[:space:]]+$abis" "$infile" | sort -n | {
0062 echo "#ifndef $guard"
0063 echo "#define $guard"
0064 echo
0065
0066 max=0
0067 while read nr abi name native compat ; do
0068 max=$nr
0069 done
0070
0071 echo "#define __NR_${prefix}syscalls $(($max + 1))"
0072 echo
0073 echo "#endif /* $guard */"
0074 } > "$outfile"