xref: /openbmc/qemu/linux-user/riscv/syscallhdr.sh (revision 2e1cacfb)
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3
4in="$1"
5out="$2"
6my_abis=`echo "($3)" | tr ',' '|'`
7prefix="$4"
8offset="$5"
9
10fileguard=LINUX_USER_X86_64_`basename "$out" | sed \
11    -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
12    -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'`
13grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | (
14    echo "#ifndef ${fileguard}"
15    echo "#define ${fileguard} 1"
16    echo ""
17
18    while read nr abi name entry compat ; do
19    if [ -z "$offset" ]; then
20        echo "#define TARGET_NR_${prefix}${name} $nr"
21    else
22        echo "#define TARGET_NR_${prefix}${name} ($offset + $nr)"
23        fi
24    done
25
26    echo ""
27    echo "#endif /* ${fileguard} */"
28) > "$out"
29