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