1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0 3 4in="$1" 5arch="$2" 6 7syscall_macro() { 8 nr="$1" 9 name="$2" 10 11 echo " [$nr] = \"$name\"," 12} 13 14emit() { 15 nr="$1" 16 entry="$2" 17 18 syscall_macro "$nr" "$entry" 19} 20 21echo "static const char *const syscalltbl_${arch}[] = {" 22 23sorted_table=$(mktemp /tmp/syscalltbl.XXXXXX) 24grep '^[0-9]' "$in" | sort -n > $sorted_table 25 26max_nr=0 27# the params are: nr abi name entry compat 28# use _ for intentionally unused variables according to SC2034 29while read nr _ name _ _; do 30 if [ $nr -ge 512 ] ; then # discard compat sycalls 31 break 32 fi 33 34 emit "$nr" "$name" 35 max_nr=$nr 36done < $sorted_table 37 38rm -f $sorted_table 39 40echo "};" 41 42echo "#define SYSCALLTBL_${arch}_MAX_ID ${max_nr}" 43