* typeck2.c (cxx_incomplete_type_diagnostic): Revert change and
[official-gcc.git] / libgo / go / runtime / os_freebsd.go
bloba4d2886d6af5cee2589fe725c7bf4e6b942979bc
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.
5 package runtime
7 import (
8 "unsafe"
11 type mOS struct {
12 unused byte
15 //go:noescape
16 //extern _umtx_op
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.
23 //go:nosplit
24 func futexsleep(addr *uint32, val uint32, ns int64) {
25 systemstack(func() {
26 futexsleep1(addr, val, ns)
30 func futexsleep1(addr *uint32, val uint32, ns int64) {
31 var utp *umtx_time
32 if ns >= 0 {
33 var ut umtx_time
34 ut._clockid = _CLOCK_MONOTONIC
35 ut._timeout.set_sec(int64(timediv(ns, 1000000000, (*int32)(unsafe.Pointer(&ut._timeout.tv_nsec)))))
36 utp = &ut
38 ret := sys_umtx_op(addr, _UMTX_OP_WAIT_UINT_PRIVATE, val, unsafe.Sizeof(*utp), utp)
39 if ret >= 0 || ret == -_EINTR {
40 return
42 print("umtx_wait addr=", addr, " val=", val, " ret=", ret, "\n")
43 *(*int32)(unsafe.Pointer(uintptr(0x1005))) = 0x1005
46 //go:nosplit
47 func futexwakeup(addr *uint32, cnt uint32) {
48 ret := sys_umtx_op(addr, _UMTX_OP_WAKE_PRIVATE, cnt, 0, nil)
49 if ret >= 0 {
50 return
53 systemstack(func() {
54 print("umtx_wake_addr=", addr, " ret=", ret, "\n")