1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3
4in="$1"
5out="$2"
6my_abis=`echo "($3)" | tr ',' '|'`
7my_abi="$4"
8offset="$5"
9
10emit() {
11	t_nxt="$1"
12	t_nr="$2"
13	t_entry="$3"
14
15	while [ $t_nxt -lt $t_nr ]; do
16		printf "__SYSCALL(%s,sys_ni_syscall)\n" "${t_nxt}"
17		t_nxt=$((t_nxt+1))
18	done
19	printf "__SYSCALL(%s,%s)\n" "${t_nxt}" "${t_entry}"
20}
21
22grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | (
23	nxt=0
24	if [ -z "$offset" ]; then
25		offset=0
26	fi
27
28	while read nr abi name entry ; do
29		emit $((nxt+offset)) $((nr+offset)) $entry
30		nxt=$((nr+1))
31	done
32) > "$out"
33