diff options
| author | Russ Cox <rsc@golang.org> | 2014-12-30 13:06:52 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2015-01-06 00:28:22 +0000 |
| commit | 813386f200e2cc15a05c8e641227e3cadffffc0d (patch) | |
| tree | 37db3b3caee4ffe63d9a8a29164c05f62dab777b /src/sync | |
| parent | ccdb50931f815fdf8de16f876478d7a1d0ee6696 (diff) | |
| download | go-813386f200e2cc15a05c8e641227e3cadffffc0d.tar.xz | |
sync/atomic: remove atomic pointer hammer tests
These depend on storing arbitrary integer values using
pointer atomics, and we can't support that anymore.
Change-Id: I8cadd6d462c3eebdbe7078f43fe7c779fa8f52b3
Reviewed-on: https://go-review.googlesource.com/2311
Reviewed-by: Rick Hudson <rlh@golang.org>
Diffstat (limited to 'src/sync')
| -rw-r--r-- | src/sync/atomic/atomic_test.go | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/src/sync/atomic/atomic_test.go b/src/sync/atomic/atomic_test.go index ec573aa8cf..3a59f5925b 100644 --- a/src/sync/atomic/atomic_test.go +++ b/src/sync/atomic/atomic_test.go @@ -759,14 +759,12 @@ var hammer32 = map[string]func(*uint32, int){ "SwapInt32": hammerSwapInt32, "SwapUint32": hammerSwapUint32, "SwapUintptr": hammerSwapUintptr32, - "SwapPointer": hammerSwapPointer32, "AddInt32": hammerAddInt32, "AddUint32": hammerAddUint32, "AddUintptr": hammerAddUintptr32, "CompareAndSwapInt32": hammerCompareAndSwapInt32, "CompareAndSwapUint32": hammerCompareAndSwapUint32, "CompareAndSwapUintptr": hammerCompareAndSwapUintptr32, - "CompareAndSwapPointer": hammerCompareAndSwapPointer32, } func init() { @@ -818,20 +816,6 @@ func hammerSwapUintptr32(uaddr *uint32, count int) { } } -func hammerSwapPointer32(uaddr *uint32, count int) { - // only safe when uintptr is 32-bit. - // not called on 64-bit systems. - addr := (*unsafe.Pointer)(unsafe.Pointer(uaddr)) - seed := int(uintptr(unsafe.Pointer(&count))) - for i := 0; i < count; i++ { - new := uintptr(seed+i)<<16 | uintptr(seed+i)<<16>>16 - old := uintptr(SwapPointer(addr, unsafe.Pointer(new))) - if old>>16 != old<<16>>16 { - panic(fmt.Sprintf("SwapPointer is not atomic: %#08x", old)) - } - } -} - func hammerAddInt32(uaddr *uint32, count int) { addr := (*int32)(unsafe.Pointer(uaddr)) for i := 0; i < count; i++ { @@ -891,20 +875,6 @@ func hammerCompareAndSwapUintptr32(uaddr *uint32, count int) { } } -func hammerCompareAndSwapPointer32(uaddr *uint32, count int) { - // only safe when uintptr is 32-bit. - // not called on 64-bit systems. - addr := (*unsafe.Pointer)(unsafe.Pointer(uaddr)) - for i := 0; i < count; i++ { - for { - v := LoadPointer(addr) - if CompareAndSwapPointer(addr, v, unsafe.Pointer(uintptr(v)+1)) { - break - } - } - } -} - func TestHammer32(t *testing.T) { const p = 4 n := 100000 @@ -940,14 +910,12 @@ var hammer64 = map[string]func(*uint64, int){ "SwapInt64": hammerSwapInt64, "SwapUint64": hammerSwapUint64, "SwapUintptr": hammerSwapUintptr64, - "SwapPointer": hammerSwapPointer64, "AddInt64": hammerAddInt64, "AddUint64": hammerAddUint64, "AddUintptr": hammerAddUintptr64, "CompareAndSwapInt64": hammerCompareAndSwapInt64, "CompareAndSwapUint64": hammerCompareAndSwapUint64, "CompareAndSwapUintptr": hammerCompareAndSwapUintptr64, - "CompareAndSwapPointer": hammerCompareAndSwapPointer64, } func init() { @@ -999,20 +967,6 @@ func hammerSwapUintptr64(uaddr *uint64, count int) { } } -func hammerSwapPointer64(uaddr *uint64, count int) { - // only safe when uintptr is 64-bit. - // not called on 32-bit systems. - addr := (*unsafe.Pointer)(unsafe.Pointer(uaddr)) - seed := int(uintptr(unsafe.Pointer(&count))) - for i := 0; i < count; i++ { - new := uintptr(seed+i)<<32 | uintptr(seed+i)<<32>>32 - old := uintptr(SwapPointer(addr, unsafe.Pointer(new))) - if old>>32 != old<<32>>32 { - panic(fmt.Sprintf("SwapPointer is not atomic: %v", old)) - } - } -} - func hammerAddInt64(uaddr *uint64, count int) { addr := (*int64)(unsafe.Pointer(uaddr)) for i := 0; i < count; i++ { @@ -1072,20 +1026,6 @@ func hammerCompareAndSwapUintptr64(uaddr *uint64, count int) { } } -func hammerCompareAndSwapPointer64(uaddr *uint64, count int) { - // only safe when uintptr is 64-bit. - // not called on 32-bit systems. - addr := (*unsafe.Pointer)(unsafe.Pointer(uaddr)) - for i := 0; i < count; i++ { - for { - v := LoadPointer(addr) - if CompareAndSwapPointer(addr, v, unsafe.Pointer(uintptr(v)+1)) { - break - } - } - } -} - func TestHammer64(t *testing.T) { if test64err != nil { t.Skipf("Skipping 64-bit tests: %v", test64err) |
