
Remove the old locking code written in C. Add a shell script mkrsysinfo.sh to generate the runtime_sysinfo.go file, so that we can get Go copies of the system time structures and other types. Tweak the compiler so that when compiling the runtime package the address operator does not cause local variables to escape. When the gc compiler compiles the runtime, an escaping local variable is treated as an error. We should implement that, instead of this change, when escape analysis is turned on. Tweak the compiler so that the generated C header does not include names that start with an underscore followed by a non-upper-case letter, except for the special cases of _defer and _panic. Otherwise we translate C types to Go in runtime_sysinfo.go and then generate those Go types back as C types in runtime.inc, which is useless and painful for the C code. Change entersyscall and friends to take a dummy argument, as the gc versions do, to simplify calls from the shared code. Reviewed-on: https://go-review.googlesource.com/30079 From-SVN: r240657
56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
// 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.
|
|
|
|
package runtime
|
|
|
|
import (
|
|
"unsafe"
|
|
)
|
|
|
|
type mOS struct {
|
|
unused byte
|
|
}
|
|
|
|
//go:noescape
|
|
//extern _umtx_op
|
|
func sys_umtx_op(addr *uint32, mode int32, val uint32, ptr2, ts *timespec) int32
|
|
|
|
// FreeBSD's umtx_op syscall is effectively the same as Linux's futex, and
|
|
// thus the code is largely similar. See Linux implementation
|
|
// and lock_futex.go for comments.
|
|
|
|
//go:nosplit
|
|
func futexsleep(addr *uint32, val uint32, ns int64) {
|
|
systemstack(func() {
|
|
futexsleep1(addr, val, ns)
|
|
})
|
|
}
|
|
|
|
func futexsleep1(addr *uint32, val uint32, ns int64) {
|
|
var tsp *timespec
|
|
if ns >= 0 {
|
|
var ts timespec
|
|
ts.tv_nsec = 0
|
|
ts.set_sec(int64(timediv(ns, 1000000000, (*int32)(unsafe.Pointer(&ts.tv_nsec)))))
|
|
tsp = &ts
|
|
}
|
|
ret := sys_umtx_op(addr, _UMTX_OP_WAIT_UINT_PRIVATE, val, nil, tsp)
|
|
if ret >= 0 || ret == -_EINTR {
|
|
return
|
|
}
|
|
print("umtx_wait addr=", addr, " val=", val, " ret=", ret, "\n")
|
|
*(*int32)(unsafe.Pointer(uintptr(0x1005))) = 0x1005
|
|
}
|
|
|
|
//go:nosplit
|
|
func futexwakeup(addr *uint32, cnt uint32) {
|
|
ret := sys_umtx_op(addr, _UMTX_OP_WAKE_PRIVATE, cnt, nil, nil)
|
|
if ret >= 0 {
|
|
return
|
|
}
|
|
|
|
systemstack(func() {
|
|
print("umtx_wake_addr=", addr, " ret=", ret, "\n")
|
|
})
|
|
}
|