vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

mkstrsyscall.pl (581B)


      1 #!/usr/bin/perl
      2 
      3 open(SYS, "/usr/include/asm/unistd.h") || die "open /usr/include/asm/unistd.h: $!";
      4 
      5 print <<'EOF';
      6 #include <stdio.h>
      7 #include <asm/unistd.h>
      8 
      9 EOF
     10 
     11 print "static char *syscall_names[] = {\n";
     12 while(<SYS>){
     13 	if(/#define __NR_(\S+)\s+\d+\s*$/) {
     14 		print "\t[__NR_$1]= \"$1\",\n";
     15 	}
     16 }
     17 print "};\n\n";
     18 
     19 print <<'EOF';
     20 
     21 #define nelem(x) (sizeof(x)/sizeof((x)[0]))
     22 
     23 char *strsyscall(int n) {
     24 	if (0 <= n && n < nelem(syscall_names) && syscall_names[n])
     25 		return syscall_names[n];
     26 	static char buf[40];
     27 	snprintf(buf, sizeof buf, "syscall%#x", n);
     28 	return buf;
     29 }
     30 
     31 EOF
     32