mksysnum_freebsd.pl 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. use strict;
  9. my $command = "mksysnum_freebsd.pl " . join(' ', @ARGV);
  10. print <<EOF;
  11. // $command
  12. // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
  13. package unix
  14. const (
  15. EOF
  16. while(<>){
  17. if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){
  18. my $num = $1;
  19. my $proto = $2;
  20. my $name = "SYS_$3";
  21. $name =~ y/a-z/A-Z/;
  22. # There are multiple entries for enosys and nosys, so comment them out.
  23. if($name =~ /^SYS_E?NOSYS$/){
  24. $name = "// $name";
  25. }
  26. if($name eq 'SYS_SYS_EXIT'){
  27. $name = 'SYS_EXIT';
  28. }
  29. if($name =~ /^SYS_CAP_+/ || $name =~ /^SYS___CAP_+/){
  30. next
  31. }
  32. print " $name = $num; // $proto\n";
  33. # We keep Capsicum syscall numbers for FreeBSD
  34. # 9-STABLE here because we are not sure whether they
  35. # are mature and stable.
  36. if($num == 513){
  37. print " SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }\n";
  38. print " SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \\\n";
  39. print " SYS_CAP_ENTER = 516 // { int cap_enter(void); }\n";
  40. print " SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }\n";
  41. }
  42. }
  43. }
  44. print <<EOF;
  45. )
  46. EOF