1 /* Test atomic_store routines for existence and proper execution on 2 8-byte values with each valid memory model. */ 3 /* { dg-do run } */ 4 /* { dg-options "-std=c11 -pedantic-errors" } */ 5 6 #include <stdatomic.h> 7 8 extern void abort (void); 9 10 _Atomic long long v; 11 long long count; 12 13 int main()14main () 15 { 16 v = 0; 17 count = 0; 18 19 atomic_init (&v, count + 1); 20 if (v != ++count) 21 abort (); 22 23 atomic_store_explicit (&v, count + 1, memory_order_relaxed); 24 if (v != ++count) 25 abort (); 26 27 atomic_store_explicit (&v, count + 1, memory_order_release); 28 if (v != ++count) 29 abort (); 30 31 atomic_store_explicit (&v, count + 1, memory_order_seq_cst); 32 if (v != ++count) 33 abort (); 34 35 count++; 36 37 atomic_store (&v, count); 38 if (v != count) 39 abort (); 40 41 return 0; 42 } 43 44