X7ROOT File Manager
Current Path:
/opt/golang/1.17.2/src/syscall
opt
/
golang
/
1.17.2
/
src
/
syscall
/
📁
..
📄
asm9_unix1_amd64.s
(1.01 KB)
📄
asm9_unix2_amd64.s
(1.23 KB)
📄
asm_aix_ppc64.s
(540 B)
📄
asm_darwin_amd64.s
(2.82 KB)
📄
asm_darwin_arm64.s
(2.71 KB)
📄
asm_freebsd_arm.s
(2.96 KB)
📄
asm_freebsd_arm64.s
(2.68 KB)
📄
asm_linux_386.s
(5.05 KB)
📄
asm_linux_amd64.s
(3.34 KB)
📄
asm_linux_arm.s
(4 KB)
📄
asm_linux_arm64.s
(2.73 KB)
📄
asm_linux_mips64x.s
(2.71 KB)
📄
asm_linux_mipsx.s
(3.66 KB)
📄
asm_linux_ppc64x.s
(2.69 KB)
📄
asm_linux_riscv64.s
(2.88 KB)
📄
asm_linux_s390x.s
(4.19 KB)
📄
asm_netbsd_arm.s
(2.85 KB)
📄
asm_netbsd_arm64.s
(2.77 KB)
📄
asm_openbsd_386.s
(1.04 KB)
📄
asm_openbsd_amd64.s
(1.04 KB)
📄
asm_openbsd_arm.s
(1.04 KB)
📄
asm_openbsd_arm64.s
(1.04 KB)
📄
asm_openbsd_mips64.s
(2.85 KB)
📄
asm_plan9_386.s
(3.14 KB)
📄
asm_plan9_amd64.s
(3.06 KB)
📄
asm_plan9_arm.s
(3.25 KB)
📄
asm_solaris_amd64.s
(1.79 KB)
📄
asm_unix_386.s
(2.76 KB)
📄
asm_unix_amd64.s
(2.11 KB)
📄
bpf_bsd.go
(4.67 KB)
📄
bpf_darwin.go
(3.97 KB)
📄
const_plan9.go
(1.2 KB)
📄
creds_test.go
(3.34 KB)
📄
dir_plan9.go
(5.62 KB)
📄
dirent.go
(3.1 KB)
📄
dirent_test.go
(3.15 KB)
📄
dll_windows.go
(10.19 KB)
📄
endian_big.go
(283 B)
📄
endian_little.go
(365 B)
📄
env_unix.go
(3 KB)
📄
env_windows.go
(1.75 KB)
📄
errors_plan9.go
(1.61 KB)
📄
exec_aix_test.go
(831 B)
📄
exec_bsd.go
(6.98 KB)
📄
exec_libc.go
(7.44 KB)
📄
exec_libc2.go
(7.48 KB)
📄
exec_linux.go
(18.98 KB)
📄
exec_linux_test.go
(19.07 KB)
📄
exec_plan9.go
(13.23 KB)
📄
exec_solaris_test.go
(827 B)
📄
exec_unix.go
(8.93 KB)
📄
exec_unix_test.go
(7.2 KB)
📄
exec_windows.go
(11.09 KB)
📄
exec_windows_test.go
(3.1 KB)
📄
export_darwin_test.go
(314 B)
📄
export_freebsd_test.go
(304 B)
📄
export_linux_test.go
(252 B)
📄
export_unix_test.go
(396 B)
📄
export_windows_test.go
(439 B)
📄
flock.go
(753 B)
📄
flock_aix.go
(564 B)
📄
flock_darwin.go
(405 B)
📄
flock_linux_32bit.go
(565 B)
📄
forkpipe.go
(527 B)
📄
forkpipe2.go
(339 B)
📄
fs_js.go
(10.56 KB)
📄
getdirentries_test.go
(2.11 KB)
📁
js
📄
lsf_linux.go
(2.12 KB)
📄
mkall.sh
(12.79 KB)
📄
mkasm.go
(1.76 KB)
📄
mkerrors.sh
(10.65 KB)
📄
mkpost.go
(1.99 KB)
📄
mksyscall.pl
(9.95 KB)
📄
mksyscall_libc.pl
(7.98 KB)
📄
mksyscall_windows.go
(2 KB)
📄
mksysctl_openbsd.pl
(5.04 KB)
📄
mksysnum_dragonfly.pl
(866 B)
📄
mksysnum_freebsd.pl
(1.35 KB)
📄
mksysnum_linux.pl
(1.26 KB)
📄
mksysnum_netbsd.pl
(1.01 KB)
📄
mksysnum_openbsd.pl
(872 B)
📄
mksysnum_plan9.sh
(459 B)
📄
mmap_unix_test.go
(623 B)
📄
msan.go
(425 B)
📄
msan0.go
(358 B)
📄
net.go
(1.19 KB)
📄
net_js.go
(2.14 KB)
📄
netlink_linux.go
(4.67 KB)
📄
ptrace_darwin.go
(396 B)
📄
ptrace_ios.go
(382 B)
📄
pwd_plan9.go
(1.55 KB)
📄
route_bsd.go
(9.15 KB)
📄
route_darwin.go
(2.01 KB)
📄
route_dragonfly.go
(2.61 KB)
📄
route_freebsd.go
(2.67 KB)
📄
route_freebsd_32bit.go
(1.33 KB)
📄
route_freebsd_64bit.go
(776 B)
📄
route_netbsd.go
(1.43 KB)
📄
route_openbsd.go
(1.46 KB)
📄
security_windows.go
(10.12 KB)
📄
setuidgid_32_linux.go
(469 B)
📄
setuidgid_linux.go
(447 B)
📄
sock_cloexec_linux.go
(632 B)
📄
sockcmsg_dragonfly.go
(547 B)
📄
sockcmsg_linux.go
(1.12 KB)
📄
sockcmsg_unix.go
(2.65 KB)
📄
sockcmsg_unix_other.go
(1.14 KB)
📄
syscall.go
(3.61 KB)
📄
syscall_aix.go
(18.05 KB)
📄
syscall_aix_ppc64.go
(405 B)
📄
syscall_bsd.go
(14.39 KB)
📄
syscall_bsd_test.go
(1.21 KB)
📄
syscall_darwin.go
(11.93 KB)
📄
syscall_darwin_amd64.go
(1.92 KB)
📄
syscall_darwin_arm64.go
(1.84 KB)
📄
syscall_dragonfly.go
(8.29 KB)
📄
syscall_dragonfly_amd64.go
(1.12 KB)
📄
syscall_dup2_linux.go
(409 B)
📄
syscall_dup3_linux.go
(275 B)
📄
syscall_freebsd.go
(15.82 KB)
📄
syscall_freebsd_386.go
(1.17 KB)
📄
syscall_freebsd_amd64.go
(1.12 KB)
📄
syscall_freebsd_arm.go
(1.16 KB)
📄
syscall_freebsd_arm64.go
(1.12 KB)
📄
syscall_freebsd_test.go
(1.37 KB)
📄
syscall_illumos.go
(1.2 KB)
📄
syscall_js.go
(6.64 KB)
📄
syscall_linux.go
(33.3 KB)
📄
syscall_linux_386.go
(10.63 KB)
📄
syscall_linux_amd64.go
(5.34 KB)
📄
syscall_linux_arm.go
(7.32 KB)
📄
syscall_linux_arm64.go
(6.68 KB)
📄
syscall_linux_mips64x.go
(6.54 KB)
📄
syscall_linux_mipsx.go
(6.98 KB)
📄
syscall_linux_ppc64x.go
(5.19 KB)
📄
syscall_linux_riscv64.go
(6.32 KB)
📄
syscall_linux_s390x.go
(8.59 KB)
📄
syscall_linux_test.go
(20.69 KB)
📄
syscall_netbsd.go
(7.59 KB)
📄
syscall_netbsd_386.go
(716 B)
📄
syscall_netbsd_amd64.go
(709 B)
📄
syscall_netbsd_arm.go
(716 B)
📄
syscall_netbsd_arm64.go
(709 B)
📄
syscall_openbsd.go
(6.67 KB)
📄
syscall_openbsd1.go
(634 B)
📄
syscall_openbsd_386.go
(715 B)
📄
syscall_openbsd_amd64.go
(701 B)
📄
syscall_openbsd_arm.go
(715 B)
📄
syscall_openbsd_arm64.go
(906 B)
📄
syscall_openbsd_libc.go
(3.46 KB)
📄
syscall_openbsd_mips64.go
(906 B)
📄
syscall_plan9.go
(8.94 KB)
📄
syscall_plan9_test.go
(1.15 KB)
📄
syscall_ptrace_test.go
(824 B)
📄
syscall_solaris.go
(15.07 KB)
📄
syscall_solaris_amd64.go
(487 B)
📄
syscall_test.go
(1.44 KB)
📄
syscall_unix.go
(8.46 KB)
📄
syscall_unix_test.go
(10.4 KB)
📄
syscall_windows.go
(46.08 KB)
📄
syscall_windows_test.go
(3.39 KB)
📄
tables_js.go
(19.19 KB)
📄
time_fake.go
(696 B)
📄
time_nofake.go
(371 B)
📄
timestruct.go
(1.07 KB)
📄
types_aix.go
(3.37 KB)
📄
types_darwin.go
(5.05 KB)
📄
types_dragonfly.go
(5.06 KB)
📄
types_freebsd.go
(6.98 KB)
📄
types_illumos_amd64.go
(397 B)
📄
types_linux.go
(10.7 KB)
📄
types_netbsd.go
(4.78 KB)
📄
types_openbsd.go
(5.06 KB)
📄
types_solaris.go
(4.9 KB)
📄
types_windows.go
(27.71 KB)
📄
types_windows_386.go
(477 B)
📄
types_windows_amd64.go
(477 B)
📄
types_windows_arm.go
(477 B)
📄
types_windows_arm64.go
(477 B)
📄
zerrors_aix_ppc64.go
(47.16 KB)
📄
zerrors_darwin_amd64.go
(55.3 KB)
📄
zerrors_darwin_arm64.go
(55.81 KB)
📄
zerrors_dragonfly_amd64.go
(59.65 KB)
📄
zerrors_freebsd_386.go
(67.38 KB)
📄
zerrors_freebsd_amd64.go
(67.42 KB)
📄
zerrors_freebsd_arm.go
(67.37 KB)
📄
zerrors_freebsd_arm64.go
(67.43 KB)
📄
zerrors_linux_386.go
(58.33 KB)
📄
zerrors_linux_amd64.go
(58.37 KB)
📄
zerrors_linux_arm.go
(58.86 KB)
📄
zerrors_linux_arm64.go
(69.54 KB)
📄
zerrors_linux_mips.go
(70.14 KB)
📄
zerrors_linux_mips64.go
(69.46 KB)
📄
zerrors_linux_mips64le.go
(69.46 KB)
📄
zerrors_linux_mipsle.go
(70.14 KB)
📄
zerrors_linux_ppc64.go
(71.86 KB)
📄
zerrors_linux_ppc64le.go
(72.82 KB)
📄
zerrors_linux_riscv64.go
(71.76 KB)
📄
zerrors_linux_s390x.go
(74.28 KB)
📄
zerrors_netbsd_386.go
(67.5 KB)
📄
zerrors_netbsd_amd64.go
(67.09 KB)
📄
zerrors_netbsd_arm.go
(66.51 KB)
📄
zerrors_netbsd_arm64.go
(67.09 KB)
📄
zerrors_openbsd_386.go
(62.54 KB)
📄
zerrors_openbsd_amd64.go
(62.5 KB)
📄
zerrors_openbsd_arm.go
(62.49 KB)
📄
zerrors_openbsd_arm64.go
(66.36 KB)
📄
zerrors_openbsd_mips64.go
(66.66 KB)
📄
zerrors_solaris_amd64.go
(50.74 KB)
📄
zerrors_windows.go
(9.97 KB)
📄
zsyscall_aix_ppc64.go
(40.16 KB)
📄
zsyscall_darwin_amd64.go
(50.65 KB)
📄
zsyscall_darwin_amd64.s
(8.64 KB)
📄
zsyscall_darwin_arm64.go
(50.6 KB)
📄
zsyscall_darwin_arm64.s
(8.61 KB)
📄
zsyscall_dragonfly_amd64.go
(31.21 KB)
📄
zsyscall_freebsd_386.go
(33.58 KB)
📄
zsyscall_freebsd_amd64.go
(33.44 KB)
📄
zsyscall_freebsd_arm.go
(33.6 KB)
📄
zsyscall_freebsd_arm64.go
(33.44 KB)
📄
zsyscall_linux_386.go
(34.35 KB)
📄
zsyscall_linux_amd64.go
(39.48 KB)
📄
zsyscall_linux_arm.go
(38.57 KB)
📄
zsyscall_linux_arm64.go
(37.74 KB)
📄
zsyscall_linux_mips.go
(40.33 KB)
📄
zsyscall_linux_mips64.go
(40.12 KB)
📄
zsyscall_linux_mips64le.go
(40.12 KB)
📄
zsyscall_linux_mipsle.go
(40.34 KB)
📄
zsyscall_linux_ppc64.go
(40.76 KB)
📄
zsyscall_linux_ppc64le.go
(40.76 KB)
📄
zsyscall_linux_riscv64.go
(37.77 KB)
📄
zsyscall_linux_s390x.go
(34.76 KB)
📄
zsyscall_netbsd_386.go
(29.65 KB)
📄
zsyscall_netbsd_amd64.go
(29.51 KB)
📄
zsyscall_netbsd_arm.go
(29.65 KB)
📄
zsyscall_netbsd_arm64.go
(29.51 KB)
📄
zsyscall_openbsd_386.go
(46.85 KB)
📄
zsyscall_openbsd_386.s
(7.89 KB)
📄
zsyscall_openbsd_amd64.go
(46.71 KB)
📄
zsyscall_openbsd_amd64.s
(7.89 KB)
📄
zsyscall_openbsd_arm.go
(46.87 KB)
📄
zsyscall_openbsd_arm.s
(7.89 KB)
📄
zsyscall_openbsd_arm64.go
(46.71 KB)
📄
zsyscall_openbsd_arm64.s
(7.89 KB)
📄
zsyscall_openbsd_mips64.go
(30.35 KB)
📄
zsyscall_plan9_386.go
(6.19 KB)
📄
zsyscall_plan9_amd64.go
(6.2 KB)
📄
zsyscall_plan9_arm.go
(6.19 KB)
📄
zsyscall_solaris_amd64.go
(35.82 KB)
📄
zsyscall_windows.go
(56.68 KB)
📄
zsysctl_openbsd.go
(11.71 KB)
📄
zsysnum_darwin_amd64.go
(14.57 KB)
📄
zsysnum_darwin_arm64.go
(14.41 KB)
📄
zsysnum_dragonfly_amd64.go
(22.97 KB)
📄
zsysnum_freebsd_386.go
(25.67 KB)
📄
zsysnum_freebsd_amd64.go
(25.68 KB)
📄
zsysnum_freebsd_arm.go
(25.67 KB)
📄
zsysnum_freebsd_arm64.go
(36.12 KB)
📄
zsysnum_linux_386.go
(11.29 KB)
📄
zsysnum_linux_amd64.go
(10.13 KB)
📄
zsysnum_linux_arm.go
(11.57 KB)
📄
zsysnum_linux_arm64.go
(8.97 KB)
📄
zsysnum_linux_mips.go
(12.1 KB)
📄
zsysnum_linux_mips64.go
(10.93 KB)
📄
zsysnum_linux_mips64le.go
(10.93 KB)
📄
zsysnum_linux_mipsle.go
(12.1 KB)
📄
zsysnum_linux_ppc64.go
(11.49 KB)
📄
zsysnum_linux_ppc64le.go
(11.51 KB)
📄
zsysnum_linux_riscv64.go
(8.88 KB)
📄
zsysnum_linux_s390x.go
(10.64 KB)
📄
zsysnum_netbsd_386.go
(25.71 KB)
📄
zsysnum_netbsd_amd64.go
(25.71 KB)
📄
zsysnum_netbsd_arm.go
(25.71 KB)
📄
zsysnum_netbsd_arm64.go
(25.71 KB)
📄
zsysnum_openbsd_386.go
(14.18 KB)
📄
zsysnum_openbsd_amd64.go
(14.18 KB)
📄
zsysnum_openbsd_arm.go
(14.48 KB)
📄
zsysnum_openbsd_arm64.go
(14.72 KB)
📄
zsysnum_openbsd_mips64.go
(14.93 KB)
📄
zsysnum_plan9.go
(1.03 KB)
📄
zsysnum_solaris_amd64.go
(317 B)
📄
ztypes_aix_ppc64.go
(4.17 KB)
📄
ztypes_darwin_amd64.go
(6.97 KB)
📄
ztypes_darwin_arm64.go
(6.97 KB)
📄
ztypes_dragonfly_amd64.go
(6.73 KB)
📄
ztypes_freebsd_386.go
(9.03 KB)
📄
ztypes_freebsd_amd64.go
(9.03 KB)
📄
ztypes_freebsd_arm.go
(9.04 KB)
📄
ztypes_freebsd_arm64.go
(9.03 KB)
📄
ztypes_linux_386.go
(11.57 KB)
📄
ztypes_linux_amd64.go
(11.94 KB)
📄
ztypes_linux_arm.go
(11.46 KB)
📄
ztypes_linux_arm64.go
(10.15 KB)
📄
ztypes_linux_mips.go
(9.93 KB)
📄
ztypes_linux_mips64.go
(10.05 KB)
📄
ztypes_linux_mips64le.go
(10.05 KB)
📄
ztypes_linux_mipsle.go
(9.93 KB)
📄
ztypes_linux_ppc64.go
(10.24 KB)
📄
ztypes_linux_ppc64le.go
(10.37 KB)
📄
ztypes_linux_riscv64.go
(10.2 KB)
📄
ztypes_linux_s390x.go
(10.39 KB)
📄
ztypes_netbsd_386.go
(6.01 KB)
📄
ztypes_netbsd_amd64.go
(6.19 KB)
📄
ztypes_netbsd_arm.go
(6.15 KB)
📄
ztypes_netbsd_arm64.go
(6.19 KB)
📄
ztypes_openbsd_386.go
(6.75 KB)
📄
ztypes_openbsd_amd64.go
(6.91 KB)
📄
ztypes_openbsd_arm.go
(6.84 KB)
📄
ztypes_openbsd_arm64.go
(6.66 KB)
📄
ztypes_openbsd_mips64.go
(6.66 KB)
📄
ztypes_solaris_amd64.go
(5.59 KB)
Editing: mksyscall.pl
#!/usr/bin/env perl # Copyright 2009 The Go Authors. All rights reserved. # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. # This program reads a file containing function prototypes # (like syscall_darwin.go) and generates system call bodies. # The prototypes are marked by lines beginning with "//sys" # and read like func declarations if //sys is replaced by func, but: # * The parameter lists must give a name for each argument. # This includes return parameters. # * The parameter lists must give a type for each argument: # the (x, y, z int) shorthand is not allowed. # * If the return parameter is an error number, it must be named errno. # A line beginning with //sysnb is like //sys, except that the # goroutine will not be suspended during the execution of the system # call. This must only be used for system calls which can never # block, as otherwise the system call could cause all goroutines to # hang. use strict; my $cmdline = "mksyscall.pl " . join(' ', @ARGV); my $errors = 0; my $_32bit = ""; my $plan9 = 0; my $darwin = 0; my $openbsd = 0; my $netbsd = 0; my $dragonfly = 0; my $arm = 0; # 64-bit value should use (even, odd)-pair my $libc = 0; my $tags = ""; # build tags my $newtags = ""; # new style build tags my $extraimports = ""; if($ARGV[0] eq "-b32") { $_32bit = "big-endian"; shift; } elsif($ARGV[0] eq "-l32") { $_32bit = "little-endian"; shift; } if($ARGV[0] eq "-plan9") { $plan9 = 1; shift; } if($ARGV[0] eq "-darwin") { $darwin = 1; $libc = 1; shift; } if($ARGV[0] eq "-openbsd") { $openbsd = 1; shift; } if($ARGV[0] eq "-netbsd") { $netbsd = 1; shift; } if($ARGV[0] eq "-dragonfly") { $dragonfly = 1; shift; } if($ARGV[0] eq "-arm") { $arm = 1; shift; } if($ARGV[0] eq "-libc") { $libc = 1; shift; } if($ARGV[0] eq "-tags") { shift; $tags = $ARGV[0]; shift; } if($ARGV[0] =~ /^-/) { print STDERR "usage: mksyscall.pl [-b32 | -l32] [-tags x,y] [file ...]\n"; exit 1; } if($libc) { $extraimports = 'import "internal/abi"'; } sub parseparamlist($) { my ($list) = @_; $list =~ s/^\s*//; $list =~ s/\s*$//; if($list eq "") { return (); } return split(/\s*,\s*/, $list); } sub parseparam($) { my ($p) = @_; if($p !~ /^(\S*) (\S*)$/) { print STDERR "$ARGV:$.: malformed parameter: $p\n"; $errors = 1; return ("xx", "int"); } return ($1, $2); } # set of trampolines we've already generated my %trampolines; my $text = ""; while(<>) { chomp; s/\s+/ /g; s/^\s+//; s/\s+$//; my $nonblock = /^\/\/sysnb /; next if !/^\/\/sys / && !$nonblock; # Line must be of the form # func Open(path string, mode int, perm int) (fd int, errno error) # Split into name, in params, out params. if(!/^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*((?i)_?SYS_[A-Z0-9_]+))?$/) { print STDERR "$ARGV:$.: malformed //sys declaration\n"; $errors = 1; next; } my ($func, $in, $out, $sysname) = ($2, $3, $4, $5); # Split argument lists on comma. my @in = parseparamlist($in); my @out = parseparamlist($out); # Try in vain to keep people from editing this file. # The theory is that they jump into the middle of the file # without reading the header. $text .= "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n"; if (($darwin && $func eq "ptrace1") || (($openbsd && $libc) && $func eq "ptrace")) { # The ptrace function is called from forkAndExecInChild where stack # growth is forbidden. $text .= "//go:nosplit\n" } # Go function header. my $out_decl = @out ? sprintf(" (%s)", join(', ', @out)) : ""; $text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out_decl; # Check if err return available my $errvar = ""; foreach my $p (@out) { my ($name, $type) = parseparam($p); if($type eq "error") { $errvar = $name; last; } } # Prepare arguments to Syscall. my @args = (); my $n = 0; foreach my $p (@in) { my ($name, $type) = parseparam($p); if($type =~ /^\*/) { push @args, "uintptr(unsafe.Pointer($name))"; } elsif($type eq "string" && $errvar ne "") { $text .= "\tvar _p$n *byte\n"; $text .= "\t_p$n, $errvar = BytePtrFromString($name)\n"; $text .= "\tif $errvar != nil {\n\t\treturn\n\t}\n"; push @args, "uintptr(unsafe.Pointer(_p$n))"; $n++; } elsif($type eq "string") { print STDERR "$ARGV:$.: $func uses string arguments, but has no error return\n"; $text .= "\tvar _p$n *byte\n"; $text .= "\t_p$n, _ = BytePtrFromString($name)\n"; push @args, "uintptr(unsafe.Pointer(_p$n))"; $n++; } elsif($type =~ /^\[\](.*)/) { # Convert slice into pointer, length. # Have to be careful not to take address of &a[0] if len == 0: # pass dummy pointer in that case. # Used to pass nil, but some OSes or simulators reject write(fd, nil, 0). $text .= "\tvar _p$n unsafe.Pointer\n"; $text .= "\tif len($name) > 0 {\n\t\t_p$n = unsafe.Pointer(\&${name}[0])\n\t}"; $text .= " else {\n\t\t_p$n = unsafe.Pointer(&_zero)\n\t}"; $text .= "\n"; push @args, "uintptr(_p$n)", "uintptr(len($name))"; $n++; } elsif($type eq "int64" && ($openbsd || $netbsd)) { if (!$libc) { push @args, "0"; } if($libc && $arm && @args % 2) { # arm abi specifies 64 bit argument must be 64 bit aligned. push @args, "0" } if($_32bit eq "big-endian") { push @args, "uintptr($name>>32)", "uintptr($name)"; } elsif($_32bit eq "little-endian") { push @args, "uintptr($name)", "uintptr($name>>32)"; } else { push @args, "uintptr($name)"; } } elsif($type eq "int64" && $dragonfly) { if ($func !~ /^extp(read|write)/i) { push @args, "0"; } if($_32bit eq "big-endian") { push @args, "uintptr($name>>32)", "uintptr($name)"; } elsif($_32bit eq "little-endian") { push @args, "uintptr($name)", "uintptr($name>>32)"; } else { push @args, "uintptr($name)"; } } elsif($type eq "int64" && $_32bit ne "") { if(@args % 2 && $arm) { # arm abi specifies 64-bit argument uses # (even, odd) pair push @args, "0" } if($_32bit eq "big-endian") { push @args, "uintptr($name>>32)", "uintptr($name)"; } else { push @args, "uintptr($name)", "uintptr($name>>32)"; } } else { push @args, "uintptr($name)"; } } # Determine which form to use; pad args with zeros. my $asm = "Syscall"; if ($nonblock) { if ($errvar eq "" && $ENV{'GOOS'} eq "linux") { $asm = "rawSyscallNoError"; } else { $asm = "RawSyscall"; } } if ($libc) { # Call unexported syscall functions (which take # libc functions instead of syscall numbers). $asm = lcfirst($asm); } if(@args <= 3) { while(@args < 3) { push @args, "0"; } } elsif(@args <= 6) { $asm .= "6"; while(@args < 6) { push @args, "0"; } } elsif(@args <= 9) { $asm .= "9"; while(@args < 9) { push @args, "0"; } } else { print STDERR "$ARGV:$.: too many arguments to system call\n"; } if ($darwin || ($openbsd && $libc)) { # Use extended versions for calls that generate a 64-bit result. my ($name, $type) = parseparam($out[0]); if ($type eq "int64" || ($type eq "uintptr" && $_32bit eq "")) { $asm .= "X"; } } # System call number. my $funcname = ""; if($sysname eq "") { $sysname = "SYS_$func"; $sysname =~ s/([a-z])([A-Z])/${1}_$2/g; # turn FooBar into Foo_Bar $sysname =~ y/a-z/A-Z/; if($libc) { $sysname =~ y/A-Z/a-z/; $sysname = substr $sysname, 4; $funcname = "libc_$sysname"; } } if($libc) { if($funcname eq "") { $sysname = substr $sysname, 4; $funcname = "libc_$sysname"; } $sysname = "abi.FuncPCABI0(${funcname}_trampoline)"; } # Actual call. my $args = join(', ', @args); my $call = "$asm($sysname, $args)"; # Assign return values. my $body = ""; my @ret = ("_", "_", "_"); my $do_errno = 0; for(my $i=0; $i<@out; $i++) { my $p = $out[$i]; my ($name, $type) = parseparam($p); my $reg = ""; if($name eq "err" && !$plan9) { $reg = "e1"; $ret[2] = $reg; $do_errno = 1; } elsif($name eq "err" && $plan9) { $ret[0] = "r0"; $ret[2] = "e1"; next; } else { $reg = sprintf("r%d", $i); $ret[$i] = $reg; } if($type eq "bool") { $reg = "$reg != 0"; } if($type eq "int64" && $_32bit ne "") { # 64-bit number in r1:r0 or r0:r1. if($i+2 > @out) { print STDERR "$ARGV:$.: not enough registers for int64 return\n"; } if($_32bit eq "big-endian") { $reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i, $i+1); } else { $reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i+1, $i); } $ret[$i] = sprintf("r%d", $i); $ret[$i+1] = sprintf("r%d", $i+1); } if($reg ne "e1" || $plan9) { $body .= "\t$name = $type($reg)\n"; } } if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") { $text .= "\t$call\n"; } else { if ($errvar eq "" && $ENV{'GOOS'} eq "linux") { # raw syscall without error on Linux, see golang.org/issue/22924 $text .= "\t$ret[0], $ret[1] := $call\n"; } else { $text .= "\t$ret[0], $ret[1], $ret[2] := $call\n"; } } $text .= $body; if ($plan9 && $ret[2] eq "e1") { $text .= "\tif int32(r0) == -1 {\n"; $text .= "\t\terr = e1\n"; $text .= "\t}\n"; } elsif ($do_errno) { $text .= "\tif e1 != 0 {\n"; $text .= "\t\terr = errnoErr(e1)\n"; $text .= "\t}\n"; } $text .= "\treturn\n"; $text .= "}\n\n"; if($libc) { if (not exists $trampolines{$funcname}) { $trampolines{$funcname} = 1; # The assembly trampoline that jumps to the libc routine. $text .= "func ${funcname}_trampoline()\n\n"; # Tell the linker that funcname can be found in libSystem using varname without the libc_ prefix. my $basename = substr $funcname, 5; my $libc = "libc.so"; if ($darwin) { $libc = "/usr/lib/libSystem.B.dylib"; } $text .= "//go:cgo_import_dynamic $funcname $basename \"$libc\"\n\n"; } } } chomp $text; chomp $text; if($errors) { exit 1; } # TODO: this assumes tags are just simply comma separated. For now this is all the uses. $newtags = $tags =~ s/,/ && /r; print <<EOF; // $cmdline // Code generated by the command above; DO NOT EDIT. //go:build $newtags // +build $tags package syscall import "unsafe" $extraimports $text EOF exit 0;
Upload File
Create Folder