summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/atomic-noinline.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/atomic-noinline.c')
-rw-r--r--gcc/testsuite/gcc.dg/atomic-noinline.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/atomic-noinline.c b/gcc/testsuite/gcc.dg/atomic-noinline.c
new file mode 100644
index 00000000000..06a93e0058e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/atomic-noinline.c
@@ -0,0 +1,56 @@
+/* Test generic __atomic routines for proper function calling.
+ memory model. */
+/* { dg-options "-w -fno-inline-atomics" } */
+/* { dg-do run } */
+/* { dg-additional-sources "atomic-noinline-aux.c" } */
+
+/* Test that -fno-inline-atomics works as expected.
+ atomic-generic-aux provide the expected routines which simply set the
+ value of the first parameter to */
+
+#include <stdlib.h>
+#include <stdbool.h>
+
+extern void abort();
+
+short as,bs,cs;
+char ac,bc,cc;
+
+main ()
+{
+
+ ac = __atomic_exchange_n (&bc, cc, __ATOMIC_RELAXED);
+ if (bc != 1)
+ abort ();
+
+ as = __atomic_load_n (&bs, __ATOMIC_SEQ_CST);
+ if (bs != 1)
+ abort ();
+
+ __atomic_store_n (&ac, bc, __ATOMIC_RELAXED);
+ if (ac != 1)
+ abort ();
+
+ __atomic_compare_exchange_n (&as, &bs, cs, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
+ if (as != 1)
+ abort ();
+
+ ac = __atomic_fetch_add (&cc, 15, __ATOMIC_SEQ_CST);
+ if (cc != 1)
+ abort ();
+
+ /* This should be translated to __atomic_fetch_add for the library */
+ as = __atomic_add_fetch (&cs, 10, __ATOMIC_RELAXED);
+
+ if (cs != 1)
+ abort ();
+
+ /* The fake external function should return 10. */
+ if (__atomic_is_lock_free (4, 0) != 10)
+ abort ();
+
+ return 0;
+}
+
+
+