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