Home | History | Annotate | Download | only in sync
      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 
      5 package sync
      6 
      7 import "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.
     14 func runtime_Semacquire(s *uint32)
     15 
     16 // Semrelease atomically increments *s and notifies a waiting goroutine
     17 // if one is blocked in Semacquire.
     18 // It is intended as a simple wakeup primitive for use by the synchronization
     19 // library and should not be used directly.
     20 func runtime_Semrelease(s *uint32)
     21 
     22 // Approximation of syncSema in runtime/sema.go.
     23 type syncSema struct {
     24 	lock uintptr
     25 	head unsafe.Pointer
     26 	tail unsafe.Pointer
     27 }
     28 
     29 // Syncsemacquire waits for a pairing Syncsemrelease on the same semaphore s.
     30 func runtime_Syncsemacquire(s *syncSema)
     31 
     32 // Syncsemrelease waits for n pairing Syncsemacquire on the same semaphore s.
     33 func runtime_Syncsemrelease(s *syncSema, n uint32)
     34 
     35 // Ensure that sync and runtime agree on size of syncSema.
     36 func runtime_Syncsemcheck(size uintptr)
     37 func init() {
     38 	var s syncSema
     39 	runtime_Syncsemcheck(unsafe.Sizeof(s))
     40 }
     41 
     42 // Active spinning runtime support.
     43 // runtime_canSpin returns true is spinning makes sense at the moment.
     44 func runtime_canSpin(i int) bool
     45 
     46 // runtime_doSpin does active spinning.
     47 func runtime_doSpin()
     48