github.com/akaros/go-akaros@v0.0.0-20181004170632-85005d477eab/src/runtime/parlib/funcs.go (about) 1 // Copyright 2013 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. 4 // 5 // +build akaros 6 7 package parlib 8 9 /* 10 #cgo akaros LDFLAGS: -lpthread -lbenchutil -lm 11 12 #define _LARGEFILE64_SOURCE 13 14 #include <futex.h> 15 #include <parlib/mcs.h> 16 17 */ 18 import "C" 19 import ( 20 "unsafe" 21 ) 22 23 var Procinfo *ProcinfoType = (*ProcinfoType)(unsafe.Pointer(uintptr(C.UINFO))) 24 25 func Futex(uaddr *int32, op int32, val int32, 26 timeout *Timespec, uaddr2 *int32, val3 int32) (ret int32) { 27 // For now, akaros futexes don't support uaddr2 or val3, so we 28 // just 0 them out. 29 uaddr2 = nil 30 val3 = 0 31 // Also, the minimum timout is 1ms, so up it to that if it's too small 32 if timeout != nil { 33 if timeout.Sec == 0 { 34 if timeout.Nsec < 1000000 { 35 timeout.Nsec = 1000000 36 } 37 } 38 } 39 return int32(C.futex((*C.int)(unsafe.Pointer(uaddr)), 40 C.int(op), C.int(val), 41 (*C.struct_timespec)(unsafe.Pointer(timeout)), 42 (*C.int)(unsafe.Pointer(uaddr2)), C.int(val3))) 43 }