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 // FreeBSD's umtx_op syscall is effectively the same as Linux's futex, and
20 // thus the code is largely similar. See Linux implementation
21 // and lock_futex.go for comments.
24 func futexsleep(addr
*uint32, val
uint32, ns
int64) {
26 futexsleep1(addr
, val
, ns
)
30 func futexsleep1(addr
*uint32, val
uint32, ns
int64) {
34 ut
._clockid
= _CLOCK_MONOTONIC
35 ut
._timeout
.set_sec(int64(timediv(ns
, 1000000000, (*int32)(unsafe
.Pointer(&ut
._timeout
.tv_nsec
)))))
38 ret
:= sys_umtx_op(addr
, _UMTX_OP_WAIT_UINT_PRIVATE
, val
, unsafe
.Sizeof(*utp
), utp
)
39 if ret
>= 0 || ret
== -_EINTR
{
42 print("umtx_wait addr=", addr
, " val=", val
, " ret=", ret
, "\n")
43 *(*int32)(unsafe
.Pointer(uintptr(0x1005))) = 0x1005
47 func futexwakeup(addr
*uint32, cnt
uint32) {
48 ret
:= sys_umtx_op(addr
, _UMTX_OP_WAKE_PRIVATE
, cnt
, 0, nil)
54 print("umtx_wake_addr=", addr
, " ret=", ret
, "\n")