1 // Copyright 2014 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.
15 func sys_umtx_sleep(addr
*uint32, val
, timeout
int32) int32
19 func sys_umtx_wakeup(addr
*uint32, val
int32) int32
22 func futexsleep(addr
*uint32, val
uint32, ns
int64) {
24 futexsleep1(addr
, val
, ns
)
28 func futexsleep1(addr
*uint32, val
uint32, ns
int64) {
31 // The timeout is specified in microseconds - ensure that we
32 // do not end up dividing to zero, which would put us to sleep
34 timeout
= timediv(ns
, 1000, nil)
40 // sys_umtx_sleep will return EWOULDBLOCK (EAGAIN) when the timeout
41 // expires or EBUSY if the mutex value does not match.
42 ret
:= sys_umtx_sleep(addr
, int32(val
), timeout
)
43 if ret
>= 0 || ret
== -_EINTR || ret
== -_EAGAIN || ret
== -_EBUSY
{
47 print("umtx_sleep addr=", addr
, " val=", val
, " ret=", ret
, "\n")
48 *(*int32)(unsafe
.Pointer(uintptr(0x1005))) = 0x1005
52 func futexwakeup(addr
*uint32, cnt
uint32) {
53 ret
:= sys_umtx_wakeup(addr
, int32(cnt
))
59 print("umtx_wake_addr=", addr
, " ret=", ret
, "\n")
60 *(*int32)(unsafe
.Pointer(uintptr(0x1006))) = 0x1006