]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: consolidate on a single closeonexec definition
authorIan Lance Taylor <iant@golang.org>
Sat, 20 May 2023 00:44:35 +0000 (17:44 -0700)
committerGopher Robot <gobot@golang.org>
Sat, 20 May 2023 21:27:51 +0000 (21:27 +0000)
Now that we implement fcntl on all Unix systems, we can
write closeonexec that uses it. This lets us remove a bunch
of assembler code.

Change-Id: If35591df535ccfc67292086a9492f0a8920e3681
Reviewed-on: https://go-review.googlesource.com/c/go/+/496081
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
38 files changed:
src/runtime/defs1_solaris_amd64.go
src/runtime/defs_aix.go
src/runtime/defs_aix_ppc64.go
src/runtime/defs_darwin.go
src/runtime/defs_darwin_amd64.go
src/runtime/defs_darwin_arm64.go
src/runtime/defs_openbsd.go
src/runtime/defs_openbsd_386.go
src/runtime/defs_openbsd_amd64.go
src/runtime/defs_openbsd_arm.go
src/runtime/defs_openbsd_arm64.go
src/runtime/defs_solaris.go
src/runtime/export_linux_test.go
src/runtime/export_unix2_test.go [deleted file]
src/runtime/export_unix_test.go
src/runtime/internal/syscall/defs_linux.go [deleted file]
src/runtime/internal/syscall/syscall_linux.go
src/runtime/netpoll_solaris.go
src/runtime/os3_solaris.go
src/runtime/os_aix.go
src/runtime/os_dragonfly.go
src/runtime/os_freebsd.go
src/runtime/os_netbsd.go
src/runtime/os_openbsd_syscall2.go
src/runtime/os_unix.go [new file with mode: 0644]
src/runtime/sys_darwin.go
src/runtime/sys_dragonfly_amd64.s
src/runtime/sys_freebsd_386.s
src/runtime/sys_freebsd_amd64.s
src/runtime/sys_freebsd_arm.s
src/runtime/sys_freebsd_arm64.s
src/runtime/sys_freebsd_riscv64.s
src/runtime/sys_netbsd_386.s
src/runtime/sys_netbsd_amd64.s
src/runtime/sys_netbsd_arm.s
src/runtime/sys_netbsd_arm64.s
src/runtime/sys_openbsd2.go
src/runtime/sys_openbsd_mips64.s

index bb53c22e06cef364ab811d6d1581738509c25c41..4e541a913bb30b51e38d22ab94b15de58ac95e93 100644 (file)
@@ -96,10 +96,8 @@ const (
        _O_TRUNC    = 0x200
        _O_CREAT    = 0x100
        _O_CLOEXEC  = 0x800000
-       _FD_CLOEXEC = 0x1
        _F_GETFL    = 0x3
        _F_SETFL    = 0x4
-       _F_SETFD    = 0x2
 
        _POLLIN  = 0x1
        _POLLOUT = 0x4
index 389598966a826b190ae1093e617933aab5860262..2f28e534689bb341e871d8f789f1ddacfead44d1 100644 (file)
@@ -144,11 +144,9 @@ const (
        __SC_PAGE_SIZE        = C._SC_PAGE_SIZE
        __SC_NPROCESSORS_ONLN = C._SC_NPROCESSORS_ONLN
 
-       _F_SETFD    = C.F_SETFD
-       _F_SETFL    = C.F_SETFL
-       _F_GETFD    = C.F_GETFD
-       _F_GETFL    = C.F_GETFL
-       _FD_CLOEXEC = C.FD_CLOEXEC
+       _F_SETFL = C.F_SETFL
+       _F_GETFD = C.F_GETFD
+       _F_GETFL = C.F_GETFL
 )
 
 type sigset C.sigset_t
index 2d25b7ce3c834a163d75026a7ed0933f4daa58b9..8e85096939cb767d0ee775f785395ff5e1639d80 100644 (file)
@@ -101,11 +101,9 @@ const (
        __SC_PAGE_SIZE        = 0x30
        __SC_NPROCESSORS_ONLN = 0x48
 
-       _F_SETFD    = 0x2
-       _F_SETFL    = 0x4
-       _F_GETFD    = 0x1
-       _F_GETFL    = 0x3
-       _FD_CLOEXEC = 0x1
+       _F_SETFL = 0x4
+       _F_GETFD = 0x1
+       _F_GETFL = 0x3
 )
 
 type sigset [4]uint64
index 89e4253f339b5bab3d89928f79e570ebed2d5a7e..9c6eeee45abe58ecb63184294ed3e008b01bf622 100644 (file)
@@ -115,10 +115,8 @@ const (
 
        PTHREAD_CREATE_DETACHED = C.PTHREAD_CREATE_DETACHED
 
-       F_SETFD    = C.F_SETFD
-       F_GETFL    = C.F_GETFL
-       F_SETFL    = C.F_SETFL
-       FD_CLOEXEC = C.FD_CLOEXEC
+       F_GETFL = C.F_GETFL
+       F_SETFL = C.F_SETFL
 
        O_WRONLY   = C.O_WRONLY
        O_NONBLOCK = C.O_NONBLOCK
index 84e6f3720368e7c8b6353b01b4cbfc07096cdaa5..fc7de3330a72a304a7ead0c8e7bd981d9d3d324b 100644 (file)
@@ -94,10 +94,8 @@ const (
 
        _PTHREAD_CREATE_DETACHED = 0x2
 
-       _F_SETFD    = 0x2
-       _F_GETFL    = 0x3
-       _F_SETFL    = 0x4
-       _FD_CLOEXEC = 0x1
+       _F_GETFL = 0x3
+       _F_SETFL = 0x4
 
        _O_WRONLY   = 0x1
        _O_NONBLOCK = 0x4
index 30d7443f2eafe5258478486a332cea1d191508b7..e26df029594bc09b048d6b98cedb9145898fbd04 100644 (file)
@@ -96,10 +96,8 @@ const (
 
        _PTHREAD_KEYS_MAX = 512
 
-       _F_SETFD    = 0x2
-       _F_GETFL    = 0x3
-       _F_SETFL    = 0x4
-       _FD_CLOEXEC = 0x1
+       _F_GETFL = 0x3
+       _F_SETFL = 0x4
 
        _O_WRONLY   = 0x1
        _O_NONBLOCK = 0x4
index 4161e216db69830e8cd935ebba927c6283990b26..2ca6a88ecad8f021d2e2437010152a6c3ce46eb7 100644 (file)
@@ -57,10 +57,8 @@ const (
 
        PTHREAD_CREATE_DETACHED = C.PTHREAD_CREATE_DETACHED
 
-       F_SETFD    = C.F_SETFD
-       F_GETFL    = C.F_GETFL
-       F_SETFL    = C.F_SETFL
-       FD_CLOEXEC = C.FD_CLOEXEC
+       F_GETFL = C.F_GETFL
+       F_SETFL = C.F_SETFL
 
        SIGHUP    = C.SIGHUP
        SIGINT    = C.SIGINT
index 25524c598215600282341362d13ba2fd789cac76..d38a632577cc7e19031be8f4e2995245ace1a816 100644 (file)
@@ -35,10 +35,8 @@ const (
 
        _PTHREAD_CREATE_DETACHED = 0x1
 
-       _F_SETFD    = 0x2
-       _F_GETFL    = 0x3
-       _F_SETFL    = 0x4
-       _FD_CLOEXEC = 0x1
+       _F_GETFL = 0x3
+       _F_SETFL = 0x4
 
        _SIGHUP    = 0x1
        _SIGINT    = 0x2
index a31d03bce59e5af07d5d5c1475a5603b7ddb1b50..ed3c067989bd96cf103759b53829b6b8961142a8 100644 (file)
@@ -35,10 +35,8 @@ const (
 
        _PTHREAD_CREATE_DETACHED = 0x1
 
-       _F_SETFD    = 0x2
-       _F_GETFL    = 0x3
-       _F_SETFL    = 0x4
-       _FD_CLOEXEC = 0x1
+       _F_GETFL = 0x3
+       _F_SETFL = 0x4
 
        _SIGHUP    = 0x1
        _SIGINT    = 0x2
index 1d1767bd3b763698811f08fa4c45ef5bb6444dda..00b265e538a4749c5c01e76902820d1409c27d6a 100644 (file)
@@ -35,10 +35,8 @@ const (
 
        _PTHREAD_CREATE_DETACHED = 0x1
 
-       _F_SETFD    = 0x2
-       _F_GETFL    = 0x3
-       _F_SETFL    = 0x4
-       _FD_CLOEXEC = 0x1
+       _F_GETFL = 0x3
+       _F_SETFL = 0x4
 
        _SIGHUP    = 0x1
        _SIGINT    = 0x2
index 745d0d39239b95281ab887664586b0d3130b3993..894fd39b75482dc00e89443db4bc2cb156f72668 100644 (file)
@@ -36,10 +36,8 @@ const (
 
        _PTHREAD_CREATE_DETACHED = 0x1
 
-       _F_SETFD    = 0x2
-       _F_GETFL    = 0x3
-       _F_SETFL    = 0x4
-       _FD_CLOEXEC = 0x1
+       _F_GETFL = 0x3
+       _F_SETFL = 0x4
 
        _SIGHUP    = 0x1
        _SIGINT    = 0x2
index 406304de5a0d0690ebae724952808091cc822d5f..11708ee23a7e9baa5b1721412d0bc2dac83e2c0e 100644 (file)
@@ -125,10 +125,8 @@ const (
        O_CREAT    = C.O_CREAT
        O_TRUNC    = C.O_TRUNC
        O_CLOEXEC  = C.O_CLOEXEC
-       FD_CLOEXEC = C.FD_CLOEXEC
        F_GETFL    = C.F_GETFL
        F_SETFL    = C.F_SETFL
-       F_SETFD    = C.F_SETFD
 
        POLLIN  = C.POLLIN
        POLLOUT = C.POLLOUT
index a441c0efa25a57287f51bcb0e0a1d669c12fbef7..426fd1e109325112b4ffcc29f478d34702bc12c1 100644 (file)
@@ -6,14 +6,9 @@
 
 package runtime
 
-import (
-       "runtime/internal/syscall"
-)
-
 const SiginfoMaxSize = _si_max_size
 const SigeventMaxSize = _sigev_max_size
 
-var Closeonexec = syscall.CloseOnExec
 var NewOSProc0 = newosproc0
 var Mincore = mincore
 var Add = add
diff --git a/src/runtime/export_unix2_test.go b/src/runtime/export_unix2_test.go
deleted file mode 100644 (file)
index 360565f..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2022 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.
-
-//go:build unix && !linux
-
-package runtime
-
-// for linux close-on-exec implemented in runtime/internal/syscall
-var Closeonexec = closeonexec
index 6967e7645c88348163340095ab2e807a2e07cdc6..56ff7716208c9a6875a98de6fb3de6447b8429ca 100644 (file)
@@ -10,6 +10,7 @@ import "unsafe"
 
 var NonblockingPipe = nonblockingPipe
 var Fcntl = fcntl
+var Closeonexec = closeonexec
 
 func sigismember(mask *sigset, i int) bool {
        clear := *mask
diff --git a/src/runtime/internal/syscall/defs_linux.go b/src/runtime/internal/syscall/defs_linux.go
deleted file mode 100644 (file)
index 71f1fa1..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2022 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.
-
-package syscall
-
-const (
-       F_SETFD    = 2
-       FD_CLOEXEC = 1
-)
index a103d318c4391499d2a3bd78b5404ca0d11e1be7..7209634edb3f81380ee9613f0df59c4af62caeb3 100644 (file)
@@ -60,7 +60,3 @@ func EpollCtl(epfd, op, fd int32, event *EpollEvent) (errno uintptr) {
        _, _, e := Syscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0)
        return e
 }
-
-func CloseOnExec(fd int32) {
-       Syscall6(SYS_FCNTL, uintptr(fd), F_SETFD, FD_CLOEXEC, 0, 0, 0)
-}
index 41b2f474ac3d68ab38fe42b581f7dcebe7916123..13c7ffc2ca3a3721fe26bcc1ab66ff86ee40aa38 100644 (file)
@@ -121,7 +121,7 @@ var portfd int32 = -1
 func netpollinit() {
        portfd = port_create()
        if portfd >= 0 {
-               fcntl(portfd, _F_SETFD, _FD_CLOEXEC)
+               closeonexec(portfd)
                return
        }
 
index d03f30dc9ec4569b20bf2a836da9c28c6508d3d9..046d173c24a904363ce2f817d0b289ec44306a54 100644 (file)
@@ -575,11 +575,6 @@ func fcntl(fd, cmd, arg int32) (ret int32, errno int32) {
        return int32(r1), int32(err)
 }
 
-//go:nosplit
-func closeonexec(fd int32) {
-       fcntl(fd, _F_SETFD, _FD_CLOEXEC)
-}
-
 func osyield1()
 
 //go:nosplit
index 7845de1470776f38fc4cbd8213ff0a65276d3635..8f10eb7380b29230e00cb168df5c154f5563ecec 100644 (file)
@@ -357,11 +357,6 @@ func fcntl(fd, cmd, arg int32) (int32, int32) {
        return int32(r), int32(errno)
 }
 
-//go:nosplit
-func closeonexec(fd int32) {
-       fcntl(fd, _F_SETFD, _FD_CLOEXEC)
-}
-
 //go:nosplit
 func setNonblock(fd int32) {
        flags, _ := fcntl(fd, _F_GETFL, 0)
index fb45de3c71a40bcd360bcf47d6b457d79f3d6e96..bb53f4a157b4261fd20c5a65eb2408cc84d5313c 100644 (file)
@@ -64,7 +64,6 @@ func kevent(kq int32, ch *keventt, nch int32, ev *keventt, nev int32, ts *timesp
 
 func pipe2(flags int32) (r, w int32, errno int32)
 func fcntl(fd, cmd, arg int32) (ret int32, errno int32)
-func closeonexec(fd int32)
 
 // From DragonFly's <sys/sysctl.h>
 const (
index ad9e58c0628377cca93d93ca845d9750e1cc8806..b53a70bef002a0886b717bf1faa896d51a279554 100644 (file)
@@ -49,7 +49,6 @@ func kevent(kq int32, ch *keventt, nch int32, ev *keventt, nev int32, ts *timesp
 
 func pipe2(flags int32) (r, w int32, errno int32)
 func fcntl(fd, cmd, arg int32) (ret int32, errno int32)
-func closeonexec(fd int32)
 
 // From FreeBSD's <sys/sysctl.h>
 const (
index 1688049ee7869d59a84fa0d5cf7ba9920b8b25f9..92c02c193fd56755db18b556d607b99fd0801af8 100644 (file)
@@ -80,7 +80,6 @@ func kevent(kq int32, ch *keventt, nch int32, ev *keventt, nev int32, ts *timesp
 
 func pipe2(flags int32) (r, w int32, errno int32)
 func fcntl(fd, cmd, arg int32) (ret int32, errno int32)
-func closeonexec(fd int32)
 
 const (
        _ESRCH     = 3
index dcf3b09e6780a86724e96aeb3d072c94cfceb320..bba89f3cb123c1e68baa75f6f59e7912fe47a913 100644 (file)
@@ -96,6 +96,5 @@ func nanotime1() int64
 func sigaltstack(new, old *stackt)
 
 func fcntl(fd, cmd, arg int32) (ret int32, errno int32)
-func closeonexec(fd int32)
 
 func walltime() (sec int64, nsec int32)
diff --git a/src/runtime/os_unix.go b/src/runtime/os_unix.go
new file mode 100644 (file)
index 0000000..fdbeba7
--- /dev/null
@@ -0,0 +1,19 @@
+// Copyright 2023 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.
+
+//go:build unix
+
+package runtime
+
+const (
+       // These values are the same on all known Unix systems.
+       // If we find a discrepancy some day, we can split them out.
+       _F_SETFD    = 2
+       _FD_CLOEXEC = 1
+)
+
+//go:nosplit
+func closeonexec(fd int32) {
+       fcntl(fd, _F_SETFD, _FD_CLOEXEC)
+}
index a56a9373b95cbedbb3d0c376c0f3af923714e077..2229ee87edbe32ca4cd3b4c3fd4a95807e7dc8b2 100644 (file)
@@ -536,11 +536,6 @@ func exitThread(wait *atomic.Uint32) {
        throw("exitThread")
 }
 
-//go:nosplit
-func closeonexec(fd int32) {
-       fcntl(fd, _F_SETFD, _FD_CLOEXEC)
-}
-
 //go:nosplit
 func setNonblock(fd int32) {
        flags, _ := fcntl(fd, _F_GETFL, 0)
index 28bc0a70ebaff6aa796b6e0c1fcc2e3b6b4dd0ea..4e16c9d66299debf96a6ab033dffaab29f718f9e 100644 (file)
@@ -400,12 +400,3 @@ noerr:
        MOVL    AX, ret+16(FP)
        MOVL    $0, errno+20(FP)
        RET
-
-// void runtime·closeonexec(int32 fd);
-TEXT runtime·closeonexec(SB),NOSPLIT,$0
-       MOVL    fd+0(FP), DI    // fd
-       MOVQ    $2, SI          // F_SETFD
-       MOVQ    $1, DX          // FD_CLOEXEC
-       MOVL    $92, AX         // fcntl
-       SYSCALL
-       RET
index a5a668cb7003c521d8a11109e7065d0b1c280eee..3d5531fecbbc5c88e581f229d4b3e394cc6e3a02 100644 (file)
@@ -12,8 +12,6 @@
 
 #define CLOCK_REALTIME         0
 #define CLOCK_MONOTONIC                4
-#define FD_CLOEXEC             1
-#define F_SETFD                        2
 
 #define SYS_exit               1
 #define SYS_read               3
@@ -464,19 +462,6 @@ noerr:
        MOVL    $0, errno+16(FP)
        RET
 
-// int32 runtime·closeonexec(int32 fd);
-TEXT runtime·closeonexec(SB),NOSPLIT,$32
-       MOVL    $SYS_fcntl, AX
-       // 0(SP) is where the caller PC would be; kernel skips it
-       MOVL    fd+0(FP), BX
-       MOVL    BX, 4(SP)       // fd
-       MOVL    $F_SETFD, 8(SP)
-       MOVL    $FD_CLOEXEC, 12(SP)
-       INT     $0x80
-       JAE     2(PC)
-       NEGL    AX
-       RET
-
 // func cpuset_getaffinity(level int, which int, id int64, size int, mask *byte) int32
 TEXT runtime·cpuset_getaffinity(SB), NOSPLIT, $0-28
        MOVL    $SYS_cpuset_getaffinity, AX
index 2f600ea6788f5063a2cb305aae820fb373a362ba..ff39d15a03695eeab8aea73c9dc7789320413699 100644 (file)
@@ -13,8 +13,6 @@
 
 #define CLOCK_REALTIME         0
 #define CLOCK_MONOTONIC                4
-#define FD_CLOEXEC             1
-#define F_SETFD                        2
 #define AMD64_SET_FSBASE       129
 
 #define SYS_exit               1
@@ -564,15 +562,6 @@ noerr:
        MOVL    $0, errno+20(FP)
        RET
 
-// void runtime·closeonexec(int32 fd);
-TEXT runtime·closeonexec(SB),NOSPLIT,$0
-       MOVL    fd+0(FP), DI    // fd
-       MOVQ    $F_SETFD, SI
-       MOVQ    $FD_CLOEXEC, DX
-       MOVL    $SYS_fcntl, AX
-       SYSCALL
-       RET
-
 // func cpuset_getaffinity(level int, which int, id int64, size int, mask *byte) int32
 TEXT runtime·cpuset_getaffinity(SB), NOSPLIT, $0-44
        MOVQ    level+0(FP), DI
index 9b09d9d349fec6dd1ebc52ff1b52218779efd994..3b76cc84a7b8024f6ad02b5707254f4e8376e1d5 100644 (file)
@@ -401,15 +401,6 @@ TEXT runtime·fcntl(SB),NOSPLIT,$0
        MOVW R1, errno+16(FP)
        RET
 
-// void runtime·closeonexec(int32 fd)
-TEXT runtime·closeonexec(SB),NOSPLIT,$0
-       MOVW fd+0(FP), R0       // fd
-       MOVW $2, R1     // F_SETFD
-       MOVW $1, R2     // FD_CLOEXEC
-       MOVW $SYS_fcntl, R7
-       SWI $0
-       RET
-
 // TODO: this is only valid for ARMv7+
 TEXT ·publicationBarrier(SB),NOSPLIT|NOFRAME,$0-0
        B       runtime·armPublicationBarrier(SB)
index dcf32a26e7c544862ec518d23d1219ad7634852d..ef0366277f5998f34e0e8e598164aa05ef0afd0b 100644 (file)
@@ -14,8 +14,6 @@
 
 #define CLOCK_REALTIME         0
 #define CLOCK_MONOTONIC                4
-#define FD_CLOEXEC             1
-#define F_SETFD                        2
 #define F_GETFL                        3
 #define F_SETFL                        4
 #define O_NONBLOCK             4
@@ -456,15 +454,6 @@ noerr:
        MOVW    $0, errno+20(FP)
        RET
 
-// func closeonexec(fd int32)
-TEXT runtime·closeonexec(SB),NOSPLIT|NOFRAME,$0
-       MOVW    fd+0(FP), R0
-       MOVD    $F_SETFD, R1
-       MOVD    $FD_CLOEXEC, R2
-       MOVD    $SYS_fcntl, R8
-       SVC
-       RET
-
 // func getCntxct(physical bool) uint32
 TEXT runtime·getCntxct(SB),NOSPLIT,$0
        MOVB    physical+0(FP), R0
index 58173c2cb64cd00ae3e72a6294c232959895cca3..be6966b9aa28c4cd8b65d99fc3e454f62b7406cd 100644 (file)
@@ -13,8 +13,6 @@
 
 #define CLOCK_REALTIME         0
 #define CLOCK_MONOTONIC                4
-#define FD_CLOEXEC             1
-#define F_SETFD                        2
 #define F_GETFL                        3
 #define F_SETFL                        4
 #define O_NONBLOCK             4
@@ -437,15 +435,6 @@ noerr:
        MOVW    ZERO, errno+20(FP)
        RET
 
-// func closeonexec(fd int32)
-TEXT runtime·closeonexec(SB),NOSPLIT|NOFRAME,$0
-       MOVW    fd+0(FP), A0
-       MOV     $F_SETFD, A1
-       MOV     $FD_CLOEXEC, A2
-       MOV     $SYS_fcntl, T0
-       ECALL
-       RET
-
 // func getCntxct() uint32
 TEXT runtime·getCntxct(SB),NOSPLIT|NOFRAME,$0
        RDTIME  A0
index e649fb13cbbbb9f762883aa739dc0344b97a3604..dbfc4b552e2c6ab0db030e3af15fabee8062287e 100644 (file)
@@ -12,8 +12,6 @@
 
 #define CLOCK_REALTIME         0
 #define CLOCK_MONOTONIC                3
-#define FD_CLOEXEC             1
-#define F_SETFD                        2
 
 #define SYS_exit                       1
 #define SYS_read                       3
@@ -469,16 +467,3 @@ noerr:
        MOVL    AX, ret+12(FP)
        MOVL    $0, errno+16(FP)
        RET
-
-// int32 runtime·closeonexec(int32 fd)
-TEXT runtime·closeonexec(SB),NOSPLIT,$32
-       MOVL    $SYS_fcntl, AX
-       // 0(SP) is where the caller PC would be; kernel skips it
-       MOVL    fd+0(FP), BX
-       MOVL    BX, 4(SP)       // fd
-       MOVL    $F_SETFD, 8(SP)
-       MOVL    $FD_CLOEXEC, 12(SP)
-       INT     $0x80
-       JAE     2(PC)
-       NEGL    AX
-       RET
index c01473a0cfe1c9df9f1d36bbe399359dc4a30048..948f62b8c59c0a71a9d119e078fcf56d91eb3385 100644 (file)
@@ -13,8 +13,6 @@
 
 #define CLOCK_REALTIME         0
 #define CLOCK_MONOTONIC                3
-#define FD_CLOEXEC             1
-#define F_SETFD                        2
 
 #define SYS_exit                       1
 #define SYS_read                       3
@@ -447,12 +445,3 @@ noerr:
        MOVL    AX, ret+16(FP)
        MOVL    $0, errno+20(FP)
        RET
-
-// void runtime·closeonexec(int32 fd)
-TEXT runtime·closeonexec(SB),NOSPLIT,$0
-       MOVL    fd+0(FP), DI    // fd
-       MOVQ    $F_SETFD, SI
-       MOVQ    $FD_CLOEXEC, DX
-       MOVL    $SYS_fcntl, AX
-       SYSCALL
-       RET
index 9d969592c47da949a1ac8809ea0887bc58853de4..91ec00e424c5d56031a30be76047bf8c47bf9935 100644 (file)
@@ -12,8 +12,6 @@
 
 #define CLOCK_REALTIME         0
 #define CLOCK_MONOTONIC                3
-#define FD_CLOEXEC             1
-#define F_SETFD                        2
 
 #define SWI_OS_NETBSD                  0xa00000
 #define SYS_exit                       SWI_OS_NETBSD | 1
@@ -411,14 +409,6 @@ TEXT runtime·fcntl(SB),NOSPLIT,$0
        MOVW R1, errno+16(FP)
        RET
 
-// void runtime·closeonexec(int32 fd)
-TEXT runtime·closeonexec(SB),NOSPLIT,$0
-       MOVW fd+0(FP), R0       // fd
-       MOVW $F_SETFD, R1       // F_SETFD
-       MOVW $FD_CLOEXEC, R2    // FD_CLOEXEC
-       SWI $SYS_fcntl
-       RET
-
 // TODO: this is only valid for ARMv7+
 TEXT ·publicationBarrier(SB),NOSPLIT|NOFRAME,$0-0
        B       runtime·armPublicationBarrier(SB)
index 34523530d5d450ef816fd1e8b78459078a906c65..611b9e1d747a98388926019d0ffdc6635b700941 100644 (file)
@@ -13,8 +13,6 @@
 
 #define CLOCK_REALTIME         0
 #define CLOCK_MONOTONIC                3
-#define FD_CLOEXEC             1
-#define F_SETFD                        2
 #define F_GETFL                        3
 #define F_SETFL                        4
 #define O_NONBLOCK             4
@@ -431,11 +429,3 @@ noerr:
        MOVW    R0, ret+16(FP)
        MOVW    $0, errno+20(FP)
        RET
-
-// void runtime·closeonexec(int32 fd)
-TEXT runtime·closeonexec(SB),NOSPLIT,$0
-       MOVW    fd+0(FP), R0            // arg 1 - fd
-       MOVW    $F_SETFD, R1
-       MOVW    $FD_CLOEXEC, R2
-       SVC     $SYS_fcntl
-       RET
index 12a53dfc6d95ecd2eee5f1768b604cdeb4d2d461..e69bfc334806090886127b068e39d8444bcb58aa 100644 (file)
@@ -258,11 +258,6 @@ func exitThread(wait *atomic.Uint32) {
        throw("exitThread")
 }
 
-//go:nosplit
-func closeonexec(fd int32) {
-       fcntl(fd, _F_SETFD, _FD_CLOEXEC)
-}
-
 // Tell the linker that the libc_* functions are to be found
 // in a system library, with the libc_ prefix missing.
 
index 9238e7d0b0efa0c6b96238085779760b31f38d41..bea20f2433fbcb4b04304f4a49339bd73e576803 100644 (file)
@@ -379,12 +379,3 @@ noerr:
        MOVW    R2, ret+16(FP)
        MOVW    R4, errno+20(FP)
        RET
-
-// func closeonexec(fd int32)
-TEXT runtime·closeonexec(SB),NOSPLIT,$0
-       MOVW    fd+0(FP), R4            // arg 1 - fd
-       MOVV    $2, R5                  // arg 2 - cmd (F_SETFD)
-       MOVV    $1, R6                  // arg 3 - arg (FD_CLOEXEC)
-       MOVV    $92, R2                 // sys_fcntl
-       SYSCALL
-       RET