Loading...
1#!/bin/sh
2
3in="$1"
4out="$2"
5
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
19emit() {
20 abi="$1"
21 nr="$2"
22 entry="$3"
23 compat="$4"
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
32 syscall_macro "$abi" "$nr" "$entry"
33 fi
34 else
35 echo "#ifdef CONFIG_X86_32"
36 if [ -n "$entry" ]; then
37 syscall_macro "$abi" "$nr" "$entry"
38 fi
39 echo "#else"
40 syscall_macro "$abi" "$nr" "$compat"
41 echo "#endif"
42 fi
43}
44
45grep '^[0-9]' "$in" | sort -n | (
46 while read nr abi name entry compat; do
47 abi=`echo "$abi" | tr '[a-z]' '[A-Z]'`
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
64 done
65) > "$out"
1#!/bin/sh
2
3in="$1"
4out="$2"
5
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 if [ "$entry" = "$real_entry" ]; then
14 qualifier=
15 else
16 qualifier=${entry#*/}
17 fi
18
19 echo "__SYSCALL_${abi}($nr, $real_entry, $qualifier)"
20}
21
22emit() {
23 abi="$1"
24 nr="$2"
25 entry="$3"
26 compat="$4"
27
28 if [ "$abi" = "64" -a -n "$compat" ]; then
29 echo "a compat entry for a 64-bit syscall makes no sense" >&2
30 exit 1
31 fi
32
33 if [ -z "$compat" ]; then
34 if [ -n "$entry" ]; then
35 syscall_macro "$abi" "$nr" "$entry"
36 fi
37 else
38 echo "#ifdef CONFIG_X86_32"
39 if [ -n "$entry" ]; then
40 syscall_macro "$abi" "$nr" "$entry"
41 fi
42 echo "#else"
43 syscall_macro "$abi" "$nr" "$compat"
44 echo "#endif"
45 fi
46}
47
48grep '^[0-9]' "$in" | sort -n | (
49 while read nr abi name entry compat; do
50 abi=`echo "$abi" | tr '[a-z]' '[A-Z]'`
51 if [ "$abi" = "COMMON" -o "$abi" = "64" ]; then
52 # COMMON is the same as 64, except that we don't expect X32
53 # programs to use it. Our expectation has nothing to do with
54 # any generated code, so treat them the same.
55 emit 64 "$nr" "$entry" "$compat"
56 elif [ "$abi" = "X32" ]; then
57 # X32 is equivalent to 64 on an X32-compatible kernel.
58 echo "#ifdef CONFIG_X86_X32_ABI"
59 emit 64 "$nr" "$entry" "$compat"
60 echo "#endif"
61 elif [ "$abi" = "I386" ]; then
62 emit "$abi" "$nr" "$entry" "$compat"
63 else
64 echo "Unknown abi $abi" >&2
65 exit 1
66 fi
67 done
68) > "$out"