syscallnr.sh 843 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0
  3. in="$1"
  4. out="$2"
  5. align=1
  6. fileguard=_ASM_ARM_`basename "$out" | sed \
  7. -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
  8. -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'`
  9. grep -E "^[0-9A-Fa-fXx]+[[:space:]]+" "$in" | sort -n | tail -n1 | (
  10. echo "#ifndef ${fileguard}
  11. #define ${fileguard} 1
  12. /*
  13. * This needs to be greater than __NR_last_syscall+1 in order to account
  14. * for the padding in the syscall table.
  15. */
  16. "
  17. while read nr abi name entry; do
  18. nr=$(($nr + 1))
  19. while [ "$(($nr / (256 * $align) ))" -gt 0 ]; do
  20. align=$(( $align * 4 ))
  21. done
  22. nr=$(( ($nr + $align - 1) & ~($align - 1) ))
  23. echo "/* aligned to $align */"
  24. echo "#define __NR_syscalls $nr"
  25. done
  26. echo ""
  27. echo "#endif /* ${fileguard} */"
  28. ) > "$out"