summaryrefslogtreecommitdiffstats
path: root/libatomic/testsuite/libatomic.c/atomic-store-2.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-store-2.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-store-2.c')
-rw-r--r--libatomic/testsuite/libatomic.c/atomic-store-2.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/libatomic/testsuite/libatomic.c/atomic-store-2.c b/libatomic/testsuite/libatomic.c/atomic-store-2.c
new file mode 100644
index 00000000000..da346fd7de4
--- /dev/null
+++ b/libatomic/testsuite/libatomic.c/atomic-store-2.c
@@ -0,0 +1,46 @@
+/* Test __atomic routines for existence and proper execution on 2 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+/* { dg-require-effective-target sync_char_short } */
+
+/* Test the execution of the __atomic_store_n builtin for a short. */
+
+extern void abort(void);
+
+short v, count;
+
+main ()
+{
+ v = 0;
+ count = 0;
+
+ __atomic_store_n (&v, count + 1, __ATOMIC_RELAXED);
+ if (v != ++count)
+ abort ();
+
+ __atomic_store_n (&v, count + 1, __ATOMIC_RELEASE);
+ if (v != ++count)
+ abort ();
+
+ __atomic_store_n (&v, count + 1, __ATOMIC_SEQ_CST);
+ if (v != ++count)
+ abort ();
+
+ /* Now test the generic variant. */
+ count++;
+
+ __atomic_store (&v, &count, __ATOMIC_RELAXED);
+ if (v != count++)
+ abort ();
+
+ __atomic_store (&v, &count, __ATOMIC_RELEASE);
+ if (v != count++)
+ abort ();
+
+ __atomic_store (&v, &count, __ATOMIC_SEQ_CST);
+ if (v != count)
+ abort ();
+
+ return 0;
+}
+
OpenPOWER on IntegriCloud