diff options
Diffstat (limited to 'third_party/gvsync/downgradable_rwmutex_unsafe.go')
-rw-r--r-- | third_party/gvsync/downgradable_rwmutex_unsafe.go | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/third_party/gvsync/downgradable_rwmutex_unsafe.go b/third_party/gvsync/downgradable_rwmutex_unsafe.go index 4d43eb765..069939033 100644 --- a/third_party/gvsync/downgradable_rwmutex_unsafe.go +++ b/third_party/gvsync/downgradable_rwmutex_unsafe.go @@ -3,6 +3,11 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build go1.12 +// +build !go1.14 + +// Check go:linkname function signatures when updating Go version. + // This is mostly copied from the standard library's sync/rwmutex.go. // // Happens-before relationships indicated to the race detector: @@ -19,6 +24,9 @@ import ( "unsafe" ) +//go:linkname runtimeSemacquire sync.runtime_Semacquire +func runtimeSemacquire(s *uint32) + // DowngradableRWMutex is identical to sync.RWMutex, but adds the DowngradeLock // method. type DowngradableRWMutex struct { @@ -62,7 +70,7 @@ func (rw *DowngradableRWMutex) RUnlock() { // A writer is pending. if atomic.AddInt32(&rw.readerWait, -1) == 0 { // The last reader unblocks the writer. - runtimeSemrelease(&rw.writerSem, false) + runtimeSemrelease(&rw.writerSem, false, 0) } } if RaceEnabled { @@ -103,7 +111,7 @@ func (rw *DowngradableRWMutex) Unlock() { } // Unblock blocked readers, if any. for i := 0; i < int(r); i++ { - runtimeSemrelease(&rw.readerSem, false) + runtimeSemrelease(&rw.readerSem, false, 0) } // Allow other writers to proceed. rw.w.Unlock() @@ -126,7 +134,7 @@ func (rw *DowngradableRWMutex) DowngradeLock() { // Unblock blocked readers, if any. Note that this loop starts as 1 since r // includes this goroutine. for i := 1; i < int(r); i++ { - runtimeSemrelease(&rw.readerSem, false) + runtimeSemrelease(&rw.readerSem, false, 0) } // Allow other writers to proceed to rw.w.Lock(). Note that they will still // block on rw.writerSem since at least this reader exists, such that @@ -136,9 +144,3 @@ func (rw *DowngradableRWMutex) DowngradeLock() { RaceEnable() } } - -//go:linkname runtimeSemacquire sync.runtime_Semacquire -func runtimeSemacquire(s *uint32) - -//go:linkname runtimeSemrelease sync.runtime_Semrelease -func runtimeSemrelease(s *uint32, handoff bool) |