diff options
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.dg/atomic/stdatomic-store-2.c')
-rw-r--r-- | gcc-4.9/gcc/testsuite/gcc.dg/atomic/stdatomic-store-2.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/atomic/stdatomic-store-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/atomic/stdatomic-store-2.c new file mode 100644 index 000000000..0bbba1cef --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/atomic/stdatomic-store-2.c @@ -0,0 +1,43 @@ +/* Test atomic_store routines for existence and proper execution on + 2-byte values with each valid memory model. */ +/* { dg-do run } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include <stdatomic.h> + +extern void abort (void); + +_Atomic short v; +short count; + +int +main () +{ + v = 0; + count = 0; + + atomic_init (&v, count + 1); + if (v != ++count) + abort (); + + atomic_store_explicit (&v, count + 1, memory_order_relaxed); + if (v != ++count) + abort (); + + atomic_store_explicit (&v, count + 1, memory_order_release); + if (v != ++count) + abort (); + + atomic_store_explicit (&v, count + 1, memory_order_seq_cst); + if (v != ++count) + abort (); + + count++; + + atomic_store (&v, count); + if (v != count) + abort (); + + return 0; +} + |