Linux Audio

Check our new training course

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