mirror of
https://github.com/golang/go
synced 2024-11-26 18:26:48 -07:00
runtime: consolidate on a single closeonexec definition
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>
This commit is contained in:
parent
2ec648aa8c
commit
58315a771a
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
@ -10,6 +10,7 @@ import "unsafe"
|
||||
|
||||
var NonblockingPipe = nonblockingPipe
|
||||
var Fcntl = fcntl
|
||||
var Closeonexec = closeonexec
|
||||
|
||||
func sigismember(mask *sigset, i int) bool {
|
||||
clear := *mask
|
||||
|
@ -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
|
||||
)
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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 (
|
||||
|
@ -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 (
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
19
src/runtime/os_unix.go
Normal file
19
src/runtime/os_unix.go
Normal file
@ -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)
|
||||
}
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user