syscalltbl.sh 732 Bytes
Newer Older
1
#!/bin/sh
2
# SPDX-License-Identifier: GPL-2.0
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

in="$1"
arch="$2"

syscall_macro() {
    nr="$1"
    name="$2"

    echo "	[$nr] = \"$name\","
}

emit() {
    nr="$1"
    entry="$2"

    syscall_macro "$nr" "$entry"
}

21
echo "static const char *const syscalltbl_${arch}[] = {"
22 23 24 25 26

sorted_table=$(mktemp /tmp/syscalltbl.XXXXXX)
grep '^[0-9]' "$in" | sort -n > $sorted_table

max_nr=0
27 28 29
# the params are: nr abi name entry compat
# use _ for intentionally unused variables according to SC2034
while read nr _ name _ _; do
30 31 32 33 34 35 36 37 38 39 40 41 42
    if [ $nr -ge 512 ] ; then # discard compat sycalls
        break
    fi

    emit "$nr" "$name"
    max_nr=$nr
done < $sorted_table

rm -f $sorted_table

echo "};"

echo "#define SYSCALLTBL_${arch}_MAX_ID ${max_nr}"