Merge tag 'powerpc-5.11-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
[linux/fpc-iii.git] / tools / perf / arch / arm64 / entry / syscalls / mksyscalltbl
blob459469b7222c1410f7a701561eec004d86568369
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
4 # Generate system call table for perf. Derived from
5 # powerpc script.
7 # Copyright IBM Corp. 2017
8 # Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
9 # Changed by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
10 # Changed by: Kim Phillips <kim.phillips@arm.com>
12 gcc=$1
13 hostcc=$2
14 incpath=$3
15 input=$4
17 if ! test -r $input; then
18 echo "Could not read input file" >&2
19 exit 1
22 create_table_from_c()
24 local sc nr last_sc
26 create_table_exe=`mktemp ${TMPDIR:-/tmp}/create-table-XXXXXX`
30 cat <<-_EoHEADER
31 #include <stdio.h>
32 #include "$input"
33 int main(int argc, char *argv[])
35 _EoHEADER
37 while read sc nr; do
38 printf "%s\n" " printf(\"\\t[%d] = \\\"$sc\\\",\\n\", __NR_$sc);"
39 last_sc=$sc
40 done
42 printf "%s\n" " printf(\"#define SYSCALLTBL_ARM64_MAX_ID %d\\n\", __NR_$last_sc);"
43 printf "}\n"
45 } | $hostcc -I $incpath/include/uapi -o $create_table_exe -x c -
47 $create_table_exe
49 rm -f $create_table_exe
52 create_table()
54 echo "static const char *syscalltbl_arm64[] = {"
55 create_table_from_c
56 echo "};"
59 $gcc -E -dM -x c -I $incpath/include/uapi $input \
60 |sed -ne 's/^#define __NR_//p' \
61 |sort -t' ' -k2 -nu \
62 |create_table