Home | History | Annotate | Download | only in syscall
      1 #!/usr/bin/env perl
      2 # Copyright 2009 The Go Authors. All rights reserved.
      3 # Use of this source code is governed by a BSD-style
      4 # license that can be found in the LICENSE file.
      5 #
      6 # Generate system call table for FreeBSD from master list
      7 # (for example, /usr/src/sys/kern/syscalls.master).
      8 
      9 use strict;
     10 
     11 my $command = "mksysnum_freebsd.pl " . join(' ', @ARGV);
     12 
     13 print <<EOF;
     14 // $command
     15 // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
     16 
     17 package syscall
     18 
     19 const (
     20 EOF
     21 
     22 while(<>){
     23 	if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){
     24 		my $num = $1;
     25 		my $proto = $2;
     26 		my $name = "SYS_$3";
     27 		$name =~ y/a-z/A-Z/;
     28 
     29 		# There are multiple entries for enosys and nosys, so comment them out.
     30 		if($name =~ /^SYS_E?NOSYS$/){
     31 			$name = "// $name";
     32 		}
     33 		if($name eq 'SYS_SYS_EXIT'){
     34 			$name = 'SYS_EXIT';
     35 		}
     36 		if($name =~ /^SYS_CAP_+/ || $name =~ /^SYS___CAP_+/){
     37 			next
     38 		}
     39 
     40 		print "	$name = $num;  // $proto\n";
     41 
     42 		# We keep Capsicum syscall numbers for FreeBSD
     43 		# 9-STABLE here because we are not sure whether they
     44 		# are mature and stable.
     45 		if($num == 513){
     46 			print " SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }\n";
     47 			print " SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \\\n";
     48 			print " SYS_CAP_ENTER = 516 // { int cap_enter(void); }\n";
     49 			print " SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }\n";
     50 		}
     51 	}
     52 }
     53 
     54 print <<EOF;
     55 )
     56 EOF
     57