1 /* Test __atomic routines for existence and proper execution on 2 byte
2 values with each valid memory model. */
4 /* { dg-require-effective-target sync_char_short } */
6 /* Test the execution of the __atomic_X builtin for a short. */
8 extern void abort(void);
17 if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) != count++)
20 if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) != count++)
23 if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) != count++)
26 if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) != count++)
29 if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) != count++)
32 /* Now test the generic version. */
36 __atomic_exchange (&v, &count, &ret, __ATOMIC_RELAXED);
37 if (ret != count - 1 || v != count)
41 __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQUIRE);
42 if (ret != count - 1 || v != count)
46 __atomic_exchange (&v, &count, &ret, __ATOMIC_RELEASE);
47 if (ret != count - 1 || v != count)
51 __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQ_REL);
52 if (ret != count - 1 || v != count)
56 __atomic_exchange (&v, &count, &ret, __ATOMIC_SEQ_CST);
57 if (ret != count - 1 || v != count)