1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
17 func sys_umtx_op(addr
*uint32, mode
int32, val
uint32, uaddr1 uinptr
, ts
*umtx_time
) int32
19 func getPageSize() uintptr {
20 mib
:= [2]uint32{_CTL_HW
, _HW_PAGESIZE
}
22 nout
:= unsafe
.Sizeof(out
)
23 ret
:= sysctl(&mib
[0], 2, (*byte)(unsafe
.Pointer(&out
)), &nout
, nil, 0)
30 // FreeBSD's umtx_op syscall is effectively the same as Linux's futex, and
31 // thus the code is largely similar. See Linux implementation
32 // and lock_futex.go for comments.
35 func futexsleep(addr
*uint32, val
uint32, ns
int64) {
37 futexsleep1(addr
, val
, ns
)
41 func futexsleep1(addr
*uint32, val
uint32, ns
int64) {
45 ut
._clockid
= _CLOCK_MONOTONIC
46 ut
._timeout
.set_sec(int64(timediv(ns
, 1000000000, (*int32)(unsafe
.Pointer(&ut
._timeout
.tv_nsec
)))))
49 ret
:= sys_umtx_op(addr
, _UMTX_OP_WAIT_UINT_PRIVATE
, val
, unsafe
.Sizeof(*utp
), utp
)
50 if ret
>= 0 || ret
== -_EINTR
{
53 print("umtx_wait addr=", addr
, " val=", val
, " ret=", ret
, "\n")
54 *(*int32)(unsafe
.Pointer(uintptr(0x1005))) = 0x1005
58 func futexwakeup(addr
*uint32, cnt
uint32) {
59 ret
:= sys_umtx_op(addr
, _UMTX_OP_WAKE_PRIVATE
, cnt
, 0, nil)
65 print("umtx_wake_addr=", addr
, " ret=", ret
, "\n")