summaryrefslogtreecommitdiffstats
path: root/libatomic/testsuite/libatomic.c/atomic-exchange-5.c
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2012-05-01 15:48:28 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2012-05-01 15:48:28 +0000
commit6db1d2ca83f9327020b75f6c1610649bb18e71db (patch)
tree729dc91fa97f38042aa7777ca6267ebed2edb3e8 /libatomic/testsuite/libatomic.c/atomic-exchange-5.c
parentd8219307493056ea48203be157f0cfb468698f2d (diff)
downloadppe42-gcc-6db1d2ca83f9327020b75f6c1610649bb18e71db.tar.gz
ppe42-gcc-6db1d2ca83f9327020b75f6c1610649bb18e71db.zip
Add libatomic as a target library.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187018 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libatomic/testsuite/libatomic.c/atomic-exchange-5.c')
-rw-r--r--libatomic/testsuite/libatomic.c/atomic-exchange-5.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/libatomic/testsuite/libatomic.c/atomic-exchange-5.c b/libatomic/testsuite/libatomic.c/atomic-exchange-5.c
new file mode 100644
index 00000000000..b0c84b17fd3
--- /dev/null
+++ b/libatomic/testsuite/libatomic.c/atomic-exchange-5.c
@@ -0,0 +1,63 @@
+/* Test __atomic routines for existence and proper execution on 16 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+/* { dg-require-effective-target sync_int_128_runtime } */
+/* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */
+
+/* Test the execution of the __atomic_X builtin for a 16 byte value. */
+
+extern void abort(void);
+
+__int128_t v, count, ret;
+
+main ()
+{
+ v = 0;
+ count = 0;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) != count++)
+ abort ();
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) != count++)
+ abort ();
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) != count++)
+ abort ();
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) != count++)
+ abort ();
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) != count++)
+ abort ();
+
+ /* Now test the generic version. */
+
+ count++;
+
+ __atomic_exchange (&v, &count, &ret, __ATOMIC_RELAXED);
+ if (ret != count - 1 || v != count)
+ abort ();
+ count++;
+
+ __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQUIRE);
+ if (ret != count - 1 || v != count)
+ abort ();
+ count++;
+
+ __atomic_exchange (&v, &count, &ret, __ATOMIC_RELEASE);
+ if (ret != count - 1 || v != count)
+ abort ();
+ count++;
+
+ __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQ_REL);
+ if (ret != count - 1 || v != count)
+ abort ();
+ count++;
+
+ __atomic_exchange (&v, &count, &ret, __ATOMIC_SEQ_CST);
+ if (ret != count - 1 || v != count)
+ abort ();
+ count++;
+
+ return 0;
+}
OpenPOWER on IntegriCloud