diff options
author | Russ Cox <rsc@golang.org> | 2009-10-15 17:46:53 -0700 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2009-10-15 17:46:53 -0700 |
commit | a86d7c2bd9196ad9c768a4cb52b5434d23f8fe84 (patch) | |
tree | b18dff11371da4606dfa47c3018e78f62f3b6564 /src/pkg/runtime | |
parent | 96c3809cb09820dd80548f1940a35e442c93c65d (diff) | |
download | golang-a86d7c2bd9196ad9c768a4cb52b5434d23f8fe84.tar.gz |
publish semacquire and semrelease for use by sync.
more enforcing package boundaries
R=r
DELTA=46 (13 added, 15 deleted, 18 changed)
OCL=35806
CL=35806
Diffstat (limited to 'src/pkg/runtime')
-rw-r--r-- | src/pkg/runtime/extern.go | 11 | ||||
-rw-r--r-- | src/pkg/runtime/sema.cgo | 6 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/pkg/runtime/extern.go b/src/pkg/runtime/extern.go index 131767aef..70c6f434b 100644 --- a/src/pkg/runtime/extern.go +++ b/src/pkg/runtime/extern.go @@ -46,3 +46,14 @@ func GOMAXPROCS(n int) // Cgocalls returns the number of cgo calls made by the current process. func Cgocalls() int64 + +// Semacquire waits until *s > 0 and then atomically decrements it. +// It is intended as a simple sleep primitive for use by the synchronization +// library and should not be used directly. +func Semacquire(s *uint32) + +// Semrelease atomically increments *s and notifies a waiting goroutine +// if one is blocked in Semacquire. +// It is intended as a simple wakeup primitive for use by the synchronization +// library and should not be used directly. +func Semrelease(s *uint32) diff --git a/src/pkg/runtime/sema.cgo b/src/pkg/runtime/sema.cgo index 81834ae6d..71395ce77 100644 --- a/src/pkg/runtime/sema.cgo +++ b/src/pkg/runtime/sema.cgo @@ -17,7 +17,7 @@ // See Mullender and Cox, ``Semaphores in Plan 9,'' // http://swtch.com/semaphore.pdf -package sync +package runtime #include "runtime.h" typedef struct Sema Sema; @@ -176,10 +176,10 @@ semrelease(uint32 *addr) semwakeup(addr); } -func semacquire(addr *uint32) { +func Semacquire(addr *uint32) { semacquire(addr); } -func semrelease(addr *uint32) { +func Semrelease(addr *uint32) { semrelease(addr); } |