]> git.ipfire.org Git - thirdparty/kernel/linux.git/blame - arch/x86/entry/syscalls/syscalltbl.sh
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[thirdparty/kernel/linux.git] / arch / x86 / entry / syscalls / syscalltbl.sh
CommitLineData
d181764c 1#!/bin/sh
b2441318 2# SPDX-License-Identifier: GPL-2.0
d181764c
PA
3
4in="$1"
5out="$2"
6
cfcbadb4
AL
7syscall_macro() {
8 abi="$1"
9 nr="$2"
10 entry="$3"
11
12 # Entry can be either just a function name or "function/qualifier"
13 real_entry="${entry%%/*}"
2df0e78b 14 if [ "$entry" = "$real_entry" ]; then
15 qualifier=
16 else
17 qualifier=${entry#*/}
18 fi
cfcbadb4
AL
19
20 echo "__SYSCALL_${abi}($nr, $real_entry, $qualifier)"
21}
22
fba32474
AL
23emit() {
24 abi="$1"
25 nr="$2"
26 entry="$3"
27 compat="$4"
3e65654e 28
2df0e78b 29 if [ "$abi" = "64" -a -n "$compat" ]; then
3e65654e
AL
30 echo "a compat entry for a 64-bit syscall makes no sense" >&2
31 exit 1
32 fi
33
34 if [ -z "$compat" ]; then
35 if [ -n "$entry" ]; then
cfcbadb4 36 syscall_macro "$abi" "$nr" "$entry"
3e65654e
AL
37 fi
38 else
39 echo "#ifdef CONFIG_X86_32"
40 if [ -n "$entry" ]; then
cfcbadb4 41 syscall_macro "$abi" "$nr" "$entry"
3e65654e
AL
42 fi
43 echo "#else"
cfcbadb4 44 syscall_macro "$abi" "$nr" "$compat"
3e65654e 45 echo "#endif"
fba32474
AL
46 fi
47}
48
d181764c
PA
49grep '^[0-9]' "$in" | sort -n | (
50 while read nr abi name entry compat; do
51 abi=`echo "$abi" | tr '[a-z]' '[A-Z]'`
2df0e78b 52 if [ "$abi" = "COMMON" -o "$abi" = "64" ]; then
32324ce1
AL
53 # COMMON is the same as 64, except that we don't expect X32
54 # programs to use it. Our expectation has nothing to do with
55 # any generated code, so treat them the same.
56 emit 64 "$nr" "$entry" "$compat"
2df0e78b 57 elif [ "$abi" = "X32" ]; then
32324ce1
AL
58 # X32 is equivalent to 64 on an X32-compatible kernel.
59 echo "#ifdef CONFIG_X86_X32_ABI"
60 emit 64 "$nr" "$entry" "$compat"
61 echo "#endif"
2df0e78b 62 elif [ "$abi" = "I386" ]; then
32324ce1
AL
63 emit "$abi" "$nr" "$entry" "$compat"
64 else
65 echo "Unknown abi $abi" >&2
66 exit 1
67 fi
d181764c
PA
68 done
69) > "$out"