1 /* Test atomic_load 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 if (atomic_load_explicit (&v, memory_order_relaxed) != count++) 20 abort (); 21 else 22 v++; 23 24 if (atomic_load_explicit (&v, memory_order_acquire) != count++) 25 abort (); 26 else 27 v++; 28 29 if (atomic_load_explicit (&v, memory_order_consume) != count++) 30 abort (); 31 else 32 v++; 33 34 if (atomic_load_explicit (&v, memory_order_seq_cst) != count++) 35 abort (); 36 else 37 v++; 38 39 if (atomic_load (&v) != count) 40 abort (); 41 42 return 0; 43 } 44 45