blob: b81479c8c5fb88c76284e327dd3f76f563e06ec5 [file] [log] [blame]
H. Peter Anvind1817642011-11-11 15:55:49 -08001#!/bin/sh
2
3in="$1"
4out="$2"
5
Andy Lutomirskifba32472016-01-28 15:11:21 -08006emit() {
7 abi="$1"
8 nr="$2"
9 entry="$3"
10 compat="$4"
Andy Lutomirski3e656542016-01-28 15:11:23 -080011
12 if [ "$abi" == "64" -a -n "$compat" ]; then
13 echo "a compat entry for a 64-bit syscall makes no sense" >&2
14 exit 1
15 fi
16
17 if [ -z "$compat" ]; then
18 if [ -n "$entry" ]; then
19 echo "__SYSCALL_${abi}($nr, $entry)"
20 fi
21 else
22 echo "#ifdef CONFIG_X86_32"
23 if [ -n "$entry" ]; then
24 echo "__SYSCALL_${abi}($nr, $entry)"
25 fi
26 echo "#else"
27 echo "__SYSCALL_${abi}($nr, $compat)"
28 echo "#endif"
Andy Lutomirskifba32472016-01-28 15:11:21 -080029 fi
30}
31
H. Peter Anvind1817642011-11-11 15:55:49 -080032grep '^[0-9]' "$in" | sort -n | (
33 while read nr abi name entry compat; do
34 abi=`echo "$abi" | tr '[a-z]' '[A-Z]'`
Andy Lutomirski32324ce2016-01-28 15:11:22 -080035 if [ "$abi" == "COMMON" -o "$abi" == "64" ]; then
36 # COMMON is the same as 64, except that we don't expect X32
37 # programs to use it. Our expectation has nothing to do with
38 # any generated code, so treat them the same.
39 emit 64 "$nr" "$entry" "$compat"
40 elif [ "$abi" == "X32" ]; then
41 # X32 is equivalent to 64 on an X32-compatible kernel.
42 echo "#ifdef CONFIG_X86_X32_ABI"
43 emit 64 "$nr" "$entry" "$compat"
44 echo "#endif"
45 elif [ "$abi" == "I386" ]; then
46 emit "$abi" "$nr" "$entry" "$compat"
47 else
48 echo "Unknown abi $abi" >&2
49 exit 1
50 fi
H. Peter Anvind1817642011-11-11 15:55:49 -080051 done
52) > "$out"