summaryrefslogtreecommitdiff
path: root/src/internal/syscall/unix
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* internal/syscall/unix: remove unused *Trap constsTobias Klauser2019-10-141-4/+0
| | | | | | | | | | | These are unused since the darwin port switched to libc calls in CL 148457. Change-Id: I309bb5b0a52c9069484e7a649d4a652efcb8e160 Reviewed-on: https://go-review.googlesource.com/c/go/+/200866 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* all: remove the nacl port (part 1)Brad Fitzpatrick2019-10-091-9/+0
| | | | | | | | | | | | | | | | | | You were a useful port and you've served your purpose. Thanks for all the play. A subsequent CL will remove amd64p32 (including assembly files and toolchain bits) and remaining bits. The amd64p32 removal will be separated into its own CL in case we want to support the Linux x32 ABI in the future and want our old amd64p32 support as a starting point. Updates #30439 Change-Id: Ia3a0c7d49804adc87bf52a4dea7e3d3007f2b1cd Reviewed-on: https://go-review.googlesource.com/c/go/+/199499 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* cmd/compile: allow bodyless function if it is linkname'dKeith Randall2018-11-261-5/+0
| | | | | | | | | | | | | | | | | | | | | In assembly free packages (aka "complete" or "pure go"), allow bodyless functions if they are linkname'd to something else. Presumably the thing the function is linkname'd to has a definition. If not, the linker will complain. And linkname is unsafe, so we expect users to know what they are doing. Note this handles only one direction, where the linkname directive is in the local package. If the linkname directive is in the remote package, this CL won't help. (See os/signal/sig.s for an example.) Fixes #23311 Change-Id: I824361b4b582ee05976d94812e5b0e8b0f7a18a6 Reviewed-on: https://go-review.googlesource.com/c/151318 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
* internal/syscall/unix: use libc calls on DarwinKeith Randall2018-11-082-1/+32
| | | | | | | | | Add unexported unlinkat, openat, and fstatat calls, so that the internal/syscall/unix package can use them. Change-Id: I1df81ecae6427211dd392ec68c9f020fe131a526 Reviewed-on: https://go-review.googlesource.com/c/148457 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* syscall: implement syscalls on Darwin using libSystemKeith Randall2018-11-073-1/+30
| | | | | | | | | | | | | | | | | | | | | | There are still some references to the bare Syscall functions in the stdlib. I will root those out in a following CL. (This CL is big enough as it is.) Most are in vendor directories: cmd/vendor/golang.org/x/sys/unix/ vendor/golang_org/x/net/route/syscall.go syscall/bpf_bsd.go syscall/exec_unix.go syscall/flock.go Update #17490 Change-Id: I69ab707811530c26b652b291cadee92f5bf5c1a4 Reviewed-on: https://go-review.googlesource.com/c/141639 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Elias Naur <elias.naur@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* os: add support for long path names on aix RemoveAllTobias Klauser2018-11-024-63/+85
| | | | | | | | | | | | | Follow CL 146020 and enable RemoveAll based on Unlinkat and Openat on aix. Updates #27029 Change-Id: I78b34ed671166ee6fa651d5f2025b88548ee6c68 Reviewed-on: https://go-review.googlesource.com/c/146937 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Clément Chigot <clement.chigot@atos.net> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* os: add support for long path names on freebsd RemoveAllTobias Klauser2018-11-013-15/+48
| | | | | | | | | | | | | | | | | | | Follow CL 146020 and enable RemoveAll based on Unlinkat and Openat on freebsd. Since the layout of syscall.Stat_t changes in FreeBSD 12, Fstatat needs a compatibility wrapper akin to Fstatat in x/sys/unix. See CL 138595 and CL 136816 for details. Updates #27029 Change-Id: I8851a5b7fa658eaa6e69a1693150b16d9a68f36a Reviewed-on: https://go-review.googlesource.com/c/146597 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Yuval Pavel Zholkover <paulzhol@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* os: add support for long path names on solaris RemoveAllTobias Klauser2018-10-312-0/+85
| | | | | | | | | | | | | | Follow CL 146020 and enable RemoveAll based on Unlinkat and Openat on solaris. Updates #27029 Change-Id: I0b0e92f4422fa960a13dcd3e9adb57cd23f09ed4 Reviewed-on: https://go-review.googlesource.com/c/145839 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: Gobot Gobot <gobot@golang.org>
* os: add support for long path names on unix RemoveAllOliver Stenbom2018-10-3110-0/+172
| | | | | | | | | | | | | | | | | | | | | | | | | On unix systems, long enough path names will fail when performing syscalls like `Lstat`. The current RemoveAll uses several of these syscalls, and so will fail for long paths. This can be risky, as it can let users "hide" files from the system or otherwise make long enough paths for programs to fail. By using `Unlinkat` and `Openat` syscalls instead, RemoveAll is safer on unix systems. Initially implemented for linux, darwin, dragonfly, netbsd and openbsd. Not yet implemented on freebsd due to fstatat 64-bit inode compatibility issues. Fixes #27029 Co-authored-by: Giuseppe Capizzi <gcapizzi@pivotal.io> Co-authored-by: Julia Nedialkova <yulia.nedyalkova@sap.com> Change-Id: I978a6a4986878fe076d3c7af86e7927675624a96 GitHub-Last-Rev: 9235489c81b90c228210144b7c25b28a46bb80b7 GitHub-Pull-Request: golang/go#28494 Reviewed-on: https://go-review.googlesource.com/c/146020 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* Revert "os: add support for long path names on unix RemoveAll"Katie Hockman2018-10-3010-172/+0
| | | | | | | | | | | | This reverts commit 85143d355493c6bba994d49ed154b4df8b78874b. Reason for revert: Breaking all Darwin and FreeBSD builds. Trybots did not pass for this. Change-Id: I5494e14ad5ab9cf6e1e225a25b2e8b38f3359d13 Reviewed-on: https://go-review.googlesource.com/c/145897 Reviewed-by: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* os: add support for long path names on unix RemoveAllOliver Stenbom2018-10-3010-0/+172
| | | | | | | | | | | | | | | | | | | | | On unix systems, long enough path names will fail when performing syscalls like `Lstat`. The current RemoveAll uses several of these syscalls, and so will fail for long paths. This can be risky, as it can let users "hide" files from the system or otherwise make long enough paths for programs to fail. By using `Unlinkat` and `Openat` syscalls instead, RemoveAll is safer on unix systems. Initially implemented for linux, darwin, and several bsds. Fixes #27029 Co-authored-by: Giuseppe Capizzi <gcapizzi@pivotal.io> Co-authored-by: Julia Nedialkova <yulia.nedyalkova@sap.com> Change-Id: Id9fcdf4775962b021b7ff438dc51ee6d16bb5f56 GitHub-Last-Rev: b30a621fe359fa2acbb055445b54202b0c508167 GitHub-Pull-Request: golang/go#27871 Reviewed-on: https://go-review.googlesource.com/c/137442 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* internal/syscall/unix: omit unnecessary randomTrap check in GetRandomTobias Klauser2018-10-242-6/+0
| | | | | | | | | | | | The randomTrap const is initialized to a non-zero value for linux in getrandom_linux_$GOARCH.go and for freebsd in getrandom_freebsd.go directly since CL 16662. Thus, omit the unnecessary check. Change-Id: Id20cd628dfe6fab9908fa5258c3132e3b422a6b4 Reviewed-on: https://go-review.googlesource.com/c/144108 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, net: improve interface_aix.goClément Chigot2018-10-232-0/+37
| | | | | | | | | | | | | | This commit improves the interface_aix.go file, based on feedbacks about CL 138724. To retrieve MTU, ioctl is needed. It's implemented inside internal/syscall/unix. Change-Id: Ic583d26b93935a32a5f1eb5a2170b86e80a4a85e Reviewed-on: https://go-review.googlesource.com/c/142157 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* internal/syscall: add AIX operating systemClément Chigot2018-10-031-1/+1
| | | | | | | | | | | | | This commit adds AIX operating system to internal/syscall package for ppc64 architecture. Updates: #25893 Change-Id: I5c3a9d4403ca170a7e894e06e68b83387d09b816 Reviewed-on: https://go-review.googlesource.com/c/138718 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* internal/syscall/unix: remove unnecessary empty.sTobias Klauser2018-08-281-7/+0
| | | | | | | | | | | After CL 130736 there are no empty function declarations this package anymore, so empty.s is no longer needed. Change-Id: Ic4306f10ad8a31777a3337870ce19e14c1510f3b Reviewed-on: https://go-review.googlesource.com/131835 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* internal/syscall/unix: don't use linkname to refer to syscall.fcntlTobias Klauser2018-08-241-10/+4
| | | | | | | | | | | Just open-code the fcntl syscall instead of relying on the obscurity of go:linkname. Change-Id: I3e4ec9db6539e016f56667d7b8b87aa37671d0e7 Reviewed-on: https://go-review.googlesource.com/130736 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* crypto/rand: use the new getrandom syscall on FreeBSDDavid Carlier2018-08-222-1/+52
| | | | | | | | | | | | | | Since the 12.x branch, the getrandom syscall had been introduced with similar interface as Linux's and consistent syscall id across architectures. Change-Id: I63d6b45dbe9e29f07f1b5b6c2ec8be4fa624b9ee GitHub-Last-Rev: 6fb76e6522ef5ccb96d02445ffa39796dae89016 GitHub-Pull-Request: golang/go#25976 Reviewed-on: https://go-review.googlesource.com/120055 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* internal/syscall/unix: add build constraint to nonblocking_js.goDmitri Shuralyov2018-06-281-0/+2
| | | | | | | | | | | | | | | | | | | The intention was for this file to be constrained to both js and wasm, but the build constraint was missing, causing it to be constrained only to js because of the _js suffix in the filename. Add a js,wasm build constraint. The js part is redundant, but specified anyway to make it more visible and consistent with other similar files. This issue was spotted while working on GopherJS, because it was causing a conflict there (both nonblocking.go and nonblocking_js.go files were being matched). Change-Id: Ifc6843269e1108fe61b1723be25a12254e806fd4 Reviewed-on: https://go-review.googlesource.com/121275 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* os: add js/wasm architectureRichard Musiol2018-06-011-0/+9
| | | | | | | | | | | | | | This commit adds the js/wasm architecture to the os package. Access to the actual file system is supported through Node.js. Updates #18892 Change-Id: I6fa642fb294ca020b2c545649d4324d981aa0408 Reviewed-on: https://go-review.googlesource.com/109977 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* os: use poller when NewFile is called with a blocking descriptor.Nick Patavalis2018-04-113-0/+39
| | | | | | | | | | | | | | | | | If NewFile is called with a file descriptor that is already set to non-blocking mode, it tries to return a pollable file (one for which SetDeadline methods work) by adding the filedes to the poll/netpoll mechanism. If called with a filedes in blocking mode, it returns a non-pollable file, as it always did. Fixes #22939 Updates #24331 Change-Id: Id54c8be1b83e6d35e14e76d7df0e57a9fd64e176 Reviewed-on: https://go-review.googlesource.com/100077 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: add randomTrap const for GOARCH=mips{,le}Vladimir Stefanovic2016-11-031-0/+11
| | | | | | Change-Id: I76c62a7b79ea526f59f281e933e4fd431539d2da Reviewed-on: https://go-review.googlesource.com/31486 Reviewed-by: Cherry Zhang <cherryyz@google.com>
* internal/syscall/unix: add randomTrap const for s390xMichael Munday2016-03-221-0/+9
| | | | | | | Change-Id: I81376f524e76db25fd52cc5bec2c80fbf618a0c5 Reviewed-on: https://go-review.googlesource.com/20877 Reviewed-by: Minux Ma <minux@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* internal/syscall/unix: document randomTrapBrad Fitzpatrick2016-03-216-0/+17
| | | | | | | | Updates #10848 Change-Id: I8353100ed01cb0e8fc19225157f5709bae388612 Reviewed-on: https://go-review.googlesource.com/20975 Reviewed-by: Rob Pike <r@golang.org>
* all: make copyright headers consistent with one space after periodBrad Fitzpatrick2016-03-018-8/+8
| | | | | | | | | | | | | | | | | | | | | | This is a subset of https://golang.org/cl/20022 with only the copyright header lines, so the next CL will be smaller and more reviewable. Go policy has been single space after periods in comments for some time. The copyright header template at: https://golang.org/doc/contribute.html#copyright also uses a single space. Make them all consistent. Change-Id: Icc26c6b8495c3820da6b171ca96a74701b4a01b0 Reviewed-on: https://go-review.googlesource.com/20111 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* crypto/rand: use the getentropy syscall on OpenBSDMichael McConville2016-02-261-0/+25
| | | | | | | | | | | | | | | | | Go already supports Linux's getrandom, which is a slightly modified version of getentropy. getentropy was added in OpenBSD 5.6. All supported versions of OpenBSD include it so, unlike with Linux and getrandom, we don't need to test for its presence. Fixes #13785. Change-Id: Ib536b96675f257cd8c5de1e3a36165e15c9abac9 Reviewed-on: https://go-review.googlesource.com/18219 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* internal/syscall/unix: added support for linux/mips64{,le}Yao Zhang2015-11-121-0/+9
| | | | | | | Change-Id: Ib6f168b6a2daf3befbf75b4b95967ff91ac95d12 Reviewed-on: https://go-review.googlesource.com/14456 Reviewed-by: Minux Ma <minux@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* internal/syscall/unix: eliminate non-trivial randomTrap initializerMatthew Dempsky2015-11-056-9/+39
| | | | | | | | | | | | | | While here, enable getrandom on arm64 too (using the value found in include/uapi/asm-generic/unistd.h, which seems to match up with other GOARCH=arm64 syscall numbers). Updates #10848. Change-Id: I5ab36ccf6ee8d5cc6f0e1a61d09f0da7410288b9 Reviewed-on: https://go-review.googlesource.com/16662 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* Revert "net, internal/syscall/unix: add SocketConn, SocketPacketConn"Mikio Hara2015-07-025-201/+0
| | | | | | | | | | | | | | | | This reverts commit 6f7961da28232c609f7c51b3bed7f15db7dd33e1. Russ suggests changing the frozon syscall package and obviously it's a better solution. Perhaps he will also let me know the way how to get the project owners to agree later. Fixes #11492. Change-Id: I98f9f366b72b85db54b4acfc3a604b62fb6d783c Reviewed-on: https://go-review.googlesource.com/11854 Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net, internal/syscall/unix: add SocketConn, SocketPacketConnMikio Hara2015-05-135-0/+201
| | | | | | | | | | | | | | | | | | | | | | | | | | FileConn and FilePacketConn APIs accept user-configured socket descriptors to make them work together with runtime-integrated network poller, but there's a limitation. The APIs reject protocol sockets that are not supported by standard library. It's very hard for the net, syscall packages to look after all platform, feature-specific sockets. This change allows various platform, feature-specific socket descriptors to use runtime-integrated network poller by using SocketConn, SocketPacketConn APIs that bridge between the net, syscall packages and platforms. New exposed APIs: pkg net, func SocketConn(*os.File, SocketAddr) (Conn, error) pkg net, func SocketPacketConn(*os.File, SocketAddr) (PacketConn, error) pkg net, type SocketAddr interface { Addr, Raw } pkg net, type SocketAddr interface, Addr([]uint8) Addr pkg net, type SocketAddr interface, Raw(Addr) []uint8 Fixes #10565. Change-Id: Iec57499b3d84bb5cb0bcf3f664330c535eec11e3 Reviewed-on: https://go-review.googlesource.com/9275 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* internal/syscall: move to unix subdirectoryIan Lance Taylor2015-04-151-0/+58
Move the single file from internal/syscall to internal/syscall/unix, to match the golang.org/x/sys layout. Change-Id: I2fb2832b4cb22efc7666bd276f5401ac3e73dc40 Reviewed-on: https://go-review.googlesource.com/8972 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Rob Pike <r@golang.org>