3 // Copyright 2018 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
16 func test32(a, b []int) bool {
17 // Try to generate flag value, issue atomic
18 // adds and then re-use the flag value to see if
19 // the atomic add has clobbered them.
20 atomic.AddInt32(&cnt32, 1)
22 atomic.AddInt32(&cnt32, 2)
24 atomic.AddInt32(&cnt32, 4)
26 atomic.AddInt32(&cnt32, 8)
29 atomic.AddInt32(&cnt32, 16)
31 return atomic.LoadInt32(&cnt32) == 31
37 func test64(a, b []int) bool {
38 // Try to generate flag value, issue atomic
39 // adds and then re-use the flag value to see if
40 // the atomic add has clobbered them.
41 atomic.AddInt64(&cnt64, 1)
43 atomic.AddInt64(&cnt64, 2)
45 atomic.AddInt64(&cnt64, 4)
47 atomic.AddInt64(&cnt64, 8)
50 atomic.AddInt64(&cnt64, 16)
52 return atomic.LoadInt64(&cnt64) == 31
56 if !test32([]int{}, []int{}) {
59 if !test64([]int{}, []int{}) {