[cfe-commits] [libcxx] r115207 - in /libcxx/trunk: include/ test/atomics/atomics.flag/
Howard Hinnant
hhinnant at apple.com
Thu Sep 30 14:05:29 PDT 2010
Author: hhinnant
Date: Thu Sep 30 16:05:29 2010
New Revision: 115207
URL: http://llvm.org/viewvc/llvm-project?rev=115207&view=rev
Log:
[atomics.flag] completed. Initialization is not working on clang and can't be made to work without defaulted default constructors.
Added:
libcxx/trunk/test/atomics/atomics.flag/atomic_flag_clear.pass.cpp
libcxx/trunk/test/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
libcxx/trunk/test/atomics/atomics.flag/atomic_flag_test_and_set.pass.cpp
libcxx/trunk/test/atomics/atomics.flag/atomic_flag_test_and_set_explicit.pass.cpp
libcxx/trunk/test/atomics/atomics.flag/clear.pass.cpp
libcxx/trunk/test/atomics/atomics.flag/copy_assign.fail.cpp
libcxx/trunk/test/atomics/atomics.flag/copy_ctor.fail.cpp
libcxx/trunk/test/atomics/atomics.flag/copy_volatile_assign.fail.cpp
libcxx/trunk/test/atomics/atomics.flag/default.pass.cpp
libcxx/trunk/test/atomics/atomics.flag/init.pass.cpp
Modified:
libcxx/trunk/include/atomic
libcxx/trunk/test/atomics/atomics.flag/test_and_set.pass.cpp
Modified: libcxx/trunk/include/atomic
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/atomic?rev=115207&r1=115206&r2=115207&view=diff
==============================================================================
--- libcxx/trunk/include/atomic (original)
+++ libcxx/trunk/include/atomic Thu Sep 30 16:05:29 2010
@@ -2556,7 +2556,7 @@
atomic_flag() = default;
#else
_LIBCPP_INLINE_VISIBILITY
- atomic_flag() : __flg_(false) {};
+ atomic_flag() {};
#endif
#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
Added: libcxx/trunk/test/atomics/atomics.flag/atomic_flag_clear.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/atomics/atomics.flag/atomic_flag_clear.pass.cpp?rev=115207&view=auto
==============================================================================
--- libcxx/trunk/test/atomics/atomics.flag/atomic_flag_clear.pass.cpp (added)
+++ libcxx/trunk/test/atomics/atomics.flag/atomic_flag_clear.pass.cpp Thu Sep 30 16:05:29 2010
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// void atomic_flag_clear(volatile atomic_flag*);
+// void atomic_flag_clear(atomic_flag*);
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ {
+ std::atomic_flag f;
+ f.test_and_set();
+ atomic_flag_clear(&f);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.test_and_set();
+ atomic_flag_clear(&f);
+ assert(f.test_and_set() == 0);
+ }
+}
Added: libcxx/trunk/test/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp?rev=115207&view=auto
==============================================================================
--- libcxx/trunk/test/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp (added)
+++ libcxx/trunk/test/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp Thu Sep 30 16:05:29 2010
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// void atomic_flag_clear_explicit(volatile atomic_flag*, memory_order);
+// void atomic_flag_clear_explicit(atomic_flag*, memory_order);
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ {
+ std::atomic_flag f;
+ f.test_and_set();
+ atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ std::atomic_flag f;
+ f.test_and_set();
+ atomic_flag_clear_explicit(&f, std::memory_order_consume);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ std::atomic_flag f;
+ f.test_and_set();
+ atomic_flag_clear_explicit(&f, std::memory_order_release);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ std::atomic_flag f;
+ f.test_and_set();
+ atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.test_and_set();
+ atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.test_and_set();
+ atomic_flag_clear_explicit(&f, std::memory_order_consume);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.test_and_set();
+ atomic_flag_clear_explicit(&f, std::memory_order_release);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.test_and_set();
+ atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
+ assert(f.test_and_set() == 0);
+ }
+}
Added: libcxx/trunk/test/atomics/atomics.flag/atomic_flag_test_and_set.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/atomics/atomics.flag/atomic_flag_test_and_set.pass.cpp?rev=115207&view=auto
==============================================================================
--- libcxx/trunk/test/atomics/atomics.flag/atomic_flag_test_and_set.pass.cpp (added)
+++ libcxx/trunk/test/atomics/atomics.flag/atomic_flag_test_and_set.pass.cpp Thu Sep 30 16:05:29 2010
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// bool atomic_flag_test_and_set(volatile atomic_flag*);
+// bool atomic_flag_test_and_set(atomic_flag*);
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set(&f) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set(&f) == 0);
+ assert(f.test_and_set() == 1);
+ }
+}
Added: libcxx/trunk/test/atomics/atomics.flag/atomic_flag_test_and_set_explicit.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/atomics/atomics.flag/atomic_flag_test_and_set_explicit.pass.cpp?rev=115207&view=auto
==============================================================================
--- libcxx/trunk/test/atomics/atomics.flag/atomic_flag_test_and_set_explicit.pass.cpp (added)
+++ libcxx/trunk/test/atomics/atomics.flag/atomic_flag_test_and_set_explicit.pass.cpp Thu Sep 30 16:05:29 2010
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// bool atomic_flag_test_and_set_explicit(volatile atomic_flag*, memory_order);
+// bool atomic_flag_test_and_set_explicit(atomic_flag*, memory_order);
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_relaxed) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_consume) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_acquire) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_release) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_acq_rel) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_seq_cst) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_relaxed) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_consume) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_acquire) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_release) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_acq_rel) == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_seq_cst) == 0);
+ assert(f.test_and_set() == 1);
+ }
+}
Added: libcxx/trunk/test/atomics/atomics.flag/clear.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/atomics/atomics.flag/clear.pass.cpp?rev=115207&view=auto
==============================================================================
--- libcxx/trunk/test/atomics/atomics.flag/clear.pass.cpp (added)
+++ libcxx/trunk/test/atomics/atomics.flag/clear.pass.cpp Thu Sep 30 16:05:29 2010
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// void clear(memory_order = memory_order_seq_cst);
+// void clear(memory_order = memory_order_seq_cst) volatile;
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ {
+ std::atomic_flag f;
+ f.test_and_set();
+ f.clear();
+ assert(f.test_and_set() == 0);
+ }
+ {
+ std::atomic_flag f;
+ f.test_and_set();
+ f.clear(std::memory_order_relaxed);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ std::atomic_flag f;
+ f.test_and_set();
+ f.clear(std::memory_order_consume);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ std::atomic_flag f;
+ f.test_and_set();
+ f.clear(std::memory_order_release);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ std::atomic_flag f;
+ f.test_and_set();
+ f.clear(std::memory_order_seq_cst);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.test_and_set();
+ f.clear();
+ assert(f.test_and_set() == 0);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.test_and_set();
+ f.clear(std::memory_order_relaxed);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.test_and_set();
+ f.clear(std::memory_order_consume);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.test_and_set();
+ f.clear(std::memory_order_release);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.test_and_set();
+ f.clear(std::memory_order_seq_cst);
+ assert(f.test_and_set() == 0);
+ }
+}
Added: libcxx/trunk/test/atomics/atomics.flag/copy_assign.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/atomics/atomics.flag/copy_assign.fail.cpp?rev=115207&view=auto
==============================================================================
--- libcxx/trunk/test/atomics/atomics.flag/copy_assign.fail.cpp (added)
+++ libcxx/trunk/test/atomics/atomics.flag/copy_assign.fail.cpp Thu Sep 30 16:05:29 2010
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// atomic_flag& operator=(const atomic_flag&) = delete;
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ std::atomic_flag f0;
+ std::atomic_flag f;
+ f = f0;
+}
Added: libcxx/trunk/test/atomics/atomics.flag/copy_ctor.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/atomics/atomics.flag/copy_ctor.fail.cpp?rev=115207&view=auto
==============================================================================
--- libcxx/trunk/test/atomics/atomics.flag/copy_ctor.fail.cpp (added)
+++ libcxx/trunk/test/atomics/atomics.flag/copy_ctor.fail.cpp Thu Sep 30 16:05:29 2010
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// atomic_flag(const atomic_flag&) = delete;
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ std::atomic_flag f0;
+ std::atomic_flag f(f0);
+}
Added: libcxx/trunk/test/atomics/atomics.flag/copy_volatile_assign.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/atomics/atomics.flag/copy_volatile_assign.fail.cpp?rev=115207&view=auto
==============================================================================
--- libcxx/trunk/test/atomics/atomics.flag/copy_volatile_assign.fail.cpp (added)
+++ libcxx/trunk/test/atomics/atomics.flag/copy_volatile_assign.fail.cpp Thu Sep 30 16:05:29 2010
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// atomic_flag& operator=(const atomic_flag&) = delete;
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ std::atomic_flag f0;
+ volatile std::atomic_flag f;
+ f = f0;
+}
Added: libcxx/trunk/test/atomics/atomics.flag/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/atomics/atomics.flag/default.pass.cpp?rev=115207&view=auto
==============================================================================
--- libcxx/trunk/test/atomics/atomics.flag/default.pass.cpp (added)
+++ libcxx/trunk/test/atomics/atomics.flag/default.pass.cpp Thu Sep 30 16:05:29 2010
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// atomic_flag() = default;
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ std::atomic_flag f;
+}
Added: libcxx/trunk/test/atomics/atomics.flag/init.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/atomics/atomics.flag/init.pass.cpp?rev=115207&view=auto
==============================================================================
--- libcxx/trunk/test/atomics/atomics.flag/init.pass.cpp (added)
+++ libcxx/trunk/test/atomics/atomics.flag/init.pass.cpp Thu Sep 30 16:05:29 2010
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// atomic_flag() = ATOMIC_FLAG_INIT;
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ std::atomic_flag f = ATOMIC_FLAG_INIT;
+ assert(f.test_and_set() == 0);
+}
Modified: libcxx/trunk/test/atomics/atomics.flag/test_and_set.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/atomics/atomics.flag/test_and_set.pass.cpp?rev=115207&r1=115206&r2=115207&view=diff
==============================================================================
--- libcxx/trunk/test/atomics/atomics.flag/test_and_set.pass.cpp (original)
+++ libcxx/trunk/test/atomics/atomics.flag/test_and_set.pass.cpp Thu Sep 30 16:05:29 2010
@@ -19,7 +19,88 @@
int main()
{
- std::atomic_flag f;
- assert(f.test_and_set() == 0);
- assert(f.test_and_set() == 1);
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set() == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_relaxed) == 0);
+ assert(f.test_and_set(std::memory_order_relaxed) == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_consume) == 0);
+ assert(f.test_and_set(std::memory_order_consume) == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_acquire) == 0);
+ assert(f.test_and_set(std::memory_order_acquire) == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_release) == 0);
+ assert(f.test_and_set(std::memory_order_release) == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_acq_rel) == 0);
+ assert(f.test_and_set(std::memory_order_acq_rel) == 1);
+ }
+ {
+ std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_seq_cst) == 0);
+ assert(f.test_and_set(std::memory_order_seq_cst) == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set() == 0);
+ assert(f.test_and_set() == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_relaxed) == 0);
+ assert(f.test_and_set(std::memory_order_relaxed) == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_consume) == 0);
+ assert(f.test_and_set(std::memory_order_consume) == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_acquire) == 0);
+ assert(f.test_and_set(std::memory_order_acquire) == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_release) == 0);
+ assert(f.test_and_set(std::memory_order_release) == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_acq_rel) == 0);
+ assert(f.test_and_set(std::memory_order_acq_rel) == 1);
+ }
+ {
+ volatile std::atomic_flag f;
+ f.clear();
+ assert(f.test_and_set(std::memory_order_seq_cst) == 0);
+ assert(f.test_and_set(std::memory_order_seq_cst) == 1);
+ }
}
More information about the cfe-commits
mailing list