1// Copyright 2012 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 5package sync 6 7import "unsafe" 8 9// defined in package runtime 10 11// Semacquire waits until *s > 0 and then atomically decrements it. 12// It is intended as a simple sleep primitive for use by the synchronization 13// library and should not be used directly. 14func runtime_Semacquire(s *uint32) 15 16// SemacquireMutex is like Semacquire, but for profiling contended Mutexes. 17// If lifo is true, queue waiter at the head of wait queue. 18func runtime_SemacquireMutex(s *uint32, lifo bool) 19 20// Semrelease atomically increments *s and notifies a waiting goroutine 21// if one is blocked in Semacquire. 22// It is intended as a simple wakeup primitive for use by the synchronization 23// library and should not be used directly. 24// If handoff is true, pass count directly to the first waiter. 25func runtime_Semrelease(s *uint32, handoff bool) 26 27// Approximation of notifyList in runtime/sema.go. Size and alignment must 28// agree. 29type notifyList struct { 30 wait uint32 31 notify uint32 32 lock uintptr 33 head unsafe.Pointer 34 tail unsafe.Pointer 35} 36 37// See runtime/sema.go for documentation. 38func runtime_notifyListAdd(l *notifyList) uint32 39 40// See runtime/sema.go for documentation. 41func runtime_notifyListWait(l *notifyList, t uint32) 42 43// See runtime/sema.go for documentation. 44func runtime_notifyListNotifyAll(l *notifyList) 45 46// See runtime/sema.go for documentation. 47func runtime_notifyListNotifyOne(l *notifyList) 48 49// Ensure that sync and runtime agree on size of notifyList. 50func runtime_notifyListCheck(size uintptr) 51func init() { 52 var n notifyList 53 runtime_notifyListCheck(unsafe.Sizeof(n)) 54} 55 56// Active spinning runtime support. 57// runtime_canSpin reports whether spinning makes sense at the moment. 58func runtime_canSpin(i int) bool 59 60// runtime_doSpin does active spinning. 61func runtime_doSpin() 62 63func runtime_nanotime() int64 64