mirror of
https://github.com/golang/go
synced 2024-11-22 22:30:02 -07:00
runtime: convert openbsd/amd64 locking to libc
Switch openbsd/amd64 to locking via libc, rather than performing direct system calls. Update #36435 Change-Id: I5e92bd70ce557b78ff385577088a9775cc468ea9 Reviewed-on: https://go-review.googlesource.com/c/go/+/270378 Trust: Joel Sing <joel@sing.id.au> Run-TryBot: Joel Sing <joel@sing.id.au> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
824f2d635c
commit
928bda4f4a
@ -46,14 +46,6 @@ func raiseproc(sig uint32)
|
|||||||
func getthrid() int32
|
func getthrid() int32
|
||||||
func thrkill(tid int32, sig int)
|
func thrkill(tid int32, sig int)
|
||||||
|
|
||||||
//go:noescape
|
|
||||||
func thrsleep(ident uintptr, clock_id int32, tsp *timespec, lock uintptr, abort *uint32) int32
|
|
||||||
|
|
||||||
//go:noescape
|
|
||||||
func thrwakeup(ident uintptr, n int32) int32
|
|
||||||
|
|
||||||
func osyield()
|
|
||||||
|
|
||||||
func kqueue() int32
|
func kqueue() int32
|
||||||
|
|
||||||
//go:noescape
|
//go:noescape
|
||||||
|
15
src/runtime/os_openbsd_syscall1.go
Normal file
15
src/runtime/os_openbsd_syscall1.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright 2011 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.
|
||||||
|
|
||||||
|
// +build openbsd,!amd64
|
||||||
|
|
||||||
|
package runtime
|
||||||
|
|
||||||
|
//go:noescape
|
||||||
|
func thrsleep(ident uintptr, clock_id int32, tsp *timespec, lock uintptr, abort *uint32) int32
|
||||||
|
|
||||||
|
//go:noescape
|
||||||
|
func thrwakeup(ident uintptr, n int32) int32
|
||||||
|
|
||||||
|
func osyield()
|
34
src/runtime/sys_openbsd1.go
Normal file
34
src/runtime/sys_openbsd1.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
// +build openbsd,amd64
|
||||||
|
|
||||||
|
package runtime
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
//go:nosplit
|
||||||
|
//go:cgo_unsafe_args
|
||||||
|
func thrsleep(ident uintptr, clock_id int32, tsp *timespec, lock uintptr, abort *uint32) int32 {
|
||||||
|
return libcCall(unsafe.Pointer(funcPC(thrsleep_trampoline)), unsafe.Pointer(&ident))
|
||||||
|
}
|
||||||
|
func thrsleep_trampoline()
|
||||||
|
|
||||||
|
//go:nosplit
|
||||||
|
//go:cgo_unsafe_args
|
||||||
|
func thrwakeup(ident uintptr, n int32) int32 {
|
||||||
|
return libcCall(unsafe.Pointer(funcPC(thrwakeup_trampoline)), unsafe.Pointer(&ident))
|
||||||
|
}
|
||||||
|
func thrwakeup_trampoline()
|
||||||
|
|
||||||
|
func osyield() {
|
||||||
|
libcCall(unsafe.Pointer(funcPC(sched_yield_trampoline)), unsafe.Pointer(nil))
|
||||||
|
}
|
||||||
|
func sched_yield_trampoline()
|
||||||
|
|
||||||
|
//go:cgo_import_dynamic libc_thrsleep __thrsleep "libc.so"
|
||||||
|
//go:cgo_import_dynamic libc_thrwakeup __thrwakeup "libc.so"
|
||||||
|
//go:cgo_import_dynamic libc_sched_yield sched_yield "libc.so"
|
||||||
|
|
||||||
|
//go:cgo_import_dynamic _ _ "libc.so"
|
@ -168,28 +168,32 @@ TEXT runtime·pthread_kill_trampoline(SB),NOSPLIT,$0
|
|||||||
POPQ BP
|
POPQ BP
|
||||||
RET
|
RET
|
||||||
|
|
||||||
TEXT runtime·osyield(SB),NOSPLIT,$0
|
TEXT runtime·thrsleep_trampoline(SB),NOSPLIT,$0
|
||||||
MOVL $298, AX // sys_sched_yield
|
PUSHQ BP
|
||||||
SYSCALL
|
MOVQ SP, BP
|
||||||
|
MOVL 8(DI), SI // arg 2 - clock_id
|
||||||
|
MOVQ 16(DI), DX // arg 3 - abstime
|
||||||
|
MOVQ 24(DI), CX // arg 3 - lock
|
||||||
|
MOVQ 32(DI), R8 // arg 4 - abort
|
||||||
|
MOVQ 0(DI), DI // arg 1 - id
|
||||||
|
CALL libc_thrsleep(SB)
|
||||||
|
POPQ BP
|
||||||
RET
|
RET
|
||||||
|
|
||||||
TEXT runtime·thrsleep(SB),NOSPLIT,$0
|
TEXT runtime·thrwakeup_trampoline(SB),NOSPLIT,$0
|
||||||
MOVQ ident+0(FP), DI // arg 1 - ident
|
PUSHQ BP
|
||||||
MOVL clock_id+8(FP), SI // arg 2 - clock_id
|
MOVQ SP, BP
|
||||||
MOVQ tsp+16(FP), DX // arg 3 - tp
|
MOVL 8(DI), SI // arg 2 - count
|
||||||
MOVQ lock+24(FP), R10 // arg 4 - lock
|
MOVQ 0(DI), DI // arg 1 - id
|
||||||
MOVQ abort+32(FP), R8 // arg 5 - abort
|
CALL libc_thrwakeup(SB)
|
||||||
MOVL $94, AX // sys___thrsleep
|
POPQ BP
|
||||||
SYSCALL
|
|
||||||
MOVL AX, ret+40(FP)
|
|
||||||
RET
|
RET
|
||||||
|
|
||||||
TEXT runtime·thrwakeup(SB),NOSPLIT,$0
|
TEXT runtime·sched_yield_trampoline(SB),NOSPLIT,$0
|
||||||
MOVQ ident+0(FP), DI // arg 1 - ident
|
PUSHQ BP
|
||||||
MOVL n+8(FP), SI // arg 2 - n
|
MOVQ SP, BP
|
||||||
MOVL $301, AX // sys___thrwakeup
|
CALL libc_sched_yield(SB)
|
||||||
SYSCALL
|
POPQ BP
|
||||||
MOVL AX, ret+16(FP)
|
|
||||||
RET
|
RET
|
||||||
|
|
||||||
// Exit the entire program (like C exit)
|
// Exit the entire program (like C exit)
|
||||||
|
Loading…
Reference in New Issue
Block a user