syscallhdr.sh 644 字节
Newer Older
1 2 3 4
#!/bin/sh

in="$1"
out="$2"
H
H. Peter Anvin 已提交
5
my_abis=`echo "($3)" | tr ',' '|'`
6 7 8 9 10 11
prefix="$4"
offset="$5"

fileguard=_ASM_X86_`basename "$out" | sed \
    -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
    -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'`
H
H. Peter Anvin 已提交
12
grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | (
13 14 15 16 17
    echo "#ifndef ${fileguard}"
    echo "#define ${fileguard} 1"
    echo ""

    while read nr abi name entry ; do
18 19 20 21 22
	if [ -z "$offset" ]; then
	    echo "#define __NR_${prefix}${name} $nr"
	else
	    echo "#define __NR_${prefix}${name} ($offset + $nr)"
        fi
23 24 25 26 27
    done

    echo ""
    echo "#endif /* ${fileguard} */"
) > "$out"