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