2 # SPDX-License-Identifier: GPL-2.0-only
4 # Generate a syscall number header.
6 # Each line of the syscall table should have the following format:
8 # NR ABI NAME [NATIVE] [COMPAT]
13 # NATIVE native entry point (optional)
14 # COMPAT compat entry point (optional)
18 echo >&2 "usage: $0 [--abis ABIS] [--prefix PREFIX] INFILE OUTFILE" >&2
20 echo >&2 " INFILE input syscall table"
21 echo >&2 " OUTFILE output header file"
24 echo >&2 " --abis ABIS ABI(s) to handle (By default, all lines are handled)"
25 echo >&2 " --prefix PREFIX The prefix to the macro like __NR_<PREFIX><NAME>"
29 # default unless specified by options
37 abis=$(echo "($2)" | tr ',' '|')
43 echo "$1: unknown option" >&2
57 guard=_ASM_$(basename "$outfile" |
58 sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
59 -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g')
61 grep -E "^[0-9A-Fa-fXx]+[[:space:]]+$abis" "$infile" | sort -n | {
67 while read nr abi name native compat ; do
71 echo "#define __NR_${prefix}syscalls $(($max + 1))"
73 echo "#endif /* $guard */"