You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.5 KiB

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