gen-cpucaps.awk 759 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/awk -f
  2. # SPDX-License-Identifier: GPL-2.0
  3. # gen-cpucaps.awk: arm64 cpucaps header generator
  4. #
  5. # Usage: awk -f gen-cpucaps.awk cpucaps.txt
  6. # Log an error and terminate
  7. function fatal(msg) {
  8. print "Error at line " NR ": " msg > "/dev/stderr"
  9. exit 1
  10. }
  11. # skip blank lines and comment lines
  12. /^$/ { next }
  13. /^#/ { next }
  14. BEGIN {
  15. print "#ifndef __ASM_CPUCAPS_H"
  16. print "#define __ASM_CPUCAPS_H"
  17. print ""
  18. print "/* Generated file - do not edit */"
  19. cap_num = 0
  20. print ""
  21. }
  22. /^[vA-Z0-9_]+$/ {
  23. printf("#define ARM64_%-30s\t%d\n", $0, cap_num++)
  24. next
  25. }
  26. END {
  27. printf("#define ARM64_NCAPS\t\t\t\t%d\n", cap_num)
  28. print ""
  29. print "#endif /* __ASM_CPUCAPS_H */"
  30. }
  31. # Any lines not handled by previous rules are unexpected
  32. {
  33. fatal("unhandled statement")
  34. }