gen_linux_syscalls.pl 520 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/perl -w
  2. use strict;
  3. my %syscalls = ();
  4. while (<>) {
  5. if (/^#define (__NR_\w+) /) {
  6. $syscalls{$1} = 1;
  7. }
  8. }
  9. print <<EOL;
  10. /* Automatically generated with
  11. gen_linux_syscalls.pl /usr/include/asm/unistd*.h
  12. Do not edit.
  13. */
  14. static const struct {
  15. int syscall_num; const char *syscall_name;
  16. } SYSCALLS_BY_NUMBER[] = {
  17. EOL
  18. for my $k (sort keys %syscalls) {
  19. my $name = $k;
  20. $name =~ s/^__NR_//;
  21. print <<EOL;
  22. #ifdef $k
  23. { $k, "$name" },
  24. #endif
  25. EOL
  26. }
  27. print <<EOL
  28. {0, NULL}
  29. };
  30. EOL