43 lines · bash
1#!/bin/sh2# SPDX-License-Identifier: GPL-2.03 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_table25 26max_nr=027# the params are: nr abi name entry compat28# use _ for intentionally unused variables according to SC203429while read nr _ name _ _; do30 if [ $nr -ge 512 ] ; then # discard compat sycalls31 break32 fi33 34 emit "$nr" "$name"35 max_nr=$nr36done < $sorted_table37 38rm -f $sorted_table39 40echo "};"41 42echo "#define SYSCALLTBL_${arch}_MAX_ID ${max_nr}"43