syscallhdr.sh 748 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0
  3. in="$1"
  4. out="$2"
  5. my_abis=`echo "($3)" | tr ',' '|'`
  6. prefix="$4"
  7. offset="$5"
  8. fileguard=_ASM_ARM_`basename "$out" | sed \
  9. -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
  10. -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'`
  11. if echo $out | grep -q uapi; then
  12. fileguard="_UAPI$fileguard"
  13. fi
  14. grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | (
  15. echo "#ifndef ${fileguard}"
  16. echo "#define ${fileguard} 1"
  17. echo ""
  18. while read nr abi name entry ; do
  19. if [ -z "$offset" ]; then
  20. echo "#define __NR_${prefix}${name} $nr"
  21. else
  22. echo "#define __NR_${prefix}${name} ($offset + $nr)"
  23. fi
  24. done
  25. echo ""
  26. echo "#endif /* ${fileguard} */"
  27. ) > "$out"