2 # SPDX-License-Identifier: GPL-2.0
4 # Generate a syscall table 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] 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)"
29 # default unless specified by options
36 abis=$(echo "($2)" | tr ',' '|')
39 echo "$1: unknown option" >&2
59 echo " [$nr] = \"$name\","
66 syscall_macro "$nr" "$entry"
69 echo "static const char *const syscalltbl[] = {" > $outfile
71 sorted_table=$(mktemp /tmp/syscalltbl.XXXXXX)
72 grep -E "^[0-9]+[[:space:]]+$abis" "$infile" | sort -n > $sorted_table
75 # the params are: nr abi name entry compat
76 # use _ for intentionally unused variables according to SC2034
77 while read nr _ name _ _; do
78 emit "$nr" "$name" >> $outfile
86 echo "#define SYSCALLTBL_MAX_ID ${max_nr}" >> $outfile