aboutsummaryrefslogtreecommitdiff
path: root/scripts/codegen/gen_linux_syscalls.pl
blob: f985bad6c99d8df5f3a09270a6abad369df5b1e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/perl -w

use strict;
my %syscalls = ();

while (<>) {
    if (/^#define (__NR_\w+) /) {
	$syscalls{$1} = 1;
    }
}

print <<EOL;
/* Automatically generated with
        gen_linux_syscalls.pl /usr/include/asm/unistd*.h
   Do not edit.
 */
static const struct {
  int syscall_num; const char *syscall_name;
} SYSCALLS_BY_NUMBER[] = {
EOL

for my $k (sort keys %syscalls) {
    my $name = $k;
    $name =~ s/^__NR_//;
    print <<EOL;
#ifdef $k
  { $k, "$name" },
#endif
EOL

}

print <<EOL
  {0, NULL}
};

EOL