diff options
author | Andrew Macleod <amacleod@gcc.gnu.org> | 2011-11-06 14:55:48 +0000 |
---|---|---|
committer | Andrew Macleod <amacleod@gcc.gnu.org> | 2011-11-06 14:55:48 +0000 |
commit | 86951993f8a4cae2fb26bf8705e2f248a8d6f21e (patch) | |
tree | c0f499483e35c60c1b9f065f10a630e6fa4345bc /gcc/testsuite/gcc.dg/atomic-store-2.c | |
parent | a8a058f6523f1e0f7b69ec1837848e55cf9f0856 (diff) | |
download | gcc-86951993f8a4cae2fb26bf8705e2f248a8d6f21e.zip gcc-86951993f8a4cae2fb26bf8705e2f248a8d6f21e.tar.gz gcc-86951993f8a4cae2fb26bf8705e2f248a8d6f21e.tar.bz2 |
Check in patch/merge from cxx-mem-model Branch
From-SVN: r181031
Diffstat (limited to 'gcc/testsuite/gcc.dg/atomic-store-2.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/atomic-store-2.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/atomic-store-2.c b/gcc/testsuite/gcc.dg/atomic-store-2.c new file mode 100644 index 0000000..da346fd --- /dev/null +++ b/gcc/testsuite/gcc.dg/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; +} + |