Skip to content

Commit dff3a00

Browse files
panjf2000gopherbot
authored andcommitted
syscall: call internal/runtime/syscall.Syscall6 in RawSyscall6
For #65355 Change-Id: I9168d9a767e3b2ece65ac6dcab6827ab6f6b11bb Reviewed-on: https://go-review.googlesource.com/c/go/+/560136 Reviewed-by: Michael Knyszek <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Michael Pratt <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]>
1 parent 5cbea57 commit dff3a00

File tree

2 files changed

+13
-32
lines changed

2 files changed

+13
-32
lines changed

src/internal/runtime/syscall/syscall_linux.go

-23
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,6 @@ import (
1515
// Syscall6 calls system call number 'num' with arguments a1-6.
1616
func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr)
1717

18-
// syscall_RawSyscall6 is a push linkname to export Syscall6 as
19-
// syscall.RawSyscall6.
20-
//
21-
// //go:uintptrkeepalive because the uintptr argument may be converted pointers
22-
// that need to be kept alive in the caller (this is implied for Syscall6 since
23-
// it has no body).
24-
//
25-
// //go:nosplit because stack copying does not account for uintptrkeepalive, so
26-
// the stack must not grow. Stack copying cannot blindly assume that all
27-
// uintptr arguments are pointers, because some values may look like pointers,
28-
// but not really be pointers, and adjusting their value would break the call.
29-
//
30-
// This is a separate wrapper because we can't export one function as two
31-
// names. The assembly implementations name themselves Syscall6 would not be
32-
// affected by a linkname.
33-
//
34-
//go:uintptrkeepalive
35-
//go:nosplit
36-
//go:linkname syscall_RawSyscall6 syscall.RawSyscall6
37-
func syscall_RawSyscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) {
38-
return Syscall6(num, a1, a2, a3, a4, a5, a6)
39-
}
40-
4118
func EpollCreate1(flags int32) (fd int32, errno uintptr) {
4219
r1, _, e := Syscall6(SYS_EPOLL_CREATE1, uintptr(flags), 0, 0, 0, 0, 0)
4320
return int32(r1), e

src/syscall/syscall_linux.go

+13-9
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,11 @@ package syscall
1313

1414
import (
1515
"internal/itoa"
16+
runtimesyscall "internal/runtime/syscall"
1617
"runtime"
1718
"unsafe"
1819
)
1920

20-
// N.B. RawSyscall6 is provided via linkname by internal/runtime/syscall.
21-
//
22-
// Errno is uintptr and thus compatible with the internal/runtime/syscall
23-
// definition.
24-
25-
func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
26-
2721
// Pull in entersyscall/exitsyscall for Syscall/Syscall6.
2822
//
2923
// Note that this can't be a push linkname because the runtime already has a
@@ -40,8 +34,7 @@ func runtime_exitsyscall()
4034
// N.B. For the Syscall functions below:
4135
//
4236
// //go:uintptrkeepalive because the uintptr argument may be converted pointers
43-
// that need to be kept alive in the caller (this is implied for RawSyscall6
44-
// since it has no body).
37+
// that need to be kept alive in the caller.
4538
//
4639
// //go:nosplit because stack copying does not account for uintptrkeepalive, so
4740
// the stack must not grow. Stack copying cannot blindly assume that all
@@ -62,6 +55,17 @@ func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
6255
return RawSyscall6(trap, a1, a2, a3, 0, 0, 0)
6356
}
6457

58+
//go:uintptrkeepalive
59+
//go:nosplit
60+
//go:norace
61+
//go:linkname RawSyscall6
62+
func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) {
63+
var errno uintptr
64+
r1, r2, errno = runtimesyscall.Syscall6(trap, a1, a2, a3, a4, a5, a6)
65+
err = Errno(errno)
66+
return
67+
}
68+
6569
//go:uintptrkeepalive
6670
//go:nosplit
6771
//go:linkname Syscall

0 commit comments

Comments
 (0)