_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
__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
__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
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
_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
_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
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
_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
_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
_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
_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
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
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
+++ /dev/null
-// 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
var NonblockingPipe = nonblockingPipe
var Fcntl = fcntl
+var Closeonexec = closeonexec
func sigismember(mask *sigset, i int) bool {
clear := *mask
+++ /dev/null
-// 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
-)
_, _, 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)
-}
func netpollinit() {
portfd = port_create()
if portfd >= 0 {
- fcntl(portfd, _F_SETFD, _FD_CLOEXEC)
+ closeonexec(portfd)
return
}
return int32(r1), int32(err)
}
-//go:nosplit
-func closeonexec(fd int32) {
- fcntl(fd, _F_SETFD, _FD_CLOEXEC)
-}
-
func osyield1()
//go:nosplit
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)
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 (
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 (
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
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)
--- /dev/null
+// 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)
+}
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)
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
#define CLOCK_REALTIME 0
#define CLOCK_MONOTONIC 4
-#define FD_CLOEXEC 1
-#define F_SETFD 2
#define SYS_exit 1
#define SYS_read 3
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
#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
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
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)
#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
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
#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
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
#define CLOCK_REALTIME 0
#define CLOCK_MONOTONIC 3
-#define FD_CLOEXEC 1
-#define F_SETFD 2
#define SYS_exit 1
#define SYS_read 3
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
#define CLOCK_REALTIME 0
#define CLOCK_MONOTONIC 3
-#define FD_CLOEXEC 1
-#define F_SETFD 2
#define SYS_exit 1
#define SYS_read 3
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
#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
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)
#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
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
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.
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