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" 69