aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/atomic-flag.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.dg/atomic-flag.c')
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/atomic-flag.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/atomic-flag.c b/gcc-4.9/gcc/testsuite/gcc.dg/atomic-flag.c
new file mode 100644
index 000000000..6e79b9027
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/atomic-flag.c
@@ -0,0 +1,32 @@
+/* Test __atomic routines for existence and execution. */
+/* { dg-do run } */
+/* { dg-require-effective-target sync_char_short } */
+
+/* Test that __atomic_test_and_set and __atomic_clear builtins execute. */
+
+extern void abort(void);
+unsigned char a;
+
+int
+main ()
+{
+ int b;
+
+ __atomic_clear (&a, __ATOMIC_RELAXED);
+ if (a != 0)
+ abort ();
+
+ b = __atomic_test_and_set (&a, __ATOMIC_SEQ_CST);
+ if (a != __GCC_ATOMIC_TEST_AND_SET_TRUEVAL || b != 0)
+ abort ();
+
+ b = __atomic_test_and_set (&a, __ATOMIC_ACQ_REL);
+ if (a != __GCC_ATOMIC_TEST_AND_SET_TRUEVAL || b != 1)
+ abort ();
+
+ __atomic_clear (&a, __ATOMIC_SEQ_CST);
+ if (a != 0)
+ abort ();
+
+ return 0;
+}