BVB Source Codes

goreplay Show mksysnum_linux.pl Source code

Return Download goreplay: download mksysnum_linux.pl Source code - Download goreplay Source code - Type:.pl
  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. use strict;
  7.  
  8. if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
  9.         print STDERR "GOARCH or GOOS not defined in environment\n";
  10.         exit 1;
  11. }
  12.  
  13. my $command = "mksysnum_linux.pl ". join(' ', @ARGV);
  14.  
  15. print <<EOF;
  16. // $command
  17. // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT
  18.  
  19. // +build $ENV{'GOARCH'},$ENV{'GOOS'}
  20.  
  21. package unix
  22.  
  23. const(
  24. EOF
  25.  
  26. my $offset = 0;
  27.  
  28. sub fmt {
  29.         my ($name, $num) = @_;
  30.         if($num > 999){
  31.                 # ignore deprecated syscalls that are no longer implemented
  32.                 # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716
  33.                 return;
  34.         }
  35.         $name =~ y/a-z/A-Z/;
  36.         $num = $num + $offset;
  37.         print " SYS_$name = $num;\n";
  38. }
  39.  
  40. my $prev;
  41. open(GCC, "gcc -E -dD $ARGV[0] |") || die "can't run gcc";
  42. while(<GCC>){
  43.         if(/^#define __NR_Linux\s+([0-9]+)/){
  44.                 # mips/mips64: extract offset
  45.                 $offset = $1;
  46.         }
  47.         elsif(/^#define __NR_syscalls\s+/) {
  48.                 # ignore redefinitions of __NR_syscalls
  49.         }
  50.         elsif(/^#define __NR_(\w+)\s+([0-9]+)/){
  51.                 $prev = $2;
  52.                 fmt($1, $2);
  53.         }
  54.         elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){
  55.                 $prev = $2;
  56.                 fmt($1, $2);
  57.         }
  58.         elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){
  59.                 fmt($1, $prev+$2)
  60.         }
  61.         elsif(/^#define __NR_(\w+)\s+\(__NR_Linux \+ ([0-9]+)/){
  62.                 fmt($1, $2);
  63.         }
  64. }
  65.  
  66. print <<EOF;
  67. )
  68. EOF
  69.  
downloadmksysnum_linux.pl Source code - Download goreplay Source code
Related Source Codes/Software:
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10
django-rest-framework - Web APIs for Django. http:/... 2017-06-10
lectures - Oxford Deep NLP 2017 course 2017-06-10
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
postal - 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10

 Back to top