bootrom-asm-offsets.awk 759 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/gawk -f
  2. BEGIN {
  3. print "/* DO NOT EDIT: AUTOMATICALLY GENERATED"
  4. print " * Input files: bootrom-asm-offsets.awk bootrom-asm-offsets.c.in"
  5. print " * DO NOT EDIT: AUTOMATICALLY GENERATED"
  6. print " */"
  7. print ""
  8. system("cat bootrom-asm-offsets.c.in")
  9. print "{"
  10. }
  11. {
  12. /* find a structure definition */
  13. if ($0 ~ /typedef struct .* {/) {
  14. delete members;
  15. i = 0;
  16. /* extract each member of the structure */
  17. while (1) {
  18. getline
  19. if ($1 == "}")
  20. break;
  21. gsub(/[*;]/, "");
  22. members[i++] = $NF;
  23. }
  24. /* grab the structure's name */
  25. struct = $NF;
  26. sub(/;$/, "", struct);
  27. /* output the DEFINE() macros */
  28. while (i-- > 0)
  29. print "\tDEFINE(" struct ", " members[i] ");"
  30. print ""
  31. }
  32. }
  33. END {
  34. print "\treturn 0;"
  35. print "}"
  36. }