syscalls.awk 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. }