1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3#
4# Generate system call table for perf
5#
6#
7# Copyright IBM Corp. 2017
8# Author(s):  Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
9#
10
11gcc=$1
12input=$2
13
14if ! test -r $input; then
15	echo "Could not read input file" >&2
16	exit 1
17fi
18
19create_table()
20{
21	local max_nr
22
23	echo 'static const char *syscalltbl_s390_64[] = {'
24	while read sc nr; do
25		printf '\t[%d] = "%s",\n' $nr $sc
26		max_nr=$nr
27	done
28	echo '};'
29	echo "#define SYSCALLTBL_S390_64_MAX_ID $max_nr"
30}
31
32
33$gcc -m64 -E -dM -x c  $input	       \
34	|sed -ne 's/^#define __NR_//p' \
35	|sort -t' ' -k2 -nu	       \
36	|create_table
37