]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/atomic-compare-exchange-4.c
1 /* Test __atomic routines for existence and proper execution on 8 byte
2 values with each valid memory model. */
4 /* { dg-require-effective-target sync_long_long_runtime } */
5 /* { dg-options "" } */
6 /* { dg-options "-march=pentium" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
8 /* Test the execution of __atomic_compare_exchange_n builtin for a long_long. */
10 extern void abort(void);
13 long long expected
= 0;
15 long long desired
= ~0;
25 if (!__atomic_compare_exchange_n (&v
, &expected
, max
, STRONG
, __ATOMIC_RELAXED
, __ATOMIC_RELAXED
))
30 if (__atomic_compare_exchange_n (&v
, &expected
, 0, STRONG
, __ATOMIC_ACQUIRE
, __ATOMIC_RELAXED
))
35 if (!__atomic_compare_exchange_n (&v
, &expected
, 0, STRONG
, __ATOMIC_RELEASE
, __ATOMIC_ACQUIRE
))
42 if (__atomic_compare_exchange_n (&v
, &expected
, desired
, WEAK
, __ATOMIC_ACQ_REL
, __ATOMIC_ACQUIRE
))
47 if (!__atomic_compare_exchange_n (&v
, &expected
, desired
, STRONG
, __ATOMIC_SEQ_CST
, __ATOMIC_SEQ_CST
))
54 /* Now test the generic version. */
58 if (!__atomic_compare_exchange (&v
, &expected
, &max
, STRONG
, __ATOMIC_RELAXED
, __ATOMIC_RELAXED
))
63 if (__atomic_compare_exchange (&v
, &expected
, &zero
, STRONG
, __ATOMIC_ACQUIRE
, __ATOMIC_RELAXED
))
68 if (!__atomic_compare_exchange (&v
, &expected
, &zero
, STRONG
, __ATOMIC_RELEASE
, __ATOMIC_ACQUIRE
))
75 if (__atomic_compare_exchange (&v
, &expected
, &desired
, WEAK
, __ATOMIC_ACQ_REL
, __ATOMIC_ACQUIRE
))
80 if (!__atomic_compare_exchange (&v
, &expected
, &desired
, STRONG
, __ATOMIC_SEQ_CST
, __ATOMIC_SEQ_CST
))