syscallhdr.sh 681 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/sh
  2. in="$1"
  3. out="$2"
  4. my_abis=`echo "$3" | tr ',' ' '`
  5. prefix="$4"
  6. offset="$5"
  7. fileguard=_ASM_X86_`basename "$out" | sed \
  8. -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
  9. -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'`
  10. in_list () {
  11. local x
  12. for x in $1; do
  13. if [ x"$x" = x"$2" ]; then
  14. return 0
  15. fi
  16. done
  17. return 1
  18. }
  19. grep '^[0-9]' "$in" | sort -n | (
  20. echo "#ifndef ${fileguard}"
  21. echo "#define ${fileguard} 1"
  22. echo ""
  23. while read nr abi name entry ; do
  24. if in_list "$my_abis" "$abi"; then
  25. echo "#define __NR_${prefix}${name}" $((nr+offset))
  26. fi
  27. done
  28. echo ""
  29. echo "#endif /* ${fileguard} */"
  30. ) > "$out"