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)
19 echo >&2 "usage: $0 [--abis ABIS] [--emit-nr] [--offset OFFSET] [--prefix PREFIX] INFILE OUTFILE" >&2
21 echo >&2 " INFILE input syscall table"
22 echo >&2 " OUTFILE output header file"
25 echo >&2 " --abis ABIS ABI(s) to handle (By default, all lines are handled)"
26 echo >&2 " --emit-nr Emit the macro of the number of syscalls (__NR_syscalls)"
27 echo >&2 " --offset OFFSET The offset of syscall numbers"
28 echo >&2 " --prefix PREFIX The prefix to the macro like __NR_<PREFIX><NAME>"
32 # default unless specified by options
42 abis=$(echo "($2)" | tr ',' '|')
54 echo "$1: unknown option" >&2
68 guard=_UAPI_ASM_$(basename "$outfile" |
69 sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
70 -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g')
72 grep -E "^[0-9A-Fa-fXx]+[[:space:]]+$abis" "$infile" | {
78 while read nr abi name native compat ; do
82 if [ -n "$offset" ]; then
86 echo "#define __NR_$prefix$name $nr"
89 if [ -n "$emit_nr" ]; then
91 echo "#ifdef __KERNEL__"
92 echo "#define __NR_${prefix}syscalls $(($max + 1))"
97 echo "#endif /* $guard */"