syscallnr.sh 888 B

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