From cfe0b0a1aba47ec45446d4e5392e0ceecc8b5701 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Tue, 28 Sep 2010 17:13:38 +0000 Subject: [PATCH] [atomics.order] llvm-svn: 114966 --- libcxx/include/atomic | 21 +++++++++++-- .../atomics.general/nothing_to_do.pass.cpp | 13 ++++++++ .../atomics.order/kill_dependency.pass.cpp | 21 +++++++++++++ .../atomics.order/memory_order.pass.cpp | 31 +++++++++++++++++++ .../atomics.syn/nothing_to_do.pass.cpp | 13 ++++++++ 5 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 libcxx/test/atomics/atomics.general/nothing_to_do.pass.cpp create mode 100644 libcxx/test/atomics/atomics.order/kill_dependency.pass.cpp create mode 100644 libcxx/test/atomics/atomics.order/memory_order.pass.cpp create mode 100644 libcxx/test/atomics/atomics.syn/nothing_to_do.pass.cpp diff --git a/libcxx/include/atomic b/libcxx/include/atomic index b36aee2328cc..97089776abf4 100644 --- a/libcxx/include/atomic +++ b/libcxx/include/atomic @@ -21,8 +21,12 @@ namespace std typedef enum memory_order { - memory_order_relaxed, memory_order_consume, memory_order_acquire, - memory_order_release, memory_order_acq_rel, memory_order_seq_cst + memory_order_relaxed, + memory_order_consume, // load-consume + memory_order_acquire, // load-acquire + memory_order_release, // store-release + memory_order_acq_rel, // store-release load-acquire + memory_order_seq_cst // store-release load-acquire } memory_order; template T kill_dependency(T y); @@ -2412,6 +2416,19 @@ void atomic_signal_fence(memory_order); _LIBCPP_BEGIN_NAMESPACE_STD +typedef enum memory_order +{ + memory_order_relaxed, memory_order_consume, memory_order_acquire, + memory_order_release, memory_order_acq_rel, memory_order_seq_cst +} memory_order; + +template +inline _LIBCPP_INLINE_VISIBILITY +_Tp +kill_dependency(_Tp __y) +{ + return __y; +} _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/test/atomics/atomics.general/nothing_to_do.pass.cpp b/libcxx/test/atomics/atomics.general/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..b85601fc46fd --- /dev/null +++ b/libcxx/test/atomics/atomics.general/nothing_to_do.pass.cpp @@ -0,0 +1,13 @@ +// -*- C++ -*- +//===-------------------------- algorithm ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/atomics/atomics.order/kill_dependency.pass.cpp b/libcxx/test/atomics/atomics.order/kill_dependency.pass.cpp new file mode 100644 index 000000000000..f51b0f544610 --- /dev/null +++ b/libcxx/test/atomics/atomics.order/kill_dependency.pass.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template T kill_dependency(T y); + +#include +#include + +int main() +{ + assert(std::kill_dependency(5) == 5); + assert(std::kill_dependency(-5.5) == -5.5); +} diff --git a/libcxx/test/atomics/atomics.order/memory_order.pass.cpp b/libcxx/test/atomics/atomics.order/memory_order.pass.cpp new file mode 100644 index 000000000000..9650d45bfa60 --- /dev/null +++ b/libcxx/test/atomics/atomics.order/memory_order.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// typedef enum memory_order +// { +// memory_order_relaxed, memory_order_consume, memory_order_acquire, +// memory_order_release, memory_order_acq_rel, memory_order_seq_cst +// } memory_order; + +#include +#include + +int main() +{ + assert(std::memory_order_relaxed == 0); + assert(std::memory_order_consume == 1); + assert(std::memory_order_acquire == 2); + assert(std::memory_order_release == 3); + assert(std::memory_order_acq_rel == 4); + assert(std::memory_order_seq_cst == 5); + std::memory_order o = std::memory_order_seq_cst; + assert(o == 5); +} diff --git a/libcxx/test/atomics/atomics.syn/nothing_to_do.pass.cpp b/libcxx/test/atomics/atomics.syn/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..b85601fc46fd --- /dev/null +++ b/libcxx/test/atomics/atomics.syn/nothing_to_do.pass.cpp @@ -0,0 +1,13 @@ +// -*- C++ -*- +//===-------------------------- algorithm ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +}