syscalls.awk 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. BEGIN {
  2. FS = ",[ ]*";
  3. if (!wrappers_file || !enum_file || !table_file)
  4. {
  5. print "Error: One or more filenames have not been specified.";
  6. exit 1;
  7. }
  8. print "/* This file has been automatically generated */" > enum_file;
  9. print "" >> enum_file;
  10. print "typedef enum" >> enum_file;
  11. print "{" >> enum_file;
  12. print "/* This file has been automatically generated */" > table_file;
  13. print "" >> table_file;
  14. print "const void *service_table[] =" >> table_file;
  15. print "{" >> table_file
  16. print "/* This file has been automatically generated */" > wrappers_file;
  17. print "" >> wrappers_file;
  18. print "#include <sdk/monolithium.h>" >> wrappers_file;
  19. print "" >> wrappers_file;
  20. }
  21. END {
  22. if (enum_file && table_file && wrappers_file) {
  23. print "" >> enum_file;
  24. print " SERVICE_COUNT" >> enum_file;
  25. print "} syscall_number_t;" >> enum_file;
  26. print "};" >> table_file;
  27. }
  28. }
  29. /sysret_t syscall_[a-zA-Z0-9_]+\(.*\);/ {
  30. print substr($0, 1, length - 1) >> wrappers_file;
  31. print "{" >> wrappers_file;
  32. match($0, /\(.*\)/);
  33. name = substr($0, 10, RSTART - 10);
  34. print " &" name "," >> table_file;
  35. print " " toupper(name) "," >> enum_file;
  36. printf " return syscall(" toupper(name) >> wrappers_file;
  37. $0 = substr($0, RSTART + 1, RLENGTH - 2);
  38. if ($0 != "void") {
  39. for (i = 1; i <= NF; i++) {
  40. match($i, /[a-zA-Z0-9_]*$/);
  41. printf ", " substr($i, RSTART) >> wrappers_file;
  42. }
  43. }
  44. print ");" >> wrappers_file;
  45. print "}" >> wrappers_file;
  46. print "" >> wrappers_file;
  47. }