1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3 4in="$1" 5out="$2" 6 7syscall_macro() { 8 local abi="$1" 9 local nr="$2" 10 local entry="$3" 11 12 echo "__SYSCALL_${abi}($nr, $entry)" 13} 14 15emit() { 16 local abi="$1" 17 local nr="$2" 18 local entry="$3" 19 local compat="$4" 20 21 if [ "$abi" != "I386" -a -n "$compat" ]; then 22 echo "a compat entry ($abi: $compat) for a 64-bit syscall makes no sense" >&2 23 exit 1 24 fi 25 26 if [ -z "$compat" ]; then 27 if [ -n "$entry" ]; then 28 syscall_macro "$abi" "$nr" "$entry" 29 fi 30 else 31 echo "#ifdef CONFIG_X86_32" 32 if [ -n "$entry" ]; then 33 syscall_macro "$abi" "$nr" "$entry" 34 fi 35 echo "#else" 36 syscall_macro "$abi" "$nr" "$compat" 37 echo "#endif" 38 fi 39} 40 41grep '^[0-9]' "$in" | sort -n | ( 42 while read nr abi name entry compat; do 43 abi=`echo "$abi" | tr '[a-z]' '[A-Z]'` 44 emit "$abi" "$nr" "$entry" "$compat" 45 done 46) > "$out" 47