summaryrefslogtreecommitdiff
path: root/src/internal/syscall/unix
Commit message (Collapse)AuthorAgeFilesLines
* os: if descriptor is non-blocking, retain that in Fd methodIan Lance Taylor2023-05-174-0/+16
| | | | | | | | | | | | | | For #58408 Fixes #60211 Change-Id: I30f5678b46e15121865b19d1c0f82698493fad4e Reviewed-on: https://go-review.googlesource.com/c/go/+/495079 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
* net: use and assert correct res state size at compile time when cgo ↵Mateusz Poliwczak2023-05-161-1/+1
| | | | | | | | | | | | | | | available on darwin Change-Id: I961bb18604dd1568ea21431545f43aa6a417b3d9 GitHub-Last-Rev: 735f3364a4f2182f3e3e1b84f39a042e86987967 GitHub-Pull-Request: golang/go#60046 Reviewed-on: https://go-review.googlesource.com/c/go/+/493415 Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com>
* syscall: implement wasip1 SetNonblock and IsNonblockChris O'Hara2023-05-111-1/+17
| | | | | | | | | | | | | | | | | | | | | Allows for the NONBLOCK file descriptor flag to be set and queried on wasip1. syscall.SetNonblock uses the fd_fdstat_set_flags WASI system call and unix.IsNonblock uses the fd_fdstat_get system call. This is a prerequisite for non-blocking I/O support. Change-Id: I2bf79fd57142b2ec53eed3977d9aac8c6337eb80 Reviewed-on: https://go-review.googlesource.com/c/go/+/493356 Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Julien Fabre <ju.pryz@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Achille Roussel <achille.roussel@gmail.com>
* os: make Chtimes accept empty time values to skip file time modificationConstantin Konstantinidis2023-05-1110-0/+41
| | | | | | | | | | | | | | | | Empty time value time.Time{} leaves the corresponding time of the file unchanged. Fixes #32558 Change-Id: I1aff42f30668ff505ecec2e9509d8f2b8e4b1b6a Reviewed-on: https://go-review.googlesource.com/c/go/+/219638 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
* internal: add wasip1 supportJohan Brandhorst-Satzkorn2023-04-072-0/+55
| | | | | | | | | | | | | | | | | | For #58141 Co-authored-by: Richard Musiol <neelance@gmail.com> Co-authored-by: Achille Roussel <achille.roussel@gmail.com> Co-authored-by: Julien Fabre <ju.pryz@gmail.com> Co-authored-by: Evan Phoenix <evan@phx.io> Change-Id: I1488726e5b43cd21c5f83900476afd2fb63d70c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/479622 Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com>
* internal/syscall/unix: fix PosixFallocate error check on freebsdTobias Klauser2023-04-055-28/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | The posix_fallocate syscall returns the result in r1 rather than in errno: > If successful, posix_fallocate() returns zero. It returns an error on failure, without > setting errno. Source: https://man.freebsd.org/cgi/man.cgi?query=posix_fallocate&sektion=2&n=1 Adjust the PosixFallocate wrappers on freebsd to account for that. Also, CL 479715 used the same syscall wrapper for 386 and arm. However, on arm the syscall argument order is different. The wrapper was generated using mksyscall.go from the golang.org/x/sys/unix package, adjusting the r1 check correspondingly. Fixes #59352 Change-Id: I9a4e8e4546237010bc5e730c4988a2a476264cf4 Reviewed-on: https://go-review.googlesource.com/c/go/+/481621 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Yuval Pavel Zholkover <paulzhol@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* net: treat EAI_NODATA as errNoSuchHostMateusz Poliwczak2023-04-041-0/+1
| | | | | | | | | | | | | | | | | | | | man getaddrinfo: EAI_NODATA The specified network host exists, but does not have any network addresses defined. In the go resolver we treat this kind of error as nosuchhost. Change-Id: I69fab6f8da8e3a86907e65104bca9f055968633a GitHub-Last-Rev: b4891e2addaeccecb242d0485daa168bb55cf54e GitHub-Pull-Request: golang/go#57507 Reviewed-on: https://go-review.googlesource.com/c/go/+/459955 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* internal/syscall/unix: fix PosixFallocate on 32-bit freebsdTobias Klauser2023-03-272-0/+22
| | | | | | | | | | | | | | | | | Follow-up for CL 478035 which broke the freebsd/396 builders: https://build.golang.org/log/e6e442cd353024c4fdb64111ad0bcbf5b25b8ecd 64-bit syscall arguments need to be passed as two 32-bit arguments on 32-bit freebsd. Change-Id: Idf4fdf4ab7d112bc2cf95b075a5a29f221bffcb6 Reviewed-on: https://go-review.googlesource.com/c/go/+/479715 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
* cmd/link/internal/ld, internal/syscall/unix: use posix_fallocate on freebsdTobias Klauser2023-03-271-0/+18
| | | | | | | | | | | | | The posix_fallocate system call is available since FreeBSD 9.0, see https://man.freebsd.org/cgi/man.cgi?query=posix_fallocate Change-Id: Ie65e0a44341909707617d3b0d9a4f1710c45b935 Reviewed-on: https://go-review.googlesource.com/c/go/+/478035 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
* internal/syscall/unix: use atomic.Bool for getrandomUnsupportedTobias Klauser2023-01-263-10/+10
| | | | | | | | | Change-Id: I50522ed782dd963f445419fc45495f6608909c47 Reviewed-on: https://go-review.googlesource.com/c/go/+/463124 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
* crypto/rand, internal/syscall/unix: add support for getrandom on NetBSD ≥ 10.0Tobias Klauser2023-01-261-0/+56
| | | | | | | | | | | | The getrandom syscall was added to NetBSD in version 10.0, see https://man.netbsd.org/NetBSD-10.0-STABLE/getrandom.2 Change-Id: I2714c1040791f7f4728be8d869058a38cbd93d4d Reviewed-on: https://go-review.googlesource.com/c/go/+/463123 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Benny Siegert <bsiegert@gmail.com>
* os/user: fix buffer retry loop on macOSRuss Cox2022-12-071-8/+12
| | | | | | | | | | | | | | | | | getpwnam_r and friends return the errno as the result, not in the global errno. The code changes in CL 449316 inadvertently started using the global errno. So if a lookup didn't fit in the first buffer size, it was treated as not found instead of growing the buffer. Fixes #56942. Change-Id: Ic5904fbeb31161bccd858e5adb987e919fb3e9d9 Reviewed-on: https://go-review.googlesource.com/c/go/+/455815 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Russ Cox <rsc@golang.org>
* internal/syscall/unix: use runtime.gostring for GostringIan Lance Taylor2022-11-111-10/+4
| | | | | | | | | | | | | | | | | Under the race detector, checkptr flags uses of unsafe.Slice that result in slices that straddle multiple Go allocations. Avoid that scenario by calling existing runtime code. This fixes a failure on the darwin-.*-race builders introduced in CL 446178. Change-Id: I6e0fdb37e3c3f38d97939a8799bb4d10f519c5b9 Reviewed-on: https://go-review.googlesource.com/c/go/+/449936 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org>
* os/user: use libc (not cgo) on macOSRuss Cox2022-11-113-35/+141
| | | | | | | | | | | | | | | With net converted to libc, os/user is the last remaining cgo code in the standard libary on macOS. Convert it to libc too. Now only plugin remains as a cgo-using package on macOS. Change-Id: Ibb518b5c62ef9ec1e6ab6191f4b576f7c5a4501c Reviewed-on: https://go-review.googlesource.com/c/go/+/449316 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* os/signal/internal/pty: use libc (not cgo) on macOSRuss Cox2022-11-102-0/+77
| | | | | | | | | | | | | | | This package is only used by tests anyway, but might as well remove the cgo use on macOS so that it doesn't show up as a cgo user, as part of our overall strategy to remove cgo use in the standard library on macOS. Change-Id: I5a1a39ed56373385f9d43a5e17098035dc1a451a Reviewed-on: https://go-review.googlesource.com/c/go/+/449315 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* net: unify CNAME handling across portsRuss Cox2022-11-082-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unix and Windows differ in how they handle LookupCNAME(name). If name exists in DNS with an A or AAAA record but no CNAME, then on all operating systems and in the pure Go resolver, LookupCNAME returns the name associated with the A/AAAA record (the original name). TestLookupCNAME has been testing this, because www.google.com has no CNAME. I think it did at one point, but not anymore, and the tests are still passing. Also added google.com as a test, since top-level domains are disallowed from having CNAMEs. If name exists in DNS with a CNAME record pointing to a record that does not exist or that has no A or AAAA record, then Windows has always reported the CNAME value, but Unix-based systems and the pure Go resolver have reported a failure instead. cname-to-txt.go4.org is an test record that is a CNAME to a non-A/AAAA target (the target only has a TXT record). This CL changes the Unix-based systems and the pure Go resolver to match the Windows behavior, allowing LookupCNAME to succeed whenever a CNAME exists. TestLookupCNAME nows tests the new behavior by looking up cname-to-txt.go4.org (run by bradfitz). Fixes #50101. Change-Id: Ieff5026c8535760e6313c7a41ebd5ff24de6d9be Reviewed-on: https://go-review.googlesource.com/c/go/+/446179 Run-TryBot: Russ Cox <rsc@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
* net: use libc (not cgo) for DNS on macOSRuss Cox2022-11-013-4/+128
| | | | | | | | | | | | | | | Change the macOS implementation to use libc calls. Using libc calls directly is what we do for all the runtime and os syscalls. Doing so here as well improves consistency and also makes it possible to cross-compile (from non-Mac systems) macOS binaries that use the native name resolver. Fixes #12524. Change-Id: I011f4fcc5c50fbb5396e494889765dcbb9342336 Reviewed-on: https://go-review.googlesource.com/c/go/+/446178 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
* internal/poll, internal/syscall/unix, syscall: move writev definition for ↵Tobias Klauser2022-10-071-28/+0
| | | | | | | | | | | | | | | | | | solaris Move the writev definition for solaris from package internal/syscall/unix to package syscall. This corresponds to where writev is defined on aix, darwin and openbsd as well and is go:linkname'ed from internal/poll. This also allows updating the generated wrappers more easily if needed. Change-Id: I671ed8232d25319f8e63f549f786d77a17602148 Reviewed-on: https://go-review.googlesource.com/c/go/+/436597 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
* internal/syscall/unix: reuse existing {Fstat,Open,Unlink}at on freebsdTobias Klauser2022-09-194-52/+18
| | | | | | | | | | Change-Id: I517e75faca18bf0fdcd4e6c837f50f824aa6348c Reviewed-on: https://go-review.googlesource.com/c/go/+/431236 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* internal/syscall/unix: remove superfluous var declarations in {Unlink,Open}atTobias Klauser2022-09-151-2/+0
| | | | | | | | | | Change-Id: Id58e3aebf325433768675523bf34c0b7e0e34aea Reviewed-on: https://go-review.googlesource.com/c/go/+/431235 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Jenny Rakoczy <jenny@golang.org> Auto-Submit: Jenny Rakoczy <jenny@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* os/exec: LookPath: use eaccess for exec check on linuxKir Kolyshkin2022-09-074-2/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Having an executable bit set for a binary is not enough for it to be executable -- there might be more checks in the kernel. For example, binaries on a filesystem mounted with "noexec" flag couldn't be executed. There might be other scenarios involving ACLs, SELinux, file capabilities, and so on. As a result, LookPath might either find a non-executable (while going over $PATH elements), or return a false positive that the argument provided is an executable. One possible fix would be to perform the check by using access(2) syscall with X_OK flag. Now, since access(2) uses real (rather than effective) uid and gid, when used by a setuid or setgid binary, it checks permissions of the (real) user who started the binary, rather than the actual effective permissions. Therefore, using access with X_OK won't work as expected for setuid/setgid binaries. To fix this, modern platforms added ways to check against effective uid and gid, with the most common being the faccessat(2) call with the AT_EACCESS flag, as described by POSIX.1-2008 (in Linux, only faccessat2(2) supports flags such as AT_EACCESS). Let's use it, and fall back to checking permission bits if faccessat is not available. Wrap the logic into unix.Eaccess, which is currently only implemented on Linux. While many other OSes (Free/Net/OpenBSD, AIX, Solaris/Illumos, and Darwin) do implement faccessat(2) with AT_EACCESS, it is not wired in syscall package (except for AIX), so these platforms are left out for now. In the future, eaccess can be implemented for these OSes, too. Alas, a call to unix.Eaccess is not enough since we have to filter out directories, so use both stat and Eaccess. One minor change introduced by this commit is that LookPath and Command now returns "is a directory" error when the argument contains a slash and is a directory. This is similar to what e.g. bash does on Linux: $ bash -c /etc bash: line 1: /etc: Is a directory Add a test case, which, unfortunately, requires root, is specific to Linux, and needs a relatively new kernel (supporting faccessat2). Other platforms either have different semantics for tmpfs with noexec, or have different ways to set up a binary which has x bit set but nevertheless could not be executed. Change-Id: If49b6ef6bf4dd23b2c32bebec8832d83e511a4bb Reviewed-on: https://go-review.googlesource.com/c/go/+/414824 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
* internal/poll, internal/syscall/unix, net: enable writev on solarisTobias Klauser2022-09-061-2/+0
| | | | | | | | | | | | | | The writev syscall is available since at least Solaris 11.3. Reuse the existing illumos writev wrapper on solaris to implement internal/poll.writev for net.(*netFD).writeBuffers. Change-Id: I23adc3bb4637740c72bfb61bfa9697b432dfe3db Reviewed-on: https://go-review.googlesource.com/c/go/+/427714 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
* internal/syscall/unix: KernelVersion nitpicksKir Kolyshkin2022-09-051-6/+6
| | | | | | | | | | | A few minor improvements for KernelVersion for the sake of readability. Change-Id: I06d2df60ecee8ee0ae603952470fb73e7dcd5d74 Reviewed-on: https://go-review.googlesource.com/c/go/+/427676 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Heschi Kreinick <heschi@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
* internal/syscall/unix: simplify KernelVersionKir Kolyshkin2022-09-051-9/+2
| | | | | | | | | | | | Since values[2] elements are initialized with 0, the switch statement doesn't do anything. Remove it. Change-Id: I41176692cdf0c01fe8e85315f0c0dc8b0f3d41fd Reviewed-on: https://go-review.googlesource.com/c/go/+/427675 Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* internal/syscall/unix: consolidate kernelVersion implementationsKir Kolyshkin2022-09-032-0/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, there are 3 functions returning Linux kernel version numbers. Two of them are identical: - in net, initially added by commit 0a9dd47dd817904e; - in internal/poll, initially added by commit 1c7650aa93bd53; (both were later fixed by commit 66c02645062561a). The third one is a more complex, regexp-based implementation in runtime/pprof, which is only used for a test. Instead of adding one more, let's consolidate existing ones. Remove the complex implementation, and move the simple one into internal/syscall/unix. Use it from all the three places mentioned above. Change-Id: I4a34d9ca47257743c16def30e4dd634e36056091 Reviewed-on: https://go-review.googlesource.com/c/go/+/424896 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* internal/poll, internal/syscall/unix, net, runtime: convert openbsd (except ↵Tobias Klauser2022-08-317-20/+39
| | | | | | | | | | | | | | | | mips64) to direct libc calls Call libc wrappers directly rather than calling using syscall(2). Updates golang/go#36435 Change-Id: I40be410c7472f7d89cbec2ebdc7c841c7726ca4a Reviewed-on: https://go-review.googlesource.com/c/go/+/425637 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Joel Sing <joel@sing.id.au>
* syscall: update linux/loong64 kernel ABI, emulate fstatat with statxWANG Xuerui2022-05-264-17/+44
| | | | | | | | | | | | | | | | | | | | | | | | | The linux/loong64 kernel ABI has changed a little since the inception of the Go port; most notably fstat and fstatat are being removed [1], leaving only statx as the stat mechanism. Fortunately the structs are easy enough to translate, and we now exclusively use statx across the board on loong64 for best compatibility with past and future kernels (due to the architecture's young age, statx is always available). In wiring up the statx calls, it turned out the linux/loong64 syscall definitions were out-of-date, so the generation script received some tweaking as well. [1]: https://lore.kernel.org/all/20220518092619.1269111-1-chenhuacai@loongson.cn/ Change-Id: Ifebb9ab9fef783683e453fa331d623575e824a48 Reviewed-on: https://go-review.googlesource.com/c/go/+/407694 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: abner chenc <chenguoqi@loongson.cn> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Alex Rakoczy <alex@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org>
* internal/syscall/unix: loong64 use generic syscallXiaodong Liu2022-05-172-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Contributors to the loong64 port are: Weining Lu <luweining@loongson.cn> Lei Wang <wanglei@loongson.cn> Lingqin Gong <gonglingqin@loongson.cn> Xiaolin Zhao <zhaoxiaolin@loongson.cn> Meidan Li <limeidan@loongson.cn> Xiaojuan Zhai <zhaixiaojuan@loongson.cn> Qiyuan Pu <puqiyuan@loongson.cn> Guoqi Chen <chenguoqi@loongson.cn> This port has been updated to Go 1.15.6: https://github.com/loongson/go Updates #46229 Change-Id: I5988bf3efed37b03b9193f1089dfece060ccba99 Reviewed-on: https://go-review.googlesource.com/c/go/+/363934 Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: David Chase <drchase@google.com> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* all: separate doc comment from //go: directivesRuss Cox2022-04-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | A future change to gofmt will rewrite // Doc comment. //go:foo to // Doc comment. // //go:foo Apply that change preemptively to all comments (not necessarily just doc comments). For #51082. Change-Id: Iffe0285418d1e79d34526af3520b415a12203ca9 Reviewed-on: https://go-review.googlesource.com/c/go/+/384260 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* all: use new "unix" build tag where appropriateIan Lance Taylor2022-03-291-1/+1
| | | | | | | | | | For #20322 For #51572 Change-Id: Id0b4799d097d01128e98ba4cc0092298357bca45 Reviewed-on: https://go-review.googlesource.com/c/go/+/389935 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
* os, internal/syscall/unix: consolidate Pipe implementationsTobias Klauser2022-03-081-34/+0
| | | | | | | | | | | | | | | | All platforms with the pipe2 syscall now provide syscall.Pipe2. Use it to implement os.Pipe. This also allows to drop the illumos-specific wrapper in internal/sys/unix. Change-Id: Ieb712a1498e86a389bad261e4e97c61c11d4bdd0 Reviewed-on: https://go-review.googlesource.com/c/go/+/390715 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Trust: Matt Layher <mdlayher@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* net: pass around pointers to SockaddrInetNJosh Bleecher Snyder2021-11-042-8/+8
| | | | | | | | | | | | | ...instead of the structs themselves. Escape analysis can handle this, and it'll avoid a bunch of large struct copies. Change-Id: Ia9c6064ed32a4c26d5a96dae2ed7d7ece6d38704 Reviewed-on: https://go-review.googlesource.com/c/go/+/361264 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* net: remove the alloc from ReadMsgUDPAddrPortJosh Bleecher Snyder2021-11-042-0/+16
| | | | | | | | | | | | | | | | | | name old time/op new time/op delta ReadWriteMsgUDPAddrPort-8 4.95µs ± 5% 4.55µs ± 1% -7.96% (p=0.016 n=5+4) name old alloc/op new alloc/op delta ReadWriteMsgUDPAddrPort-8 32.0B ± 0% 0.0B -100.00% (p=0.008 n=5+5) name old allocs/op new allocs/op delta ReadWriteMsgUDPAddrPort-8 1.00 ± 0% 0.00 -100.00% (p=0.008 n=5+5) Change-Id: Ib968c6f2968926ec9a364dd52063cd0d7c29b10c Reviewed-on: https://go-review.googlesource.com/c/go/+/360862 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* net: remove the alloc from WriteMsgUDPAddrPortJosh Bleecher Snyder2021-11-042-0/+16
| | | | | | | | | | | | | | | | | | name old time/op new time/op delta ReadWriteMsgUDPAddrPort-8 5.12µs ± 8% 4.59µs ± 3% -10.19% (p=0.000 n=10+9) name old alloc/op new alloc/op delta ReadWriteMsgUDPAddrPort-8 64.0B ± 0% 32.0B ± 0% -50.00% (p=0.000 n=10+10) name old allocs/op new allocs/op delta ReadWriteMsgUDPAddrPort-8 2.00 ± 0% 1.00 ± 0% -50.00% (p=0.000 n=10+10) Change-Id: Idf540b2f9f8035660305a0ab1cfc3e162569db63 Reviewed-on: https://go-review.googlesource.com/c/go/+/361257 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* syscall: migrate new UDP send/recv API to internal/syscall/unixJosh Bleecher Snyder2021-11-032-0/+56
| | | | | | | | | | | | CL 331490 and friends added new API to package syscall. This was a mistake that we need to fix before Go 1.18 is released. Change-Id: I697c9a4fa649d564822f585dc163df5ab9e5ae08 Reviewed-on: https://go-review.googlesource.com/c/go/+/361216 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* all: go fix -fix=buildtag std cmd (except for bootstrap deps, vendor)Russ Cox2021-10-2817-18/+0
| | | | | | | | | | | | | | | | | | | | | | | | When these packages are released as part of Go 1.18, Go 1.16 will no longer be supported, so we can remove the +build tags in these files. Ran go fix -fix=buildtag std cmd and then reverted the bootstrapDirs as defined in src/cmd/dist/buildtool.go, which need to continue to build with Go 1.4 for now. Also reverted src/vendor and src/cmd/vendor, which will need to be updated in their own repos first. Manual changes in runtime/pprof/mprof_test.go to adjust line numbers. For #41184. Change-Id: Ic0f93f7091295b6abc76ed5cd6e6746e1280861e Reviewed-on: https://go-review.googlesource.com/c/go/+/344955 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
* crypto/rand, internal/syscall/unix: don't use getentropy on iOSTobias Klauser2021-08-201-0/+3
| | | | | | | | | | | | | | | | CL 302489 switched crypto/rand to use getentropy on darwin, however this function is not available on iOS. Enable getentropy only on macOS and disable it on iOS. Fixes #47812 Change-Id: Ib7ba5d77346aee87904bb93d60cacc845f5c0089 Reviewed-on: https://go-review.googlesource.com/c/go/+/343609 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
* internal/syscall/unix: change Ioctl arg type to unsafe.Pointer on AIXMatt Layher2021-08-161-1/+1
| | | | | | | | | | | | | Without this change, this code is technically in violation of the unsafe.Pointer rules since the conversion from unsafe.Pointer to uintptr has to happen when calling into the syscall6 assembly implementation. Change-Id: I4821f5bf9788c8fa2efeb041f811ed092e07ae74 Reviewed-on: https://go-review.googlesource.com/c/go/+/340949 Trust: Matt Layher <mdlayher@gmail.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* internal/syscall/unix: use internal/abi.FuncPC for syscall wrapperCherry Zhang2021-05-031-4/+2
| | | | | | | | | | | | | Following CL 313230, this is for internal/syscall/unix package. Updates #45702. Change-Id: Ie6d8c1923dfeae56896212393c5c2a6e257648d2 Reviewed-on: https://go-review.googlesource.com/c/go/+/316649 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org>
* crypto/rand, internal/syscall/unix: add support for getentropy syscall on darwinTobias Klauser2021-03-172-0/+40
| | | | | | | | | | | | The getentropy syscall is available on macOS since version 10.12, which is the minimum required version since Go 1.15. Change-Id: I294259af0b11df9669e4dc5fa891d2f2f039d91a Reviewed-on: https://go-review.googlesource.com/c/go/+/302489 Trust: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
* crypto/rand, internal/syscall/unix: add support for getrandom syscall on solarisTobias Klauser2021-03-111-0/+53
| | | | | | | | | | | | | The getrandom syscall is available on Solaris and Illumos, see https://docs.oracle.com/cd/E88353_01/html/E37841/getrandom-2.html and https://illumos.org/man/2/getrandom Change-Id: Id1c65d6a5b2fbc80d20b43d8b32dab137ca950ca Reviewed-on: https://go-review.googlesource.com/c/go/+/299134 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* internal/syscall/unix: unify GetRandom implementationTobias Klauser2021-03-114-102/+42
| | | | | | | | | | | | | | | The implementation of GetRandom for Linux, FreeBSD and DragonflyBSD can be shared. Also remove GRND_INSECURE on DragonflyBSD as pointed out by Ian in the review of CL 269999. Change-Id: I5bf4c1bd51ddb2ad600652a57e0bc1bafa1cf40d Reviewed-on: https://go-review.googlesource.com/c/go/+/299133 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* crypto/rand: supports for getrandom syscall in DragonFlyBSDDavid Carlier2021-03-101-0/+51
| | | | | | | | | | | | | | | Since the 5.7 release, DragonFlyBSD supports as well the getrandom function, the actual stable is 5.8. Change-Id: I2b8fc468771b10ac12b38ea7e8e5314342de6375 GitHub-Last-Rev: c5c496f41898d58f2c6f3ccc81f754792f49edbe GitHub-Pull-Request: golang/go#42617 Reviewed-on: https://go-review.googlesource.com/c/go/+/269999 Run-TryBot: Ian Lance Taylor <iant@golang.org> Trust: Ian Lance Taylor <iant@golang.org> Trust: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
* all: go fmt std cmd (but revert vendor)Russ Cox2021-02-2015-0/+15
| | | | | | | | | | | | | | | | Make all our package sources use Go 1.17 gofmt format (adding //go:build lines). Part of //go:build change (#41184). See https://golang.org/design/draft-gobuild Change-Id: Ia0534360e4957e58cd9a18429c39d0e32a6addb4 Reviewed-on: https://go-review.googlesource.com/c/go/+/294430 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* os, internal/syscall/unix: use pipe2 instead of pipe on illumosTobias Klauser2020-09-161-0/+34
| | | | | | | | | | | | Illumos provides the pipe2 syscall. Add a wrapper to internal/syscall/unix and use it to implement os.Pipe. Change-Id: I26ecdbcae1e8d51f80e2bc8a86fb129826387b1f Reviewed-on: https://go-review.googlesource.com/c/go/+/254981 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* internal/poll, internal/syscall/unix, net: enable writev on illumosTobias Klauser2020-09-151-0/+30
| | | | | | | | | | | | | Illumos supports iovec read/write. Add the writev wrapper to internal/syscall/unix and use it to implement internal/poll.writev for net.(*netFD).writeBuffers. Change-Id: Ie256c2f96aba8e61fb21991788789a049425f792 Reviewed-on: https://go-review.googlesource.com/c/go/+/254638 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Tobias Klauser <tobias.klauser@gmail.com>
* os, internal/poll, internal/syscall/unix: use copy_file_range on LinuxAndrei Tudor Călin2020-04-2810-28/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Linux 4.5 introduced (and Linux 5.3 refined) the copy_file_range system call, which allows file systems the opportunity to implement copy acceleration techniques. This commit adds support for copy_file_range(2) to the os package. Introduce a new ReadFrom method on *os.File, which makes *os.File implement the io.ReaderFrom interface. If dst and src are both files, this enables io.Copy(dst, src) to call dst.ReadFrom(src), which, in turn, will call copy_file_range(2) if possible. If copy_file_range(2) is not supported by the host kernel, or if either of dst or src refers to a non-regular file, ReadFrom falls back to the regular io.Copy code path. Add internal/poll.CopyFileRange, which acquires locks on the appropriate poll.FDs and performs the actual work, as well as internal/syscall/unix.CopyFileRange, which wraps the copy_file_range system call itself at the lowest level. Rework file layout in internal/syscall/unix to accomodate the additional system call numbers needed for copy_file_range. Merge these definitions with the ones used by getrandom(2) into sysnum_linux_$GOARCH.go files. A note on additional optimizations: if dst and src both refer to pipes in the invocation dst.ReadFrom(src), we could, in theory, use the existing splice(2) code in package internal/poll to splice directly from src to dst. Attempting this runs into trouble with the poller, however. If we call splice(src, dst) and see EAGAIN, we cannot know if it came from src not being ready for reading or dst not being ready for writing. The write end of src and the read end of dst are not under our control, so we cannot reliably use the poller to wait for readiness. Therefore, it seems infeasible to use the new ReadFrom method to splice between pipes directly. In conclusion, for now, the only optimization enabled by the new ReadFrom method on *os.File is the copy_file_range optimization. Fixes #36817. Change-Id: I696372639fa0cdf704e3f65414f7321fc7d30adb Reviewed-on: https://go-review.googlesource.com/c/go/+/229101 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* internal/syscall/unix: use libc based fcntl for IsNonblock on aix and solarisTobias Klauser2019-12-302-3/+3
| | | | | | | | | | | On aix and solaris (like on darwin) use libc fcntl to implement IsNonblock instead of Syscall(SYS_FCNTL, ...) which isn't supported. Change-Id: I989b02aa0c90b7e2dae025572867dda277fef8be Reviewed-on: https://go-review.googlesource.com/c/go/+/212600 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* internal/syscall/unix: use fcntl64 on 32-bit GNU/Linux systemsIan Lance Taylor2019-12-232-1/+21
| | | | | | | | | | | | | | Patch up runtime testing to use the libc fcntl function on Darwin, which is what we should be doing anyhow. This is similar to how we handle fcntl on AIX and Solaris. Fixes #36211 Change-Id: I47ad87e11df043ce21496a0d59523dad28960f76 Reviewed-on: https://go-review.googlesource.com/c/go/+/212299 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
* internal/syscall/unix: add support for linux/riscv64Tobias Klauser2019-11-012-6/+6
| | | | | | | | | | | | Based on the riscv-go port. Updates #27532 Change-Id: I3a4d86783fbd625e3ade16d08f87d66e4502f3f7 Reviewed-on: https://go-review.googlesource.com/c/go/+/204660 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>