1 # Copyright all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <http://www.gnu.org/licenses/agpl-3.0.txt>
3 # Dump syscall numbers under Linux and any other kernel which
4 # promises stable syscall numbers. This is to maintain
6 # DO NOT USE this for *BSDs, none of the current BSD kernels
7 # we know about promise stable syscall numbers, we'll use
8 # Inline::C to support them.
9 eval 'exec perl -S $0 ${1+"$@"}' # no shebang
10 if 0; # running under some shell
15 say '$machine='.(POSIX::uname())[-1];
16 my $cc = $ENV{CC} // 'cc';
17 my @cflags = split(/\s+/, $ENV{CFLAGS} // '-Wall');
18 my $str = do { local $/; <DATA> };
19 my $tmp = File::Temp->newdir('syscall-list-XXXX', TMPDIR => 1);
22 open my $fh, '>', $f or die "open $f $!";
23 print $fh $str or die "print $f $!";
24 close $fh or die "close $f $!";
25 system($cc, '-o', $x, $f, @cflags) == 0 or die "cc failed \$?=$?";
30 #include <sys/syscall.h>
31 #include <sys/ioctl.h>
35 #include <sys/types.h>
39 #define D(x) printf("$" #x " = %ld;\n", (long)x)
52 D(SYS_inotify_add_watch);
53 D(SYS_inotify_rm_watch);
58 #ifdef FS_IOC_GETFLAGS
59 printf("FS_IOC_GETFLAGS=%#lx\nFS_IOC_SETFLAGS=%#lx\n",
60 (unsigned long)FS_IOC_GETFLAGS, (unsigned long)FS_IOC_SETFLAGS);
66 #endif /* Linux, any other OSes with stable syscalls? */
67 printf("size_t=%zu off_t=%zu pid_t=%zu\n",
68 sizeof(size_t), sizeof(off_t), sizeof(pid_t));