diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-03-30 15:33:16 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-03-30 15:33:16 +0000 |
commit | f72f4169133572cf62f1e872c5657cdbc4d5de2c (patch) | |
tree | 9382d76e5dc68294cdf3c4f2c03a9f61b44fb014 /libgo/go/sync | |
parent | f2034d064c29d9620c5562b2b5b517bdc6c7a672 (diff) | |
download | gcc-f72f4169133572cf62f1e872c5657cdbc4d5de2c.zip gcc-f72f4169133572cf62f1e872c5657cdbc4d5de2c.tar.gz gcc-f72f4169133572cf62f1e872c5657cdbc4d5de2c.tar.bz2 |
Update to current Go library.
From-SVN: r171732
Diffstat (limited to 'libgo/go/sync')
-rw-r--r-- | libgo/go/sync/atomic/atomic_test.go | 55 | ||||
-rw-r--r-- | libgo/go/sync/atomic/doc.go | 5 | ||||
-rw-r--r-- | libgo/go/sync/rwmutex_test.go | 24 |
3 files changed, 63 insertions, 21 deletions
diff --git a/libgo/go/sync/atomic/atomic_test.go b/libgo/go/sync/atomic/atomic_test.go index 7b204b1..119ad00 100644 --- a/libgo/go/sync/atomic/atomic_test.go +++ b/libgo/go/sync/atomic/atomic_test.go @@ -2,10 +2,11 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package atomic +package atomic_test import ( "runtime" + . "sync/atomic" "testing" "unsafe" ) @@ -27,6 +28,16 @@ const ( magic64 = 0xdeddeadbeefbeef ) +// Do the 64-bit functions panic? If so, don't bother testing. +var test64err = func() (err interface{}) { + defer func() { + err = recover() + }() + var x int64 + AddInt64(&x, 1) + return nil +}() + func TestAddInt32(t *testing.T) { var x struct { before int32 @@ -70,6 +81,10 @@ func TestAddUint32(t *testing.T) { } func TestAddInt64(t *testing.T) { + if test64err != nil { + t.Logf("Skipping 64-bit tests: %v", test64err) + return + } var x struct { before int64 i int64 @@ -91,6 +106,10 @@ func TestAddInt64(t *testing.T) { } func TestAddUint64(t *testing.T) { + if test64err != nil { + t.Logf("Skipping 64-bit tests: %v", test64err) + return + } var x struct { before uint64 i uint64 @@ -193,6 +212,10 @@ func TestCompareAndSwapUint32(t *testing.T) { } func TestCompareAndSwapInt64(t *testing.T) { + if test64err != nil { + t.Logf("Skipping 64-bit tests: %v", test64err) + return + } var x struct { before int64 i int64 @@ -222,6 +245,10 @@ func TestCompareAndSwapInt64(t *testing.T) { } func TestCompareAndSwapUint64(t *testing.T) { + if test64err != nil { + t.Logf("Skipping 64-bit tests: %v", test64err) + return + } var x struct { before uint64 i uint64 @@ -370,10 +397,11 @@ func hammerCompareAndSwapUintptr32(uval *uint32, count int) { } func TestHammer32(t *testing.T) { - const ( - n = 100000 - p = 4 - ) + const p = 4 + n := 100000 + if testing.Short() { + n = 1000 + } defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(p)) for _, tt := range hammer32 { @@ -391,7 +419,7 @@ func TestHammer32(t *testing.T) { for i := 0; i < p; i++ { <-c } - if val != n*p { + if val != uint32(n)*p { t.Errorf("%s: val=%d want %d", tt.name, val, n*p) } } @@ -478,10 +506,15 @@ func hammerCompareAndSwapUintptr64(uval *uint64, count int) { } func TestHammer64(t *testing.T) { - const ( - n = 100000 - p = 4 - ) + if test64err != nil { + t.Logf("Skipping 64-bit tests: %v", test64err) + return + } + const p = 4 + n := 100000 + if testing.Short() { + n = 1000 + } defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(p)) for _, tt := range hammer64 { @@ -499,7 +532,7 @@ func TestHammer64(t *testing.T) { for i := 0; i < p; i++ { <-c } - if val != n*p { + if val != uint64(n)*p { t.Errorf("%s: val=%d want %d", tt.name, val, n*p) } } diff --git a/libgo/go/sync/atomic/doc.go b/libgo/go/sync/atomic/doc.go index 1335def..ec5a0d3 100644 --- a/libgo/go/sync/atomic/doc.go +++ b/libgo/go/sync/atomic/doc.go @@ -55,3 +55,8 @@ func AddUint64(val *uint64, delta uint64) (new uint64) // AddUintptr atomically adds delta to *val and returns the new value. func AddUintptr(val *uintptr, delta uintptr) (new uintptr) + +// Helper for ARM. Linker will discard on other systems +func panic64() { + panic("sync/atomic: broken 64-bit atomic operations (buggy QEMU)") +} diff --git a/libgo/go/sync/rwmutex_test.go b/libgo/go/sync/rwmutex_test.go index 4050792..9fb89f8 100644 --- a/libgo/go/sync/rwmutex_test.go +++ b/libgo/go/sync/rwmutex_test.go @@ -102,16 +102,20 @@ func HammerRWMutex(gomaxprocs, numReaders, num_iterations int) { } func TestRWMutex(t *testing.T) { - HammerRWMutex(1, 1, 1000) - HammerRWMutex(1, 3, 1000) - HammerRWMutex(1, 10, 1000) - HammerRWMutex(4, 1, 1000) - HammerRWMutex(4, 3, 1000) - HammerRWMutex(4, 10, 1000) - HammerRWMutex(10, 1, 1000) - HammerRWMutex(10, 3, 1000) - HammerRWMutex(10, 10, 1000) - HammerRWMutex(10, 5, 10000) + n := 1000 + if testing.Short() { + n = 5 + } + HammerRWMutex(1, 1, n) + HammerRWMutex(1, 3, n) + HammerRWMutex(1, 10, n) + HammerRWMutex(4, 1, n) + HammerRWMutex(4, 3, n) + HammerRWMutex(4, 10, n) + HammerRWMutex(10, 1, n) + HammerRWMutex(10, 3, n) + HammerRWMutex(10, 10, n) + HammerRWMutex(10, 5, n) } func TestRLocker(t *testing.T) { |