aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/atomic/stdatomic-load-1.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.dg/atomic/stdatomic-load-1.c')
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/atomic/stdatomic-load-1.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/atomic/stdatomic-load-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/atomic/stdatomic-load-1.c
new file mode 100644
index 000000000..16bea684c
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/atomic/stdatomic-load-1.c
@@ -0,0 +1,44 @@
+/* Test atomic_load routines for existence and proper execution on
+ 1-byte values with each valid memory model. */
+/* { dg-do run } */
+/* { dg-options "-std=c11 -pedantic-errors" } */
+
+#include <stdatomic.h>
+
+extern void abort (void);
+
+_Atomic char v;
+char count;
+
+int
+main ()
+{
+ v = 0;
+ count = 0;
+
+ if (atomic_load_explicit (&v, memory_order_relaxed) != count++)
+ abort ();
+ else
+ v++;
+
+ if (atomic_load_explicit (&v, memory_order_acquire) != count++)
+ abort ();
+ else
+ v++;
+
+ if (atomic_load_explicit (&v, memory_order_consume) != count++)
+ abort ();
+ else
+ v++;
+
+ if (atomic_load_explicit (&v, memory_order_seq_cst) != count++)
+ abort ();
+ else
+ v++;
+
+ if (atomic_load (&v) != count)
+ abort ();
+
+ return 0;
+}
+