[cfe-commits] [libcxx] r121202 - in /libcxx/trunk/test/atomics/atomics.types.generic: address.pass.cpp atomics.types.address/address.pass.cpp atomics.types.integral/bool.pass.cpp atomics.types.integral/integral.pass.cpp bool.pass.cpp integral.pass.cpp nothing_to_do.pass.cpp
Howard Hinnant
hhinnant at apple.com
Tue Dec 7 15:20:29 PST 2010
Author: hhinnant
Date: Tue Dec 7 17:20:28 2010
New Revision: 121202
URL: http://llvm.org/viewvc/llvm-project?rev=121202&view=rev
Log:
atomics ...
Added:
libcxx/trunk/test/atomics/atomics.types.generic/address.pass.cpp
- copied, changed from r120913, libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.address/address.pass.cpp
libcxx/trunk/test/atomics/atomics.types.generic/bool.pass.cpp
- copied, changed from r120913, libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.integral/bool.pass.cpp
libcxx/trunk/test/atomics/atomics.types.generic/integral.pass.cpp
- copied, changed from r120913, libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.integral/integral.pass.cpp
Removed:
libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.address/address.pass.cpp
libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.integral/bool.pass.cpp
libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.integral/integral.pass.cpp
libcxx/trunk/test/atomics/atomics.types.generic/nothing_to_do.pass.cpp
Copied: libcxx/trunk/test/atomics/atomics.types.generic/address.pass.cpp (from r120913, libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.address/address.pass.cpp)
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/atomics/atomics.types.generic/address.pass.cpp?p2=libcxx/trunk/test/atomics/atomics.types.generic/address.pass.cpp&p1=libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.address/address.pass.cpp&r1=120913&r2=121202&rev=121202&view=diff
==============================================================================
--- libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.address/address.pass.cpp (original)
+++ libcxx/trunk/test/atomics/atomics.types.generic/address.pass.cpp Tue Dec 7 17:20:28 2010
@@ -9,103 +9,61 @@
// <atomic>
-// typedef struct atomic_address
+// template <class T>
+// struct atomic<T*>
// {
// bool is_lock_free() const volatile;
// bool is_lock_free() const;
-// void store(void*, memory_order = memory_order_seq_cst) volatile;
-// void store(void*, memory_order = memory_order_seq_cst);
-// void* load(memory_order = memory_order_seq_cst) const volatile;
-// void* load(memory_order = memory_order_seq_cst) const;
-// operator void*() const volatile;
-// operator void*() const;
-// void* exchange(void*, memory_order = memory_order_seq_cst) volatile;
-// void* exchange(void*, memory_order = memory_order_seq_cst);
-// bool compare_exchange_weak(void*&, void*, memory_order,
-// memory_order) volatile;
-// bool compare_exchange_weak(void*&, void*, memory_order, memory_order);
-// bool compare_exchange_strong(void*&, void*, memory_order,
-// memory_order) volatile;
-// bool compare_exchange_strong(void*&, void*, memory_order, memory_order);
-// bool compare_exchange_weak(void*&, void*,
-// memory_order = memory_order_seq_cst) volatile;
-// bool compare_exchange_weak(void*&, void*,
-// memory_order = memory_order_seq_cst);
-// bool compare_exchange_strong(void*&, void*,
-// memory_order = memory_order_seq_cst) volatile;
-// bool compare_exchange_strong(void*&, void*,
-// memory_order = memory_order_seq_cst);
-// bool compare_exchange_weak(const void*&, const void*,
-// memory_order, memory_order) volatile;
-// bool compare_exchange_weak(const void*&, const void*, memory_order,
-// memory_order);
-// bool compare_exchange_strong(const void*&, const void*, memory_order,
-// memory_order) volatile;
-// bool compare_exchange_strong(const void*&, const void*, memory_order,
-// memory_order);
-// bool compare_exchange_weak(const void*&, const void*,
-// memory_order = memory_order_seq_cst) volatile;
-// bool compare_exchange_weak(const void*&, const void*,
-// memory_order = memory_order_seq_cst);
-// bool compare_exchange_strong(const void*&, const void*,
-// memory_order = memory_order_seq_cst) volatile;
-// bool compare_exchange_strong(const void*&, const void*,
-// memory_order = memory_order_seq_cst);
-// void* fetch_add(ptrdiff_t, memory_order = memory_order_seq_cst) volatile;
-// void* fetch_add(ptrdiff_t, memory_order = memory_order_seq_cst);
-// void* fetch_sub(ptrdiff_t, memory_order = memory_order_seq_cst) volatile;
-// void* fetch_sub(ptrdiff_t, memory_order = memory_order_seq_cst);
-// atomic_address() = default;
-// constexpr atomic_address(void*);
-// atomic_address(const atomic_address&) = delete;
-// atomic_address& operator=(const atomic_address&) = delete;
-// atomic_address& operator=(const atomic_address&) volatile = delete;
-// void* operator=(const void*) volatile;
-// void* operator=(const void*);
-// void* operator+=(ptrdiff_t) volatile;
-// void* operator+=(ptrdiff_t);
-// void* operator-=(ptrdiff_t) volatile;
-// void* operator-=(ptrdiff_t);
-// } atomic_address;
+// void store(T* desr, memory_order m = memory_order_seq_cst) volatile;
+// void store(T* desr, memory_order m = memory_order_seq_cst);
+// T* load(memory_order m = memory_order_seq_cst) const volatile;
+// T* load(memory_order m = memory_order_seq_cst) const;
+// operator T*() const volatile;
+// operator T*() const;
+// T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile;
+// T* exchange(T* desr, memory_order m = memory_order_seq_cst);
+// bool compare_exchange_weak(T*& expc, T* desr,
+// memory_order s, memory_order f) volatile;
+// bool compare_exchange_weak(T*& expc, T* desr,
+// memory_order s, memory_order f);
+// bool compare_exchange_strong(T*& expc, T* desr,
+// memory_order s, memory_order f) volatile;
+// bool compare_exchange_strong(T*& expc, T* desr,
+// memory_order s, memory_order f);
+// bool compare_exchange_weak(T*& expc, T* desr,
+// memory_order m = memory_order_seq_cst) volatile;
+// bool compare_exchange_weak(T*& expc, T* desr,
+// memory_order m = memory_order_seq_cst);
+// bool compare_exchange_strong(T*& expc, T* desr,
+// memory_order m = memory_order_seq_cst) volatile;
+// bool compare_exchange_strong(T*& expc, T* desr,
+// memory_order m = memory_order_seq_cst);
+// T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile;
+// T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst);
+// T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile;
+// T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst);
//
-// bool atomic_is_lock_free(const volatile atomic_address*);
-// bool atomic_is_lock_free(const atomic_address*);
-// void atomic_init(volatile atomic_address*, void*);
-// void atomic_init(atomic_address*, void*);
-// void atomic_store(volatile atomic_address*, void*);
-// void atomic_store(atomic_address*, void*);
-// void atomic_store_explicit(volatile atomic_address*, void*, memory_order);
-// void atomic_store_explicit(atomic_address*, void*, memory_order);
-// void* atomic_load(const volatile atomic_address*);
-// void* atomic_load(const atomic_address*);
-// void* atomic_load_explicit(const volatile atomic_address*, memory_order);
-// void* atomic_load_explicit(const atomic_address*, memory_order);
-// void* atomic_exchange(volatile atomic_address*, void*);
-// void* atomic_exchange(atomic_address*, void*);
-// void* atomic_exchange_explicit(volatile atomic_address*, void*, memory_order);
-// void* atomic_exchange_explicit(atomic_address*, void*, memory_order);
-// bool atomic_compare_exchange_weak(volatile atomic_address*, void**, void*);
-// bool atomic_compare_exchange_weak(atomic_address*, void**, void*);
-// bool atomic_compare_exchange_strong(volatile atomic_address*, void**, void*);
-// bool atomic_compare_exchange_strong(atomic_address*, void**, void*);
-// bool atomic_compare_exchange_weak_explicit(volatile atomic_address*, void**,
-// void*, memory_order, memory_order);
-// bool atomic_compare_exchange_weak_explicit(atomic_address*, void**, void*,
-// memory_order, memory_order);
-// bool atomic_compare_exchange_strong_explicit(volatile atomic_address*, void**,
-// void*, memory_order, memory_order);
-// bool atomic_compare_exchange_strong_explicit(atomic_address*, void**, void*,
-// memory_order, memory_order);
-// void* atomic_fetch_add(volatile atomic_address*, ptrdiff_t);
-// void* atomic_fetch_add(atomic_address*, ptrdiff_t);
-// void* atomic_fetch_add_explicit(volatile atomic_address*, ptrdiff_t,
-// memory_order);
-// void* atomic_fetch_add_explicit(atomic_address*, ptrdiff_t, memory_order);
-// void* atomic_fetch_sub(volatile atomic_address*, ptrdiff_t);
-// void* atomic_fetch_sub(atomic_address*, ptrdiff_t);
-// void* atomic_fetch_sub_explicit(volatile atomic_address*, ptrdiff_t,
-// memory_order);
-// void* atomic_fetch_sub_explicit(atomic_address*, ptrdiff_t, memory_order);
+// atomic() = default;
+// constexpr atomic(T* desr);
+// atomic(const atomic&) = delete;
+// atomic& operator=(const atomic&) = delete;
+// atomic& operator=(const atomic&) volatile = delete;
+//
+// T* operator=(T*) volatile;
+// T* operator=(T*);
+// T* operator++(int) volatile;
+// T* operator++(int);
+// T* operator--(int) volatile;
+// T* operator--(int);
+// T* operator++() volatile;
+// T* operator++();
+// T* operator--() volatile;
+// T* operator--();
+// T* operator+=(ptrdiff_t op) volatile;
+// T* operator+=(ptrdiff_t op);
+// T* operator-=(ptrdiff_t op) volatile;
+// T* operator-=(ptrdiff_t op);
+// };
#include <atomic>
#include <cassert>
@@ -114,6 +72,7 @@
void
do_test()
{
+ typedef typename std::remove_pointer<T>::type X;
A obj(T(0));
assert(obj == T(0));
std::atomic_init(&obj, T(1));
@@ -137,74 +96,21 @@
assert(x == T(3));
assert(obj.compare_exchange_weak(x, T(1)) == false);
assert(obj == T(2));
- assert(x == T(2));
+ assert(x == T(1));
+ x = T(2);
assert(obj.compare_exchange_strong(x, T(1)) == true);
assert(obj == T(1));
assert(x == T(2));
assert(obj.compare_exchange_strong(x, T(0)) == false);
assert(obj == T(1));
- assert(x == T(1));
+ assert(x == T(0));
assert((obj = T(0)) == T(0));
assert(obj == T(0));
- obj = T(2);
- assert((obj += std::ptrdiff_t(3)) == T(5));
- assert(obj == T(5));
- assert((obj -= std::ptrdiff_t(3)) == T(2));
- assert(obj == T(2));
-
- std::atomic_init(&obj, T(1));
- assert(obj == T(1));
- bool b1 = std::atomic_is_lock_free(&obj);
- std::atomic_store(&obj, T(0));
- assert(obj == T(0));
- std::atomic_store_explicit(&obj, T(1), std::memory_order_release);
- assert(obj == T(1));
- assert(std::atomic_load(&obj) == T(1));
- assert(std::atomic_load_explicit(&obj, std::memory_order_acquire) == T(1));
- assert(std::atomic_exchange(&obj, T(2)) == T(1));
- assert(obj == T(2));
- assert(std::atomic_exchange_explicit(&obj, T(3), std::memory_order_relaxed) == T(2));
- assert(obj == T(3));
- x = obj;
- assert(std::atomic_compare_exchange_weak(&obj, &x, T(2)) == true);
- assert(obj == T(2));
- assert(x == T(3));
- assert(std::atomic_compare_exchange_weak(&obj, &x, T(1)) == false);
- assert(obj == T(2));
- assert(x == T(2));
- assert(std::atomic_compare_exchange_strong(&obj, &x, T(1)) == true);
- assert(obj == T(1));
- assert(x == T(2));
- assert(std::atomic_compare_exchange_strong(&obj, &x, T(0)) == false);
- assert(obj == T(1));
- assert(x == T(1));
- assert(std::atomic_compare_exchange_weak_explicit(&obj, &x, T(2),
- std::memory_order_relaxed, std::memory_order_relaxed) == true);
- assert(obj == T(2));
- assert(x == T(1));
- assert(std::atomic_compare_exchange_weak_explicit(&obj, &x, T(3),
- std::memory_order_relaxed, std::memory_order_relaxed) == false);
- assert(obj == T(2));
- assert(x == T(2));
- assert(std::atomic_compare_exchange_strong_explicit(&obj, &x, T(3),
- std::memory_order_relaxed, std::memory_order_relaxed) == true);
- assert(obj == T(3));
- assert(x == T(2));
- assert(std::atomic_compare_exchange_strong_explicit(&obj, &x, T(0),
- std::memory_order_relaxed, std::memory_order_relaxed) == false);
- assert(obj == T(3));
- assert(x == T(3));
- assert((obj = T(1)) == T(1));
- assert(obj == T(1));
- obj = T(2);
- assert(std::atomic_fetch_add(&obj, std::ptrdiff_t(3)) == T(2));
- assert(obj == T(5));
- assert(std::atomic_fetch_add_explicit(&obj, std::ptrdiff_t(3), std::memory_order_seq_cst) == T(5));
- assert(obj == T(8));
- assert(std::atomic_fetch_sub(&obj, std::ptrdiff_t(3)) == T(8));
- assert(obj == T(5));
- assert(std::atomic_fetch_sub_explicit(&obj, std::ptrdiff_t(3), std::memory_order_seq_cst) == T(5));
- assert(obj == T(2));
+ obj = T(2*sizeof(X));
+ assert((obj += std::ptrdiff_t(3)) == T(5*sizeof(X)));
+ assert(obj == T(5*sizeof(X)));
+ assert((obj -= std::ptrdiff_t(3)) == T(2*sizeof(X)));
+ assert(obj == T(2*sizeof(X)));
}
template <class A, class T>
@@ -216,5 +122,5 @@
int main()
{
- test<std::atomic_address, void*>();
+ test<std::atomic<int*>, int*>();
}
Removed: libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.address/address.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.address/address.pass.cpp?rev=121201&view=auto
==============================================================================
--- libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.address/address.pass.cpp (original)
+++ libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.address/address.pass.cpp (removed)
@@ -1,220 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <atomic>
-
-// typedef struct atomic_address
-// {
-// bool is_lock_free() const volatile;
-// bool is_lock_free() const;
-// void store(void*, memory_order = memory_order_seq_cst) volatile;
-// void store(void*, memory_order = memory_order_seq_cst);
-// void* load(memory_order = memory_order_seq_cst) const volatile;
-// void* load(memory_order = memory_order_seq_cst) const;
-// operator void*() const volatile;
-// operator void*() const;
-// void* exchange(void*, memory_order = memory_order_seq_cst) volatile;
-// void* exchange(void*, memory_order = memory_order_seq_cst);
-// bool compare_exchange_weak(void*&, void*, memory_order,
-// memory_order) volatile;
-// bool compare_exchange_weak(void*&, void*, memory_order, memory_order);
-// bool compare_exchange_strong(void*&, void*, memory_order,
-// memory_order) volatile;
-// bool compare_exchange_strong(void*&, void*, memory_order, memory_order);
-// bool compare_exchange_weak(void*&, void*,
-// memory_order = memory_order_seq_cst) volatile;
-// bool compare_exchange_weak(void*&, void*,
-// memory_order = memory_order_seq_cst);
-// bool compare_exchange_strong(void*&, void*,
-// memory_order = memory_order_seq_cst) volatile;
-// bool compare_exchange_strong(void*&, void*,
-// memory_order = memory_order_seq_cst);
-// bool compare_exchange_weak(const void*&, const void*,
-// memory_order, memory_order) volatile;
-// bool compare_exchange_weak(const void*&, const void*, memory_order,
-// memory_order);
-// bool compare_exchange_strong(const void*&, const void*, memory_order,
-// memory_order) volatile;
-// bool compare_exchange_strong(const void*&, const void*, memory_order,
-// memory_order);
-// bool compare_exchange_weak(const void*&, const void*,
-// memory_order = memory_order_seq_cst) volatile;
-// bool compare_exchange_weak(const void*&, const void*,
-// memory_order = memory_order_seq_cst);
-// bool compare_exchange_strong(const void*&, const void*,
-// memory_order = memory_order_seq_cst) volatile;
-// bool compare_exchange_strong(const void*&, const void*,
-// memory_order = memory_order_seq_cst);
-// void* fetch_add(ptrdiff_t, memory_order = memory_order_seq_cst) volatile;
-// void* fetch_add(ptrdiff_t, memory_order = memory_order_seq_cst);
-// void* fetch_sub(ptrdiff_t, memory_order = memory_order_seq_cst) volatile;
-// void* fetch_sub(ptrdiff_t, memory_order = memory_order_seq_cst);
-// atomic_address() = default;
-// constexpr atomic_address(void*);
-// atomic_address(const atomic_address&) = delete;
-// atomic_address& operator=(const atomic_address&) = delete;
-// atomic_address& operator=(const atomic_address&) volatile = delete;
-// void* operator=(const void*) volatile;
-// void* operator=(const void*);
-// void* operator+=(ptrdiff_t) volatile;
-// void* operator+=(ptrdiff_t);
-// void* operator-=(ptrdiff_t) volatile;
-// void* operator-=(ptrdiff_t);
-// } atomic_address;
-//
-// bool atomic_is_lock_free(const volatile atomic_address*);
-// bool atomic_is_lock_free(const atomic_address*);
-// void atomic_init(volatile atomic_address*, void*);
-// void atomic_init(atomic_address*, void*);
-// void atomic_store(volatile atomic_address*, void*);
-// void atomic_store(atomic_address*, void*);
-// void atomic_store_explicit(volatile atomic_address*, void*, memory_order);
-// void atomic_store_explicit(atomic_address*, void*, memory_order);
-// void* atomic_load(const volatile atomic_address*);
-// void* atomic_load(const atomic_address*);
-// void* atomic_load_explicit(const volatile atomic_address*, memory_order);
-// void* atomic_load_explicit(const atomic_address*, memory_order);
-// void* atomic_exchange(volatile atomic_address*, void*);
-// void* atomic_exchange(atomic_address*, void*);
-// void* atomic_exchange_explicit(volatile atomic_address*, void*, memory_order);
-// void* atomic_exchange_explicit(atomic_address*, void*, memory_order);
-// bool atomic_compare_exchange_weak(volatile atomic_address*, void**, void*);
-// bool atomic_compare_exchange_weak(atomic_address*, void**, void*);
-// bool atomic_compare_exchange_strong(volatile atomic_address*, void**, void*);
-// bool atomic_compare_exchange_strong(atomic_address*, void**, void*);
-// bool atomic_compare_exchange_weak_explicit(volatile atomic_address*, void**,
-// void*, memory_order, memory_order);
-// bool atomic_compare_exchange_weak_explicit(atomic_address*, void**, void*,
-// memory_order, memory_order);
-// bool atomic_compare_exchange_strong_explicit(volatile atomic_address*, void**,
-// void*, memory_order, memory_order);
-// bool atomic_compare_exchange_strong_explicit(atomic_address*, void**, void*,
-// memory_order, memory_order);
-// void* atomic_fetch_add(volatile atomic_address*, ptrdiff_t);
-// void* atomic_fetch_add(atomic_address*, ptrdiff_t);
-// void* atomic_fetch_add_explicit(volatile atomic_address*, ptrdiff_t,
-// memory_order);
-// void* atomic_fetch_add_explicit(atomic_address*, ptrdiff_t, memory_order);
-// void* atomic_fetch_sub(volatile atomic_address*, ptrdiff_t);
-// void* atomic_fetch_sub(atomic_address*, ptrdiff_t);
-// void* atomic_fetch_sub_explicit(volatile atomic_address*, ptrdiff_t,
-// memory_order);
-// void* atomic_fetch_sub_explicit(atomic_address*, ptrdiff_t, memory_order);
-
-#include <atomic>
-#include <cassert>
-
-template <class A, class T>
-void
-do_test()
-{
- A obj(T(0));
- assert(obj == T(0));
- std::atomic_init(&obj, T(1));
- assert(obj == T(1));
- std::atomic_init(&obj, T(2));
- assert(obj == T(2));
- bool b0 = obj.is_lock_free();
- obj.store(T(0));
- assert(obj == T(0));
- obj.store(T(1), std::memory_order_release);
- assert(obj == T(1));
- assert(obj.load() == T(1));
- assert(obj.load(std::memory_order_acquire) == T(1));
- assert(obj.exchange(T(2)) == T(1));
- assert(obj == T(2));
- assert(obj.exchange(T(3), std::memory_order_relaxed) == T(2));
- assert(obj == T(3));
- T x = obj;
- assert(obj.compare_exchange_weak(x, T(2)) == true);
- assert(obj == T(2));
- assert(x == T(3));
- assert(obj.compare_exchange_weak(x, T(1)) == false);
- assert(obj == T(2));
- assert(x == T(2));
- assert(obj.compare_exchange_strong(x, T(1)) == true);
- assert(obj == T(1));
- assert(x == T(2));
- assert(obj.compare_exchange_strong(x, T(0)) == false);
- assert(obj == T(1));
- assert(x == T(1));
- assert((obj = T(0)) == T(0));
- assert(obj == T(0));
- obj = T(2);
- assert((obj += std::ptrdiff_t(3)) == T(5));
- assert(obj == T(5));
- assert((obj -= std::ptrdiff_t(3)) == T(2));
- assert(obj == T(2));
-
- std::atomic_init(&obj, T(1));
- assert(obj == T(1));
- bool b1 = std::atomic_is_lock_free(&obj);
- std::atomic_store(&obj, T(0));
- assert(obj == T(0));
- std::atomic_store_explicit(&obj, T(1), std::memory_order_release);
- assert(obj == T(1));
- assert(std::atomic_load(&obj) == T(1));
- assert(std::atomic_load_explicit(&obj, std::memory_order_acquire) == T(1));
- assert(std::atomic_exchange(&obj, T(2)) == T(1));
- assert(obj == T(2));
- assert(std::atomic_exchange_explicit(&obj, T(3), std::memory_order_relaxed) == T(2));
- assert(obj == T(3));
- x = obj;
- assert(std::atomic_compare_exchange_weak(&obj, &x, T(2)) == true);
- assert(obj == T(2));
- assert(x == T(3));
- assert(std::atomic_compare_exchange_weak(&obj, &x, T(1)) == false);
- assert(obj == T(2));
- assert(x == T(2));
- assert(std::atomic_compare_exchange_strong(&obj, &x, T(1)) == true);
- assert(obj == T(1));
- assert(x == T(2));
- assert(std::atomic_compare_exchange_strong(&obj, &x, T(0)) == false);
- assert(obj == T(1));
- assert(x == T(1));
- assert(std::atomic_compare_exchange_weak_explicit(&obj, &x, T(2),
- std::memory_order_relaxed, std::memory_order_relaxed) == true);
- assert(obj == T(2));
- assert(x == T(1));
- assert(std::atomic_compare_exchange_weak_explicit(&obj, &x, T(3),
- std::memory_order_relaxed, std::memory_order_relaxed) == false);
- assert(obj == T(2));
- assert(x == T(2));
- assert(std::atomic_compare_exchange_strong_explicit(&obj, &x, T(3),
- std::memory_order_relaxed, std::memory_order_relaxed) == true);
- assert(obj == T(3));
- assert(x == T(2));
- assert(std::atomic_compare_exchange_strong_explicit(&obj, &x, T(0),
- std::memory_order_relaxed, std::memory_order_relaxed) == false);
- assert(obj == T(3));
- assert(x == T(3));
- assert((obj = T(1)) == T(1));
- assert(obj == T(1));
- obj = T(2);
- assert(std::atomic_fetch_add(&obj, std::ptrdiff_t(3)) == T(2));
- assert(obj == T(5));
- assert(std::atomic_fetch_add_explicit(&obj, std::ptrdiff_t(3), std::memory_order_seq_cst) == T(5));
- assert(obj == T(8));
- assert(std::atomic_fetch_sub(&obj, std::ptrdiff_t(3)) == T(8));
- assert(obj == T(5));
- assert(std::atomic_fetch_sub_explicit(&obj, std::ptrdiff_t(3), std::memory_order_seq_cst) == T(5));
- assert(obj == T(2));
-}
-
-template <class A, class T>
-void test()
-{
- do_test<A, T>();
- do_test<volatile A, T>();
-}
-
-int main()
-{
- test<std::atomic_address, void*>();
-}
Removed: libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.integral/bool.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.integral/bool.pass.cpp?rev=121201&view=auto
==============================================================================
--- libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.integral/bool.pass.cpp (original)
+++ libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.integral/bool.pass.cpp (removed)
@@ -1,239 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <atomic>
-
-// typedef struct atomic_bool
-// {
-// bool is_lock_free() const volatile;
-// bool is_lock_free() const;
-// void store(bool, memory_order = memory_order_seq_cst) volatile;
-// void store(bool, memory_order = memory_order_seq_cst);
-// bool load(memory_order = memory_order_seq_cst) const volatile;
-// bool load(memory_order = memory_order_seq_cst) const;
-// operator bool() const volatile;
-// operator bool() const;
-// bool exchange(bool, memory_order = memory_order_seq_cst) volatile;
-// bool exchange(bool, memory_order = memory_order_seq_cst);
-// bool compare_exchange_weak(bool&, bool, memory_order,
-// memory_order) volatile;
-// bool compare_exchange_weak(bool&, bool, memory_order, memory_order);
-// bool compare_exchange_strong(bool&, bool, memory_order,
-// memory_order) volatile;
-// bool compare_exchange_strong(bool&, bool, memory_order, memory_order);
-// bool compare_exchange_weak(bool&, bool,
-// memory_order = memory_order_seq_cst) volatile;
-// bool compare_exchange_weak(bool&, bool,
-// memory_order = memory_order_seq_cst);
-// bool compare_exchange_strong(bool&, bool,
-// memory_order = memory_order_seq_cst) volatile;
-// bool compare_exchange_strong(bool&, bool,
-// memory_order = memory_order_seq_cst);
-// atomic_bool() = default;
-// constexpr atomic_bool(bool);
-// atomic_bool(const atomic_bool&) = delete;
-// atomic_bool& operator=(const atomic_bool&) = delete;
-// atomic_bool& operator=(const atomic_bool&) volatile = delete;
-// bool operator=(bool) volatile;
-// bool operator=(bool);
-// } atomic_bool;
-//
-// bool atomic_is_lock_free(const volatile atomic_bool*);
-// bool atomic_is_lock_free(const atomic_bool*);
-// void atomic_init(volatile atomic_bool*, bool);
-// void atomic_init(atomic_bool*, bool);
-// void atomic_store(volatile atomic_bool*, bool);
-// void atomic_store(atomic_bool*, bool);
-// void atomic_store_explicit(volatile atomic_bool*, bool, memory_order);
-// void atomic_store_explicit(atomic_bool*, bool, memory_order);
-// bool atomic_load(const volatile atomic_bool*);
-// bool atomic_load(const atomic_bool*);
-// bool atomic_load_explicit(const volatile atomic_bool*, memory_order);
-// bool atomic_load_explicit(const atomic_bool*, memory_order);
-// bool atomic_exchange(volatile atomic_bool*, bool);
-// bool atomic_exchange(atomic_bool*, bool);
-// bool atomic_exchange_explicit(volatile atomic_bool*, bool, memory_order);
-// bool atomic_exchange_explicit(atomic_bool*, bool, memory_order);
-// bool atomic_compare_exchange_weak(volatile atomic_bool*, bool*, bool);
-// bool atomic_compare_exchange_weak(atomic_bool*, bool*, bool);
-// bool atomic_compare_exchange_strong(volatile atomic_bool*, bool*, bool);
-// bool atomic_compare_exchange_strong(atomic_bool*, bool*, bool);
-// bool atomic_compare_exchange_weak_explicit(volatile atomic_bool*, bool*, bool,
-// memory_order, memory_order);
-// bool atomic_compare_exchange_weak_explicit(atomic_bool*, bool*, bool,
-// memory_order, memory_order);
-// bool atomic_compare_exchange_strong_explicit(volatile atomic_bool*, bool*, bool,
-// memory_order, memory_order);
-// bool atomic_compare_exchange_strong_explicit(atomic_bool*, bool*, bool,
-// memory_order, memory_order);
-
-#include <atomic>
-#include <cassert>
-
-int main()
-{
- {
- volatile std::atomic_bool obj(true);
- assert(obj == true);
- std::atomic_init(&obj, false);
- assert(obj == false);
- std::atomic_init(&obj, true);
- assert(obj == true);
- bool b0 = obj.is_lock_free();
- obj.store(false);
- assert(obj == false);
- obj.store(true, std::memory_order_release);
- assert(obj == true);
- assert(obj.load() == true);
- assert(obj.load(std::memory_order_acquire) == true);
- assert(obj.exchange(false) == true);
- assert(obj == false);
- assert(obj.exchange(true, std::memory_order_relaxed) == false);
- assert(obj == true);
- bool x = obj;
- assert(obj.compare_exchange_weak(x, false) == true);
- assert(obj == false);
- assert(x == true);
- assert(obj.compare_exchange_weak(x, true) == false);
- assert(obj == false);
- assert(x == false);
- assert(obj.compare_exchange_strong(x, true) == true);
- assert(obj == true);
- assert(x == false);
- assert(obj.compare_exchange_strong(x, false) == false);
- assert(obj == true);
- assert(x == true);
- assert((obj = false) == false);
- assert(obj == false);
-
- std::atomic_init(&obj, true);
- assert(obj == true);
- bool b1 = std::atomic_is_lock_free(&obj);
- std::atomic_store(&obj, false);
- assert(obj == false);
- std::atomic_store_explicit(&obj, true, std::memory_order_release);
- assert(obj == true);
- assert(std::atomic_load(&obj) == true);
- assert(std::atomic_load_explicit(&obj, std::memory_order_acquire) == true);
- assert(std::atomic_exchange(&obj, false) == true);
- assert(obj == false);
- assert(std::atomic_exchange_explicit(&obj, true, std::memory_order_relaxed) == false);
- assert(obj == true);
- x = obj;
- assert(std::atomic_compare_exchange_weak(&obj, &x, false) == true);
- assert(obj == false);
- assert(x == true);
- assert(std::atomic_compare_exchange_weak(&obj, &x, true) == false);
- assert(obj == false);
- assert(x == false);
- assert(std::atomic_compare_exchange_strong(&obj, &x, true) == true);
- assert(obj == true);
- assert(x == false);
- assert(std::atomic_compare_exchange_strong(&obj, &x, false) == false);
- assert(obj == true);
- assert(x == true);
- assert(std::atomic_compare_exchange_weak_explicit(&obj, &x, false,
- std::memory_order_relaxed, std::memory_order_relaxed) == true);
- assert(obj == false);
- assert(x == true);
- assert(std::atomic_compare_exchange_weak_explicit(&obj, &x, true,
- std::memory_order_relaxed, std::memory_order_relaxed) == false);
- assert(obj == false);
- assert(x == false);
- assert(std::atomic_compare_exchange_strong_explicit(&obj, &x, true,
- std::memory_order_relaxed, std::memory_order_relaxed) == true);
- assert(obj == true);
- assert(x == false);
- assert(std::atomic_compare_exchange_strong_explicit(&obj, &x, false,
- std::memory_order_relaxed, std::memory_order_relaxed) == false);
- assert(obj == true);
- assert(x == true);
- assert((obj = false) == false);
- assert(obj == false);
- }
- {
- std::atomic_bool obj(true);
- assert(obj == true);
- std::atomic_init(&obj, false);
- assert(obj == false);
- std::atomic_init(&obj, true);
- assert(obj == true);
- bool b0 = obj.is_lock_free();
- obj.store(false);
- assert(obj == false);
- obj.store(true, std::memory_order_release);
- assert(obj == true);
- assert(obj.load() == true);
- assert(obj.load(std::memory_order_acquire) == true);
- assert(obj.exchange(false) == true);
- assert(obj == false);
- assert(obj.exchange(true, std::memory_order_relaxed) == false);
- assert(obj == true);
- bool x = obj;
- assert(obj.compare_exchange_weak(x, false) == true);
- assert(obj == false);
- assert(x == true);
- assert(obj.compare_exchange_weak(x, true) == false);
- assert(obj == false);
- assert(x == false);
- assert(obj.compare_exchange_strong(x, true) == true);
- assert(obj == true);
- assert(x == false);
- assert(obj.compare_exchange_strong(x, false) == false);
- assert(obj == true);
- assert(x == true);
- assert((obj = false) == false);
- assert(obj == false);
-
- std::atomic_init(&obj, true);
- assert(obj == true);
- bool b1 = std::atomic_is_lock_free(&obj);
- std::atomic_store(&obj, false);
- assert(obj == false);
- std::atomic_store_explicit(&obj, true, std::memory_order_release);
- assert(obj == true);
- assert(std::atomic_load(&obj) == true);
- assert(std::atomic_load_explicit(&obj, std::memory_order_acquire) == true);
- assert(std::atomic_exchange(&obj, false) == true);
- assert(obj == false);
- assert(std::atomic_exchange_explicit(&obj, true, std::memory_order_relaxed) == false);
- assert(obj == true);
- x = obj;
- assert(std::atomic_compare_exchange_weak(&obj, &x, false) == true);
- assert(obj == false);
- assert(x == true);
- assert(std::atomic_compare_exchange_weak(&obj, &x, true) == false);
- assert(obj == false);
- assert(x == false);
- assert(std::atomic_compare_exchange_strong(&obj, &x, true) == true);
- assert(obj == true);
- assert(x == false);
- assert(std::atomic_compare_exchange_strong(&obj, &x, false) == false);
- assert(obj == true);
- assert(x == true);
- assert(std::atomic_compare_exchange_weak_explicit(&obj, &x, false,
- std::memory_order_relaxed, std::memory_order_relaxed) == true);
- assert(obj == false);
- assert(x == true);
- assert(std::atomic_compare_exchange_weak_explicit(&obj, &x, true,
- std::memory_order_relaxed, std::memory_order_relaxed) == false);
- assert(obj == false);
- assert(x == false);
- assert(std::atomic_compare_exchange_strong_explicit(&obj, &x, true,
- std::memory_order_relaxed, std::memory_order_relaxed) == true);
- assert(obj == true);
- assert(x == false);
- assert(std::atomic_compare_exchange_strong_explicit(&obj, &x, false,
- std::memory_order_relaxed, std::memory_order_relaxed) == false);
- assert(obj == true);
- assert(x == true);
- assert((obj = false) == false);
- assert(obj == false);
- }
-}
Removed: libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.integral/integral.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.integral/integral.pass.cpp?rev=121201&view=auto
==============================================================================
--- libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.integral/integral.pass.cpp (original)
+++ libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.integral/integral.pass.cpp (removed)
@@ -1,276 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <atomic>
-
-// typedef struct atomic_itype
-// {
-// bool is_lock_free() const volatile;
-// bool is_lock_free() const;
-// void store(itype, memory_order = memory_order_seq_cst) volatile;
-// void store(itype, memory_order = memory_order_seq_cst);
-// itype load(memory_order = memory_order_seq_cst) const volatile;
-// itype load(memory_order = memory_order_seq_cst) const;
-// operator itype() const volatile;
-// operator itype() const;
-// itype exchange(itype, memory_order = memory_order_seq_cst) volatile;
-// itype exchange(itype, memory_order = memory_order_seq_cst);
-// bool compare_exchange_weak(itype&, itype, memory_order,
-// memory_order) volatile;
-// bool compare_exchange_weak(itype&, itype, memory_order, memory_order);
-// bool compare_exchange_strong(itype&, itype, memory_order,
-// memory_order) volatile;
-// bool compare_exchange_strong(itype&, itype, memory_order, memory_order);
-// bool compare_exchange_weak(itype&, itype,
-// memory_order = memory_order_seq_cst) volatile;
-// bool compare_exchange_weak(itype&, itype,
-// memory_order = memory_order_seq_cst);
-// bool compare_exchange_strong(itype&, itype,
-// memory_order = memory_order_seq_cst) volatile;
-// bool compare_exchange_strong(itype&, itype,
-// memory_order = memory_order_seq_cst);
-// itype fetch_add(itype, memory_order = memory_order_seq_cst) volatile;
-// itype fetch_add(itype, memory_order = memory_order_seq_cst);
-// itype fetch_sub(itype, memory_order = memory_order_seq_cst) volatile;
-// itype fetch_sub(itype, memory_order = memory_order_seq_cst);
-// itype fetch_and(itype, memory_order = memory_order_seq_cst) volatile;
-// itype fetch_and(itype, memory_order = memory_order_seq_cst);
-// itype fetch_or(itype, memory_order = memory_order_seq_cst) volatile;
-// itype fetch_or(itype, memory_order = memory_order_seq_cst);
-// itype fetch_xor(itype, memory_order = memory_order_seq_cst) volatile;
-// itype fetch_xor(itype, memory_order = memory_order_seq_cst);
-// atomic_itype() = default;
-// constexpr atomic_itype(itype);
-// atomic_itype(const atomic_itype&) = delete;
-// atomic_itype& operator=(const atomic_itype&) = delete;
-// atomic_itype& operator=(const atomic_itype&) volatile = delete;
-// itype operator=(itype) volatile;
-// itype operator=(itype);
-// itype operator++(int) volatile;
-// itype operator++(int);
-// itype operator--(int) volatile;
-// itype operator--(int);
-// itype operator++() volatile;
-// itype operator++();
-// itype operator--() volatile;
-// itype operator--();
-// itype operator+=(itype) volatile;
-// itype operator+=(itype);
-// itype operator-=(itype) volatile;
-// itype operator-=(itype);
-// itype operator&=(itype) volatile;
-// itype operator&=(itype);
-// itype operator|=(itype) volatile;
-// itype operator|=(itype);
-// itype operator^=(itype) volatile;
-// itype operator^=(itype);
-// } atomic_itype;
-//
-// bool atomic_is_lock_free(const volatile atomic_itype*);
-// bool atomic_is_lock_free(const atomic_itype*);
-// void atomic_init(volatile atomic_itype*, itype);
-// void atomic_init(atomic_itype*, itype);
-// void atomic_store(volatile atomic_itype*, itype);
-// void atomic_store(atomic_itype*, itype);
-// void atomic_store_explicit(volatile atomic_itype*, itype, memory_order);
-// void atomic_store_explicit(atomic_itype*, itype, memory_order);
-// itype atomic_load(const volatile atomic_itype*);
-// itype atomic_load(const atomic_itype*);
-// itype atomic_load_explicit(const volatile atomic_itype*, memory_order);
-// itype atomic_load_explicit(const atomic_itype*, memory_order);
-// itype atomic_exchange(volatile atomic_itype*, itype);
-// itype atomic_exchange(atomic_itype*, itype);
-// itype atomic_exchange_explicit(volatile atomic_itype*, itype, memory_order);
-// itype atomic_exchange_explicit(atomic_itype*, itype, memory_order);
-// bool atomic_compare_exchange_weak(volatile atomic_itype*, itype*, itype);
-// bool atomic_compare_exchange_weak(atomic_itype*, itype*, itype);
-// bool atomic_compare_exchange_strong(volatile atomic_itype*, itype*, itype);
-// bool atomic_compare_exchange_strong(atomic_itype*, itype*, itype);
-// bool atomic_compare_exchange_weak_explicit(volatile atomic_itype*, itype*, itype,
-// memory_order, memory_order);
-// bool atomic_compare_exchange_weak_explicit(atomic_itype*, itype*, itype,
-// memory_order, memory_order);
-// bool atomic_compare_exchange_strong_explicit(volatile atomic_itype*, itype*, itype,
-// memory_order, memory_order);
-// bool atomic_compare_exchange_strong_explicit(atomic_itype*, itype*, itype,
-// memory_order, memory_order);
-// itype atomic_fetch_add(volatile atomic_itype*, itype);
-// itype atomic_fetch_add(atomic_itype*, itype);
-// itype atomic_fetch_add_explicit(volatile atomic_itype*, itype, memory_order);
-// itype atomic_fetch_add_explicit(atomic_itype*, itype, memory_order);
-// itype atomic_fetch_sub(volatile atomic_itype*, itype);
-// itype atomic_fetch_sub(atomic_itype*, itype);
-// itype atomic_fetch_sub_explicit(volatile atomic_itype*, itype, memory_order);
-// itype atomic_fetch_sub_explicit(atomic_itype*, itype, memory_order);
-// itype atomic_fetch_and(volatile atomic_itype*, itype);
-// itype atomic_fetch_and(atomic_itype*, itype);
-// itype atomic_fetch_and_explicit(volatile atomic_itype*, itype, memory_order);
-// itype atomic_fetch_and_explicit(atomic_itype*, itype, memory_order);
-// itype atomic_fetch_or(volatile atomic_itype*, itype);
-// itype atomic_fetch_or(atomic_itype*, itype);
-// itype atomic_fetch_or_explicit(volatile atomic_itype*, itype, memory_order);
-// itype atomic_fetch_or_explicit(atomic_itype*, itype, memory_order);
-// itype atomic_fetch_xor(volatile atomic_itype*, itype);
-// itype atomic_fetch_xor(atomic_itype*, itype);
-// itype atomic_fetch_xor_explicit(volatile atomic_itype*, itype, memory_order);
-// itype atomic_fetch_xor_explicit(atomic_itype*, itype, memory_order);
-
-#include <atomic>
-#include <cassert>
-
-template <class A, class T>
-void
-do_test()
-{
- A obj(T(0));
- assert(obj == T(0));
- std::atomic_init(&obj, T(1));
- assert(obj == T(1));
- std::atomic_init(&obj, T(2));
- assert(obj == T(2));
- bool b0 = obj.is_lock_free();
- obj.store(T(0));
- assert(obj == T(0));
- obj.store(T(1), std::memory_order_release);
- assert(obj == T(1));
- assert(obj.load() == T(1));
- assert(obj.load(std::memory_order_acquire) == T(1));
- assert(obj.exchange(T(2)) == T(1));
- assert(obj == T(2));
- assert(obj.exchange(T(3), std::memory_order_relaxed) == T(2));
- assert(obj == T(3));
- T x = obj;
- assert(obj.compare_exchange_weak(x, T(2)) == true);
- assert(obj == T(2));
- assert(x == T(3));
- assert(obj.compare_exchange_weak(x, T(1)) == false);
- assert(obj == T(2));
- assert(x == T(2));
- assert(obj.compare_exchange_strong(x, T(1)) == true);
- assert(obj == T(1));
- assert(x == T(2));
- assert(obj.compare_exchange_strong(x, T(0)) == false);
- assert(obj == T(1));
- assert(x == T(1));
- assert((obj = T(0)) == T(0));
- assert(obj == T(0));
- assert(obj++ == T(0));
- assert(obj == T(1));
- assert(++obj == T(2));
- assert(obj == T(2));
- assert(--obj == T(1));
- assert(obj == T(1));
- assert(obj-- == T(1));
- assert(obj == T(0));
- obj = T(2);
- assert((obj += T(3)) == T(5));
- assert(obj == T(5));
- assert((obj -= T(3)) == T(2));
- assert(obj == T(2));
- assert((obj |= T(5)) == T(7));
- assert(obj == T(7));
- assert((obj &= T(0xF)) == T(7));
- assert(obj == T(7));
- assert((obj ^= T(0xF)) == T(8));
- assert(obj == T(8));
-
- std::atomic_init(&obj, T(1));
- assert(obj == T(1));
- bool b1 = std::atomic_is_lock_free(&obj);
- std::atomic_store(&obj, T(0));
- assert(obj == T(0));
- std::atomic_store_explicit(&obj, T(1), std::memory_order_release);
- assert(obj == T(1));
- assert(std::atomic_load(&obj) == T(1));
- assert(std::atomic_load_explicit(&obj, std::memory_order_acquire) == T(1));
- assert(std::atomic_exchange(&obj, T(2)) == T(1));
- assert(obj == T(2));
- assert(std::atomic_exchange_explicit(&obj, T(3), std::memory_order_relaxed) == T(2));
- assert(obj == T(3));
- x = obj;
- assert(std::atomic_compare_exchange_weak(&obj, &x, T(2)) == true);
- assert(obj == T(2));
- assert(x == T(3));
- assert(std::atomic_compare_exchange_weak(&obj, &x, T(1)) == false);
- assert(obj == T(2));
- assert(x == T(2));
- assert(std::atomic_compare_exchange_strong(&obj, &x, T(1)) == true);
- assert(obj == T(1));
- assert(x == T(2));
- assert(std::atomic_compare_exchange_strong(&obj, &x, T(0)) == false);
- assert(obj == T(1));
- assert(x == T(1));
- assert(std::atomic_compare_exchange_weak_explicit(&obj, &x, T(2),
- std::memory_order_relaxed, std::memory_order_relaxed) == true);
- assert(obj == T(2));
- assert(x == T(1));
- assert(std::atomic_compare_exchange_weak_explicit(&obj, &x, T(3),
- std::memory_order_relaxed, std::memory_order_relaxed) == false);
- assert(obj == T(2));
- assert(x == T(2));
- assert(std::atomic_compare_exchange_strong_explicit(&obj, &x, T(3),
- std::memory_order_relaxed, std::memory_order_relaxed) == true);
- assert(obj == T(3));
- assert(x == T(2));
- assert(std::atomic_compare_exchange_strong_explicit(&obj, &x, T(0),
- std::memory_order_relaxed, std::memory_order_relaxed) == false);
- assert(obj == T(3));
- assert(x == T(3));
- assert((obj = T(1)) == T(1));
- assert(obj == T(1));
- obj = T(2);
- assert(std::atomic_fetch_add(&obj, T(3)) == T(2));
- assert(obj == T(5));
- assert(std::atomic_fetch_add_explicit(&obj, T(3), std::memory_order_seq_cst) == T(5));
- assert(obj == T(8));
- assert(std::atomic_fetch_sub(&obj, T(3)) == T(8));
- assert(obj == T(5));
- assert(std::atomic_fetch_sub_explicit(&obj, T(3), std::memory_order_seq_cst) == T(5));
- assert(obj == T(2));
- assert(std::atomic_fetch_or(&obj, T(5)) == T(2));
- assert(obj == T(7));
- assert(std::atomic_fetch_or_explicit(&obj, T(8), std::memory_order_seq_cst) == T(7));
- assert(obj == T(0xF));
- assert(std::atomic_fetch_and(&obj, T(7)) == T(0xF));
- assert(obj == T(7));
- assert(std::atomic_fetch_and_explicit(&obj, T(3), std::memory_order_seq_cst) == T(7));
- assert(obj == T(3));
- assert(std::atomic_fetch_xor(&obj, T(7)) == T(3));
- assert(obj == T(4));
- assert(std::atomic_fetch_xor_explicit(&obj, T(7), std::memory_order_seq_cst) == T(4));
- assert(obj == T(3));
-}
-
-template <class A, class T>
-void test()
-{
- do_test<A, T>();
- do_test<volatile A, T>();
-}
-
-
-int main()
-{
- test<std::atomic_char, char>();
- test<std::atomic_schar, signed char>();
- test<std::atomic_uchar, unsigned char>();
- test<std::atomic_short, short>();
- test<std::atomic_ushort, unsigned short>();
- test<std::atomic_int, int>();
- test<std::atomic_uint, unsigned int>();
- test<std::atomic_long, long>();
- test<std::atomic_ulong, unsigned long>();
- test<std::atomic_llong, long long>();
- test<std::atomic_ullong, unsigned long long>();
-#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
- test<std::atomic_char16_t, char16_t>();
- test<std::atomic_char32_t, char32_t>();
-#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
- test<std::atomic_wchar_t, wchar_t>();
-}
Copied: libcxx/trunk/test/atomics/atomics.types.generic/bool.pass.cpp (from r120913, libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.integral/bool.pass.cpp)
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/atomics/atomics.types.generic/bool.pass.cpp?p2=libcxx/trunk/test/atomics/atomics.types.generic/bool.pass.cpp&p1=libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.integral/bool.pass.cpp&r1=120913&r2=121202&rev=121202&view=diff
==============================================================================
--- libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.integral/bool.pass.cpp (original)
+++ libcxx/trunk/test/atomics/atomics.types.generic/bool.pass.cpp Tue Dec 7 17:20:28 2010
@@ -9,69 +9,43 @@
// <atomic>
-// typedef struct atomic_bool
+// template <class T>
+// struct atomic
// {
// bool is_lock_free() const volatile;
// bool is_lock_free() const;
-// void store(bool, memory_order = memory_order_seq_cst) volatile;
-// void store(bool, memory_order = memory_order_seq_cst);
-// bool load(memory_order = memory_order_seq_cst) const volatile;
-// bool load(memory_order = memory_order_seq_cst) const;
-// operator bool() const volatile;
-// operator bool() const;
-// bool exchange(bool, memory_order = memory_order_seq_cst) volatile;
-// bool exchange(bool, memory_order = memory_order_seq_cst);
-// bool compare_exchange_weak(bool&, bool, memory_order,
-// memory_order) volatile;
-// bool compare_exchange_weak(bool&, bool, memory_order, memory_order);
-// bool compare_exchange_strong(bool&, bool, memory_order,
-// memory_order) volatile;
-// bool compare_exchange_strong(bool&, bool, memory_order, memory_order);
-// bool compare_exchange_weak(bool&, bool,
-// memory_order = memory_order_seq_cst) volatile;
-// bool compare_exchange_weak(bool&, bool,
-// memory_order = memory_order_seq_cst);
-// bool compare_exchange_strong(bool&, bool,
-// memory_order = memory_order_seq_cst) volatile;
-// bool compare_exchange_strong(bool&, bool,
-// memory_order = memory_order_seq_cst);
-// atomic_bool() = default;
-// constexpr atomic_bool(bool);
-// atomic_bool(const atomic_bool&) = delete;
-// atomic_bool& operator=(const atomic_bool&) = delete;
-// atomic_bool& operator=(const atomic_bool&) volatile = delete;
-// bool operator=(bool) volatile;
-// bool operator=(bool);
-// } atomic_bool;
+// void store(T desr, memory_order m = memory_order_seq_cst) volatile;
+// void store(T desr, memory_order m = memory_order_seq_cst);
+// T load(memory_order m = memory_order_seq_cst) const volatile;
+// T load(memory_order m = memory_order_seq_cst) const;
+// operator T() const volatile;
+// operator T() const;
+// T exchange(T desr, memory_order m = memory_order_seq_cst) volatile;
+// T exchange(T desr, memory_order m = memory_order_seq_cst);
+// bool compare_exchange_weak(T& expc, T desr,
+// memory_order s, memory_order f) volatile;
+// bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f);
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order s, memory_order f) volatile;
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order s, memory_order f);
+// bool compare_exchange_weak(T& expc, T desr,
+// memory_order m = memory_order_seq_cst) volatile;
+// bool compare_exchange_weak(T& expc, T desr,
+// memory_order m = memory_order_seq_cst);
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order m = memory_order_seq_cst) volatile;
+// bool compare_exchange_strong(T& expc, T desr,
+// memory_order m = memory_order_seq_cst);
//
-// bool atomic_is_lock_free(const volatile atomic_bool*);
-// bool atomic_is_lock_free(const atomic_bool*);
-// void atomic_init(volatile atomic_bool*, bool);
-// void atomic_init(atomic_bool*, bool);
-// void atomic_store(volatile atomic_bool*, bool);
-// void atomic_store(atomic_bool*, bool);
-// void atomic_store_explicit(volatile atomic_bool*, bool, memory_order);
-// void atomic_store_explicit(atomic_bool*, bool, memory_order);
-// bool atomic_load(const volatile atomic_bool*);
-// bool atomic_load(const atomic_bool*);
-// bool atomic_load_explicit(const volatile atomic_bool*, memory_order);
-// bool atomic_load_explicit(const atomic_bool*, memory_order);
-// bool atomic_exchange(volatile atomic_bool*, bool);
-// bool atomic_exchange(atomic_bool*, bool);
-// bool atomic_exchange_explicit(volatile atomic_bool*, bool, memory_order);
-// bool atomic_exchange_explicit(atomic_bool*, bool, memory_order);
-// bool atomic_compare_exchange_weak(volatile atomic_bool*, bool*, bool);
-// bool atomic_compare_exchange_weak(atomic_bool*, bool*, bool);
-// bool atomic_compare_exchange_strong(volatile atomic_bool*, bool*, bool);
-// bool atomic_compare_exchange_strong(atomic_bool*, bool*, bool);
-// bool atomic_compare_exchange_weak_explicit(volatile atomic_bool*, bool*, bool,
-// memory_order, memory_order);
-// bool atomic_compare_exchange_weak_explicit(atomic_bool*, bool*, bool,
-// memory_order, memory_order);
-// bool atomic_compare_exchange_strong_explicit(volatile atomic_bool*, bool*, bool,
-// memory_order, memory_order);
-// bool atomic_compare_exchange_strong_explicit(atomic_bool*, bool*, bool,
-// memory_order, memory_order);
+// atomic() = default;
+// constexpr atomic(T desr);
+// atomic(const atomic&) = delete;
+// atomic& operator=(const atomic&) = delete;
+// atomic& operator=(const atomic&) volatile = delete;
+// T operator=(T) volatile;
+// T operator=(T);
+// };
#include <atomic>
#include <cassert>
@@ -79,7 +53,8 @@
int main()
{
{
- volatile std::atomic_bool obj(true);
+ volatile std::atomic<bool> _;
+ volatile std::atomic<bool> obj(true);
assert(obj == true);
std::atomic_init(&obj, false);
assert(obj == false);
@@ -100,65 +75,40 @@
assert(obj.compare_exchange_weak(x, false) == true);
assert(obj == false);
assert(x == true);
- assert(obj.compare_exchange_weak(x, true) == false);
+ assert(obj.compare_exchange_weak(x, true,
+ std::memory_order_seq_cst) == false);
assert(obj == false);
- assert(x == false);
- assert(obj.compare_exchange_strong(x, true) == true);
- assert(obj == true);
- assert(x == false);
- assert(obj.compare_exchange_strong(x, false) == false);
- assert(obj == true);
assert(x == true);
- assert((obj = false) == false);
- assert(obj == false);
-
- std::atomic_init(&obj, true);
- assert(obj == true);
- bool b1 = std::atomic_is_lock_free(&obj);
- std::atomic_store(&obj, false);
- assert(obj == false);
- std::atomic_store_explicit(&obj, true, std::memory_order_release);
- assert(obj == true);
- assert(std::atomic_load(&obj) == true);
- assert(std::atomic_load_explicit(&obj, std::memory_order_acquire) == true);
- assert(std::atomic_exchange(&obj, false) == true);
- assert(obj == false);
- assert(std::atomic_exchange_explicit(&obj, true, std::memory_order_relaxed) == false);
- assert(obj == true);
- x = obj;
- assert(std::atomic_compare_exchange_weak(&obj, &x, false) == true);
+ obj.store(true);
+ assert(obj.compare_exchange_weak(x, false,
+ std::memory_order_seq_cst,
+ std::memory_order_seq_cst) == true);
assert(obj == false);
assert(x == true);
- assert(std::atomic_compare_exchange_weak(&obj, &x, true) == false);
+ x = true;
+ obj.store(true);
+ assert(obj.compare_exchange_strong(x, false) == true);
assert(obj == false);
- assert(x == false);
- assert(std::atomic_compare_exchange_strong(&obj, &x, true) == true);
- assert(obj == true);
- assert(x == false);
- assert(std::atomic_compare_exchange_strong(&obj, &x, false) == false);
- assert(obj == true);
assert(x == true);
- assert(std::atomic_compare_exchange_weak_explicit(&obj, &x, false,
- std::memory_order_relaxed, std::memory_order_relaxed) == true);
+ assert(obj.compare_exchange_strong(x, true,
+ std::memory_order_seq_cst) == false);
assert(obj == false);
assert(x == true);
- assert(std::atomic_compare_exchange_weak_explicit(&obj, &x, true,
- std::memory_order_relaxed, std::memory_order_relaxed) == false);
+ x = true;
+ obj.store(true);
+ assert(obj.compare_exchange_strong(x, false,
+ std::memory_order_seq_cst,
+ std::memory_order_seq_cst) == true);
assert(obj == false);
- assert(x == false);
- assert(std::atomic_compare_exchange_strong_explicit(&obj, &x, true,
- std::memory_order_relaxed, std::memory_order_relaxed) == true);
- assert(obj == true);
- assert(x == false);
- assert(std::atomic_compare_exchange_strong_explicit(&obj, &x, false,
- std::memory_order_relaxed, std::memory_order_relaxed) == false);
- assert(obj == true);
assert(x == true);
assert((obj = false) == false);
assert(obj == false);
+ assert((obj = true) == true);
+ assert(obj == true);
}
{
- std::atomic_bool obj(true);
+ std::atomic<bool> _;
+ std::atomic<bool> obj(true);
assert(obj == true);
std::atomic_init(&obj, false);
assert(obj == false);
@@ -179,61 +129,35 @@
assert(obj.compare_exchange_weak(x, false) == true);
assert(obj == false);
assert(x == true);
- assert(obj.compare_exchange_weak(x, true) == false);
+ assert(obj.compare_exchange_weak(x, true,
+ std::memory_order_seq_cst) == false);
assert(obj == false);
- assert(x == false);
- assert(obj.compare_exchange_strong(x, true) == true);
- assert(obj == true);
- assert(x == false);
- assert(obj.compare_exchange_strong(x, false) == false);
- assert(obj == true);
assert(x == true);
- assert((obj = false) == false);
- assert(obj == false);
-
- std::atomic_init(&obj, true);
- assert(obj == true);
- bool b1 = std::atomic_is_lock_free(&obj);
- std::atomic_store(&obj, false);
- assert(obj == false);
- std::atomic_store_explicit(&obj, true, std::memory_order_release);
- assert(obj == true);
- assert(std::atomic_load(&obj) == true);
- assert(std::atomic_load_explicit(&obj, std::memory_order_acquire) == true);
- assert(std::atomic_exchange(&obj, false) == true);
- assert(obj == false);
- assert(std::atomic_exchange_explicit(&obj, true, std::memory_order_relaxed) == false);
- assert(obj == true);
- x = obj;
- assert(std::atomic_compare_exchange_weak(&obj, &x, false) == true);
+ obj.store(true);
+ assert(obj.compare_exchange_weak(x, false,
+ std::memory_order_seq_cst,
+ std::memory_order_seq_cst) == true);
assert(obj == false);
assert(x == true);
- assert(std::atomic_compare_exchange_weak(&obj, &x, true) == false);
+ x = true;
+ obj.store(true);
+ assert(obj.compare_exchange_strong(x, false) == true);
assert(obj == false);
- assert(x == false);
- assert(std::atomic_compare_exchange_strong(&obj, &x, true) == true);
- assert(obj == true);
- assert(x == false);
- assert(std::atomic_compare_exchange_strong(&obj, &x, false) == false);
- assert(obj == true);
assert(x == true);
- assert(std::atomic_compare_exchange_weak_explicit(&obj, &x, false,
- std::memory_order_relaxed, std::memory_order_relaxed) == true);
+ assert(obj.compare_exchange_strong(x, true,
+ std::memory_order_seq_cst) == false);
assert(obj == false);
assert(x == true);
- assert(std::atomic_compare_exchange_weak_explicit(&obj, &x, true,
- std::memory_order_relaxed, std::memory_order_relaxed) == false);
+ x = true;
+ obj.store(true);
+ assert(obj.compare_exchange_strong(x, false,
+ std::memory_order_seq_cst,
+ std::memory_order_seq_cst) == true);
assert(obj == false);
- assert(x == false);
- assert(std::atomic_compare_exchange_strong_explicit(&obj, &x, true,
- std::memory_order_relaxed, std::memory_order_relaxed) == true);
- assert(obj == true);
- assert(x == false);
- assert(std::atomic_compare_exchange_strong_explicit(&obj, &x, false,
- std::memory_order_relaxed, std::memory_order_relaxed) == false);
- assert(obj == true);
assert(x == true);
assert((obj = false) == false);
assert(obj == false);
+ assert((obj = true) == true);
+ assert(obj == true);
}
}
Copied: libcxx/trunk/test/atomics/atomics.types.generic/integral.pass.cpp (from r120913, libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.integral/integral.pass.cpp)
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/atomics/atomics.types.generic/integral.pass.cpp?p2=libcxx/trunk/test/atomics/atomics.types.generic/integral.pass.cpp&p1=libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.integral/integral.pass.cpp&r1=120913&r2=121202&rev=121202&view=diff
==============================================================================
--- libcxx/trunk/test/atomics/atomics.types.generic/atomics.types.integral/integral.pass.cpp (original)
+++ libcxx/trunk/test/atomics/atomics.types.generic/integral.pass.cpp Tue Dec 7 17:20:28 2010
@@ -9,117 +9,80 @@
// <atomic>
-// typedef struct atomic_itype
+// template <>
+// struct atomic<integral>
// {
// bool is_lock_free() const volatile;
// bool is_lock_free() const;
-// void store(itype, memory_order = memory_order_seq_cst) volatile;
-// void store(itype, memory_order = memory_order_seq_cst);
-// itype load(memory_order = memory_order_seq_cst) const volatile;
-// itype load(memory_order = memory_order_seq_cst) const;
-// operator itype() const volatile;
-// operator itype() const;
-// itype exchange(itype, memory_order = memory_order_seq_cst) volatile;
-// itype exchange(itype, memory_order = memory_order_seq_cst);
-// bool compare_exchange_weak(itype&, itype, memory_order,
-// memory_order) volatile;
-// bool compare_exchange_weak(itype&, itype, memory_order, memory_order);
-// bool compare_exchange_strong(itype&, itype, memory_order,
-// memory_order) volatile;
-// bool compare_exchange_strong(itype&, itype, memory_order, memory_order);
-// bool compare_exchange_weak(itype&, itype,
-// memory_order = memory_order_seq_cst) volatile;
-// bool compare_exchange_weak(itype&, itype,
-// memory_order = memory_order_seq_cst);
-// bool compare_exchange_strong(itype&, itype,
-// memory_order = memory_order_seq_cst) volatile;
-// bool compare_exchange_strong(itype&, itype,
-// memory_order = memory_order_seq_cst);
-// itype fetch_add(itype, memory_order = memory_order_seq_cst) volatile;
-// itype fetch_add(itype, memory_order = memory_order_seq_cst);
-// itype fetch_sub(itype, memory_order = memory_order_seq_cst) volatile;
-// itype fetch_sub(itype, memory_order = memory_order_seq_cst);
-// itype fetch_and(itype, memory_order = memory_order_seq_cst) volatile;
-// itype fetch_and(itype, memory_order = memory_order_seq_cst);
-// itype fetch_or(itype, memory_order = memory_order_seq_cst) volatile;
-// itype fetch_or(itype, memory_order = memory_order_seq_cst);
-// itype fetch_xor(itype, memory_order = memory_order_seq_cst) volatile;
-// itype fetch_xor(itype, memory_order = memory_order_seq_cst);
-// atomic_itype() = default;
-// constexpr atomic_itype(itype);
-// atomic_itype(const atomic_itype&) = delete;
-// atomic_itype& operator=(const atomic_itype&) = delete;
-// atomic_itype& operator=(const atomic_itype&) volatile = delete;
-// itype operator=(itype) volatile;
-// itype operator=(itype);
-// itype operator++(int) volatile;
-// itype operator++(int);
-// itype operator--(int) volatile;
-// itype operator--(int);
-// itype operator++() volatile;
-// itype operator++();
-// itype operator--() volatile;
-// itype operator--();
-// itype operator+=(itype) volatile;
-// itype operator+=(itype);
-// itype operator-=(itype) volatile;
-// itype operator-=(itype);
-// itype operator&=(itype) volatile;
-// itype operator&=(itype);
-// itype operator|=(itype) volatile;
-// itype operator|=(itype);
-// itype operator^=(itype) volatile;
-// itype operator^=(itype);
-// } atomic_itype;
+// void store(integral desr, memory_order m = memory_order_seq_cst) volatile;
+// void store(integral desr, memory_order m = memory_order_seq_cst);
+// integral load(memory_order m = memory_order_seq_cst) const volatile;
+// integral load(memory_order m = memory_order_seq_cst) const;
+// operator integral() const volatile;
+// operator integral() const;
+// integral exchange(integral desr,
+// memory_order m = memory_order_seq_cst) volatile;
+// integral exchange(integral desr, memory_order m = memory_order_seq_cst);
+// bool compare_exchange_weak(integral& expc, integral desr,
+// memory_order s, memory_order f) volatile;
+// bool compare_exchange_weak(integral& expc, integral desr,
+// memory_order s, memory_order f);
+// bool compare_exchange_strong(integral& expc, integral desr,
+// memory_order s, memory_order f) volatile;
+// bool compare_exchange_strong(integral& expc, integral desr,
+// memory_order s, memory_order f);
+// bool compare_exchange_weak(integral& expc, integral desr,
+// memory_order m = memory_order_seq_cst) volatile;
+// bool compare_exchange_weak(integral& expc, integral desr,
+// memory_order m = memory_order_seq_cst);
+// bool compare_exchange_strong(integral& expc, integral desr,
+// memory_order m = memory_order_seq_cst) volatile;
+// bool compare_exchange_strong(integral& expc, integral desr,
+// memory_order m = memory_order_seq_cst);
//
-// bool atomic_is_lock_free(const volatile atomic_itype*);
-// bool atomic_is_lock_free(const atomic_itype*);
-// void atomic_init(volatile atomic_itype*, itype);
-// void atomic_init(atomic_itype*, itype);
-// void atomic_store(volatile atomic_itype*, itype);
-// void atomic_store(atomic_itype*, itype);
-// void atomic_store_explicit(volatile atomic_itype*, itype, memory_order);
-// void atomic_store_explicit(atomic_itype*, itype, memory_order);
-// itype atomic_load(const volatile atomic_itype*);
-// itype atomic_load(const atomic_itype*);
-// itype atomic_load_explicit(const volatile atomic_itype*, memory_order);
-// itype atomic_load_explicit(const atomic_itype*, memory_order);
-// itype atomic_exchange(volatile atomic_itype*, itype);
-// itype atomic_exchange(atomic_itype*, itype);
-// itype atomic_exchange_explicit(volatile atomic_itype*, itype, memory_order);
-// itype atomic_exchange_explicit(atomic_itype*, itype, memory_order);
-// bool atomic_compare_exchange_weak(volatile atomic_itype*, itype*, itype);
-// bool atomic_compare_exchange_weak(atomic_itype*, itype*, itype);
-// bool atomic_compare_exchange_strong(volatile atomic_itype*, itype*, itype);
-// bool atomic_compare_exchange_strong(atomic_itype*, itype*, itype);
-// bool atomic_compare_exchange_weak_explicit(volatile atomic_itype*, itype*, itype,
-// memory_order, memory_order);
-// bool atomic_compare_exchange_weak_explicit(atomic_itype*, itype*, itype,
-// memory_order, memory_order);
-// bool atomic_compare_exchange_strong_explicit(volatile atomic_itype*, itype*, itype,
-// memory_order, memory_order);
-// bool atomic_compare_exchange_strong_explicit(atomic_itype*, itype*, itype,
-// memory_order, memory_order);
-// itype atomic_fetch_add(volatile atomic_itype*, itype);
-// itype atomic_fetch_add(atomic_itype*, itype);
-// itype atomic_fetch_add_explicit(volatile atomic_itype*, itype, memory_order);
-// itype atomic_fetch_add_explicit(atomic_itype*, itype, memory_order);
-// itype atomic_fetch_sub(volatile atomic_itype*, itype);
-// itype atomic_fetch_sub(atomic_itype*, itype);
-// itype atomic_fetch_sub_explicit(volatile atomic_itype*, itype, memory_order);
-// itype atomic_fetch_sub_explicit(atomic_itype*, itype, memory_order);
-// itype atomic_fetch_and(volatile atomic_itype*, itype);
-// itype atomic_fetch_and(atomic_itype*, itype);
-// itype atomic_fetch_and_explicit(volatile atomic_itype*, itype, memory_order);
-// itype atomic_fetch_and_explicit(atomic_itype*, itype, memory_order);
-// itype atomic_fetch_or(volatile atomic_itype*, itype);
-// itype atomic_fetch_or(atomic_itype*, itype);
-// itype atomic_fetch_or_explicit(volatile atomic_itype*, itype, memory_order);
-// itype atomic_fetch_or_explicit(atomic_itype*, itype, memory_order);
-// itype atomic_fetch_xor(volatile atomic_itype*, itype);
-// itype atomic_fetch_xor(atomic_itype*, itype);
-// itype atomic_fetch_xor_explicit(volatile atomic_itype*, itype, memory_order);
-// itype atomic_fetch_xor_explicit(atomic_itype*, itype, memory_order);
+// integral
+// fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile;
+// integral fetch_add(integral op, memory_order m = memory_order_seq_cst);
+// integral
+// fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile;
+// integral fetch_sub(integral op, memory_order m = memory_order_seq_cst);
+// integral
+// fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile;
+// integral fetch_and(integral op, memory_order m = memory_order_seq_cst);
+// integral
+// fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile;
+// integral fetch_or(integral op, memory_order m = memory_order_seq_cst);
+// integral
+// fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile;
+// integral fetch_xor(integral op, memory_order m = memory_order_seq_cst);
+//
+// atomic() = default;
+// constexpr atomic(integral desr);
+// atomic(const atomic&) = delete;
+// atomic& operator=(const atomic&) = delete;
+// atomic& operator=(const atomic&) volatile = delete;
+// integral operator=(integral desr) volatile;
+// integral operator=(integral desr);
+//
+// integral operator++(int) volatile;
+// integral operator++(int);
+// integral operator--(int) volatile;
+// integral operator--(int);
+// integral operator++() volatile;
+// integral operator++();
+// integral operator--() volatile;
+// integral operator--();
+// integral operator+=(integral op) volatile;
+// integral operator+=(integral op);
+// integral operator-=(integral op) volatile;
+// integral operator-=(integral op);
+// integral operator&=(integral op) volatile;
+// integral operator&=(integral op);
+// integral operator|=(integral op) volatile;
+// integral operator|=(integral op);
+// integral operator^=(integral op) volatile;
+// integral operator^=(integral op);
+// };
#include <atomic>
#include <cassert>
@@ -151,13 +114,14 @@
assert(x == T(3));
assert(obj.compare_exchange_weak(x, T(1)) == false);
assert(obj == T(2));
- assert(x == T(2));
+ assert(x == T(1));
+ x = T(2);
assert(obj.compare_exchange_strong(x, T(1)) == true);
assert(obj == T(1));
assert(x == T(2));
assert(obj.compare_exchange_strong(x, T(0)) == false);
assert(obj == T(1));
- assert(x == T(1));
+ assert(x == T(0));
assert((obj = T(0)) == T(0));
assert(obj == T(0));
assert(obj++ == T(0));
@@ -179,72 +143,6 @@
assert(obj == T(7));
assert((obj ^= T(0xF)) == T(8));
assert(obj == T(8));
-
- std::atomic_init(&obj, T(1));
- assert(obj == T(1));
- bool b1 = std::atomic_is_lock_free(&obj);
- std::atomic_store(&obj, T(0));
- assert(obj == T(0));
- std::atomic_store_explicit(&obj, T(1), std::memory_order_release);
- assert(obj == T(1));
- assert(std::atomic_load(&obj) == T(1));
- assert(std::atomic_load_explicit(&obj, std::memory_order_acquire) == T(1));
- assert(std::atomic_exchange(&obj, T(2)) == T(1));
- assert(obj == T(2));
- assert(std::atomic_exchange_explicit(&obj, T(3), std::memory_order_relaxed) == T(2));
- assert(obj == T(3));
- x = obj;
- assert(std::atomic_compare_exchange_weak(&obj, &x, T(2)) == true);
- assert(obj == T(2));
- assert(x == T(3));
- assert(std::atomic_compare_exchange_weak(&obj, &x, T(1)) == false);
- assert(obj == T(2));
- assert(x == T(2));
- assert(std::atomic_compare_exchange_strong(&obj, &x, T(1)) == true);
- assert(obj == T(1));
- assert(x == T(2));
- assert(std::atomic_compare_exchange_strong(&obj, &x, T(0)) == false);
- assert(obj == T(1));
- assert(x == T(1));
- assert(std::atomic_compare_exchange_weak_explicit(&obj, &x, T(2),
- std::memory_order_relaxed, std::memory_order_relaxed) == true);
- assert(obj == T(2));
- assert(x == T(1));
- assert(std::atomic_compare_exchange_weak_explicit(&obj, &x, T(3),
- std::memory_order_relaxed, std::memory_order_relaxed) == false);
- assert(obj == T(2));
- assert(x == T(2));
- assert(std::atomic_compare_exchange_strong_explicit(&obj, &x, T(3),
- std::memory_order_relaxed, std::memory_order_relaxed) == true);
- assert(obj == T(3));
- assert(x == T(2));
- assert(std::atomic_compare_exchange_strong_explicit(&obj, &x, T(0),
- std::memory_order_relaxed, std::memory_order_relaxed) == false);
- assert(obj == T(3));
- assert(x == T(3));
- assert((obj = T(1)) == T(1));
- assert(obj == T(1));
- obj = T(2);
- assert(std::atomic_fetch_add(&obj, T(3)) == T(2));
- assert(obj == T(5));
- assert(std::atomic_fetch_add_explicit(&obj, T(3), std::memory_order_seq_cst) == T(5));
- assert(obj == T(8));
- assert(std::atomic_fetch_sub(&obj, T(3)) == T(8));
- assert(obj == T(5));
- assert(std::atomic_fetch_sub_explicit(&obj, T(3), std::memory_order_seq_cst) == T(5));
- assert(obj == T(2));
- assert(std::atomic_fetch_or(&obj, T(5)) == T(2));
- assert(obj == T(7));
- assert(std::atomic_fetch_or_explicit(&obj, T(8), std::memory_order_seq_cst) == T(7));
- assert(obj == T(0xF));
- assert(std::atomic_fetch_and(&obj, T(7)) == T(0xF));
- assert(obj == T(7));
- assert(std::atomic_fetch_and_explicit(&obj, T(3), std::memory_order_seq_cst) == T(7));
- assert(obj == T(3));
- assert(std::atomic_fetch_xor(&obj, T(7)) == T(3));
- assert(obj == T(4));
- assert(std::atomic_fetch_xor_explicit(&obj, T(7), std::memory_order_seq_cst) == T(4));
- assert(obj == T(3));
}
template <class A, class T>
@@ -273,4 +171,21 @@
test<std::atomic_char32_t, char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
test<std::atomic_wchar_t, wchar_t>();
+
+ test<volatile std::atomic_char, char>();
+ test<volatile std::atomic_schar, signed char>();
+ test<volatile std::atomic_uchar, unsigned char>();
+ test<volatile std::atomic_short, short>();
+ test<volatile std::atomic_ushort, unsigned short>();
+ test<volatile std::atomic_int, int>();
+ test<volatile std::atomic_uint, unsigned int>();
+ test<volatile std::atomic_long, long>();
+ test<volatile std::atomic_ulong, unsigned long>();
+ test<volatile std::atomic_llong, long long>();
+ test<volatile std::atomic_ullong, unsigned long long>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<volatile std::atomic_char16_t, char16_t>();
+ test<volatile std::atomic_char32_t, char32_t>();
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+ test<volatile std::atomic_wchar_t, wchar_t>();
}
Removed: libcxx/trunk/test/atomics/atomics.types.generic/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/atomics/atomics.types.generic/nothing_to_do.pass.cpp?rev=121201&view=auto
==============================================================================
--- libcxx/trunk/test/atomics/atomics.types.generic/nothing_to_do.pass.cpp (original)
+++ libcxx/trunk/test/atomics/atomics.types.generic/nothing_to_do.pass.cpp (removed)
@@ -1,13 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-int main()
-{
-}
More information about the cfe-commits
mailing list