xref: /openbmc/qemu/linux-user/mips/syscallhdr.sh (revision 05caa062)
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_MIPS_`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    printf "#ifndef %s\n" "${fileguard}"
15    printf "#define %s\n" "${fileguard}"
16    printf "\n"
17
18    nxt=0
19    while read nr abi name entry compat ; do
20        if [ "$name" = "fadvise64" ] ; then
21            name="fadvise64_64"
22        fi
23        if [ -z "$offset" ]; then
24            printf "#define TARGET_NR_%s%s\t%s\n" \
25                "${prefix}" "${name}" "${nr}"
26        else
27            printf "#define TARGET_NR_%s%s\t(%s + %s)\n" \
28                "${prefix}" "${name}" "${offset}" "${nr}"
29        fi
30        nxt=$((nr+1))
31    done
32
33    printf "\n"
34    printf "#endif /* %s */" "${fileguard}"
35    printf "\n"
36) > "$out"
37