summaryrefslogtreecommitdiffstats
path: root/libcxx/test
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2010-12-08 17:20:28 +0000
committerHoward Hinnant <hhinnant@apple.com>2010-12-08 17:20:28 +0000
commitb5452b3db5a888f85c5bb4993b232ec9a802940c (patch)
tree8752dc5692d42ef301932da928f42badf2e6ec43 /libcxx/test
parentcbc87eb33130d088245c5ede83d73a1631f0598b (diff)
downloadbcm5719-llvm-b5452b3db5a888f85c5bb4993b232ec9a802940c.tar.gz
bcm5719-llvm-b5452b3db5a888f85c5bb4993b232ec9a802940c.zip
After a long break to wait for the atomic spec to settle, this completes the library part of <atomic>. It currently won't even parse as it depends on the existence of the intrinsics specified at http://libcxx.llvm.org/atomic_design_a.html. Everything has been tested using fake intrinsics which have now been removed. As the intrinsics come online, the ATOMIC_* macros will need to be adjusted to reflect which operations are lock-free. These macros will probably need to be #ifdef'd for each supported platform.
llvm-svn: 121267
Diffstat (limited to 'libcxx/test')
-rw-r--r--libcxx/test/atomics/atomics.fences/atomic_signal_fence.pass.cpp19
-rw-r--r--libcxx/test/atomics/atomics.fences/atomic_thread_fence.pass.cpp19
-rw-r--r--libcxx/test/atomics/atomics.lockfree/lockfree.pass.cpp50
-rw-r--r--libcxx/test/atomics/atomics.types.generic/cstdint_typedefs.pass.cpp66
-rw-r--r--libcxx/test/atomics/atomics.types.generic/integral_typedefs.pass.cpp48
-rw-r--r--libcxx/test/atomics/atomics.types.operations/atomics.types.operations.arith/nothing_to_do.pass.cpp13
-rw-r--r--libcxx/test/atomics/atomics.types.operations/atomics.types.operations.general/nothing_to_do.pass.cpp13
-rw-r--r--libcxx/test/atomics/atomics.types.operations/atomics.types.operations.pointer/nothing_to_do.pass.cpp13
-rw-r--r--libcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp21
-rw-r--r--libcxx/test/atomics/atomics.types.operations/atomics.types.operations.templ/nothing_to_do.pass.cpp13
-rw-r--r--libcxx/test/atomics/atomics.types.operations/nothing_to_do.pass.cpp13
11 files changed, 288 insertions, 0 deletions
diff --git a/libcxx/test/atomics/atomics.fences/atomic_signal_fence.pass.cpp b/libcxx/test/atomics/atomics.fences/atomic_signal_fence.pass.cpp
new file mode 100644
index 00000000000..65e1d3813c9
--- /dev/null
+++ b/libcxx/test/atomics/atomics.fences/atomic_signal_fence.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// void atomic_signal_fence(memory_order m);
+
+#include <atomic>
+
+int main()
+{
+ std::atomic_signal_fence(std::memory_order_seq_cst);
+}
diff --git a/libcxx/test/atomics/atomics.fences/atomic_thread_fence.pass.cpp b/libcxx/test/atomics/atomics.fences/atomic_thread_fence.pass.cpp
new file mode 100644
index 00000000000..8c2abc0442e
--- /dev/null
+++ b/libcxx/test/atomics/atomics.fences/atomic_thread_fence.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// void atomic_thread_fence(memory_order m);
+
+#include <atomic>
+
+int main()
+{
+ std::atomic_thread_fence(std::memory_order_seq_cst);
+}
diff --git a/libcxx/test/atomics/atomics.lockfree/lockfree.pass.cpp b/libcxx/test/atomics/atomics.lockfree/lockfree.pass.cpp
new file mode 100644
index 00000000000..467f561eca8
--- /dev/null
+++ b/libcxx/test/atomics/atomics.lockfree/lockfree.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// #define ATOMIC_CHAR_LOCK_FREE unspecified
+// #define ATOMIC_CHAR16_T_LOCK_FREE unspecified
+// #define ATOMIC_CHAR32_T_LOCK_FREE unspecified
+// #define ATOMIC_WCHAR_T_LOCK_FREE unspecified
+// #define ATOMIC_SHORT_LOCK_FREE unspecified
+// #define ATOMIC_INT_LOCK_FREE unspecified
+// #define ATOMIC_LONG_LOCK_FREE unspecified
+// #define ATOMIC_LLONG_LOCK_FREE unspecified
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ assert(ATOMIC_CHAR_LOCK_FREE == 0 ||
+ ATOMIC_CHAR_LOCK_FREE == 1 ||
+ ATOMIC_CHAR_LOCK_FREE == 2);
+ assert(ATOMIC_CHAR16_T_LOCK_FREE == 0 ||
+ ATOMIC_CHAR16_T_LOCK_FREE == 1 ||
+ ATOMIC_CHAR16_T_LOCK_FREE == 2);
+ assert(ATOMIC_CHAR32_T_LOCK_FREE == 0 ||
+ ATOMIC_CHAR32_T_LOCK_FREE == 1 ||
+ ATOMIC_CHAR32_T_LOCK_FREE == 2);
+ assert(ATOMIC_WCHAR_T_LOCK_FREE == 0 ||
+ ATOMIC_WCHAR_T_LOCK_FREE == 1 ||
+ ATOMIC_WCHAR_T_LOCK_FREE == 2);
+ assert(ATOMIC_SHORT_LOCK_FREE == 0 ||
+ ATOMIC_SHORT_LOCK_FREE == 1 ||
+ ATOMIC_SHORT_LOCK_FREE == 2);
+ assert(ATOMIC_INT_LOCK_FREE == 0 ||
+ ATOMIC_INT_LOCK_FREE == 1 ||
+ ATOMIC_INT_LOCK_FREE == 2);
+ assert(ATOMIC_LONG_LOCK_FREE == 0 ||
+ ATOMIC_LONG_LOCK_FREE == 1 ||
+ ATOMIC_LONG_LOCK_FREE == 2);
+ assert(ATOMIC_LLONG_LOCK_FREE == 0 ||
+ ATOMIC_LLONG_LOCK_FREE == 1 ||
+ ATOMIC_LLONG_LOCK_FREE == 2);
+}
diff --git a/libcxx/test/atomics/atomics.types.generic/cstdint_typedefs.pass.cpp b/libcxx/test/atomics/atomics.types.generic/cstdint_typedefs.pass.cpp
new file mode 100644
index 00000000000..0ce127daf20
--- /dev/null
+++ b/libcxx/test/atomics/atomics.types.generic/cstdint_typedefs.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 atomic<int_least8_t> atomic_int_least8_t;
+// typedef atomic<uint_least8_t> atomic_uint_least8_t;
+// typedef atomic<int_least16_t> atomic_int_least16_t;
+// typedef atomic<uint_least16_t> atomic_uint_least16_t;
+// typedef atomic<int_least32_t> atomic_int_least32_t;
+// typedef atomic<uint_least32_t> atomic_uint_least32_t;
+// typedef atomic<int_least64_t> atomic_int_least64_t;
+// typedef atomic<uint_least64_t> atomic_uint_least64_t;
+//
+// typedef atomic<int_fast8_t> atomic_int_fast8_t;
+// typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
+// typedef atomic<int_fast16_t> atomic_int_fast16_t;
+// typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
+// typedef atomic<int_fast32_t> atomic_int_fast32_t;
+// typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
+// typedef atomic<int_fast64_t> atomic_int_fast64_t;
+// typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
+//
+// typedef atomic<intptr_t> atomic_intptr_t;
+// typedef atomic<uintptr_t> atomic_uintptr_t;
+// typedef atomic<size_t> atomic_size_t;
+// typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
+// typedef atomic<intmax_t> atomic_intmax_t;
+// typedef atomic<uintmax_t> atomic_uintmax_t;
+
+#include <atomic>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::atomic< std::int_least8_t>, std::atomic_int_least8_t>::value), "");
+ static_assert((std::is_same<std::atomic< std::uint_least8_t>, std::atomic_uint_least8_t>::value), "");
+ static_assert((std::is_same<std::atomic< std::int_least16_t>, std::atomic_int_least16_t>::value), "");
+ static_assert((std::is_same<std::atomic<std::uint_least16_t>, std::atomic_uint_least16_t>::value), "");
+ static_assert((std::is_same<std::atomic< std::int_least32_t>, std::atomic_int_least32_t>::value), "");
+ static_assert((std::is_same<std::atomic<std::uint_least32_t>, std::atomic_uint_least32_t>::value), "");
+ static_assert((std::is_same<std::atomic< std::int_least64_t>, std::atomic_int_least64_t>::value), "");
+ static_assert((std::is_same<std::atomic<std::uint_least64_t>, std::atomic_uint_least64_t>::value), "");
+
+ static_assert((std::is_same<std::atomic< std::int_fast8_t>, std::atomic_int_fast8_t>::value), "");
+ static_assert((std::is_same<std::atomic< std::uint_fast8_t>, std::atomic_uint_fast8_t>::value), "");
+ static_assert((std::is_same<std::atomic< std::int_fast16_t>, std::atomic_int_fast16_t>::value), "");
+ static_assert((std::is_same<std::atomic<std::uint_fast16_t>, std::atomic_uint_fast16_t>::value), "");
+ static_assert((std::is_same<std::atomic< std::int_fast32_t>, std::atomic_int_fast32_t>::value), "");
+ static_assert((std::is_same<std::atomic<std::uint_fast32_t>, std::atomic_uint_fast32_t>::value), "");
+ static_assert((std::is_same<std::atomic< std::int_fast64_t>, std::atomic_int_fast64_t>::value), "");
+ static_assert((std::is_same<std::atomic<std::uint_fast64_t>, std::atomic_uint_fast64_t>::value), "");
+
+ static_assert((std::is_same<std::atomic< std::intptr_t>, std::atomic_intptr_t>::value), "");
+ static_assert((std::is_same<std::atomic<std::uintptr_t>, std::atomic_uintptr_t>::value), "");
+ static_assert((std::is_same<std::atomic< std::size_t>, std::atomic_size_t>::value), "");
+ static_assert((std::is_same<std::atomic<std::ptrdiff_t>, std::atomic_ptrdiff_t>::value), "");
+ static_assert((std::is_same<std::atomic< std::intmax_t>, std::atomic_intmax_t>::value), "");
+ static_assert((std::is_same<std::atomic<std::uintmax_t>, std::atomic_uintmax_t>::value), "");
+}
diff --git a/libcxx/test/atomics/atomics.types.generic/integral_typedefs.pass.cpp b/libcxx/test/atomics/atomics.types.generic/integral_typedefs.pass.cpp
new file mode 100644
index 00000000000..c622d6e09bf
--- /dev/null
+++ b/libcxx/test/atomics/atomics.types.generic/integral_typedefs.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 atomic<char> atomic_char;
+// typedef atomic<signed char> atomic_schar;
+// typedef atomic<unsigned char> atomic_uchar;
+// typedef atomic<short> atomic_short;
+// typedef atomic<unsigned short> atomic_ushort;
+// typedef atomic<int> atomic_int;
+// typedef atomic<unsigned int> atomic_uint;
+// typedef atomic<long> atomic_long;
+// typedef atomic<unsigned long> atomic_ulong;
+// typedef atomic<long long> atomic_llong;
+// typedef atomic<unsigned long long> atomic_ullong;
+// typedef atomic<char16_t> atomic_char16_t;
+// typedef atomic<char32_t> atomic_char32_t;
+// typedef atomic<wchar_t> atomic_wchar_t;
+
+#include <atomic>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::atomic<char>, std::atomic_char>::value), "");
+ static_assert((std::is_same<std::atomic<signed char>, std::atomic_schar>::value), "");
+ static_assert((std::is_same<std::atomic<unsigned char>, std::atomic_uchar>::value), "");
+ static_assert((std::is_same<std::atomic<short>, std::atomic_short>::value), "");
+ static_assert((std::is_same<std::atomic<unsigned short>, std::atomic_ushort>::value), "");
+ static_assert((std::is_same<std::atomic<int>, std::atomic_int>::value), "");
+ static_assert((std::is_same<std::atomic<unsigned int>, std::atomic_uint>::value), "");
+ static_assert((std::is_same<std::atomic<long>, std::atomic_long>::value), "");
+ static_assert((std::is_same<std::atomic<unsigned long>, std::atomic_ulong>::value), "");
+ static_assert((std::is_same<std::atomic<long long>, std::atomic_llong>::value), "");
+ static_assert((std::is_same<std::atomic<unsigned long long>, std::atomic_ullong>::value), "");
+ static_assert((std::is_same<std::atomic<wchar_t>, std::atomic_wchar_t>::value), "");
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ static_assert((std::is_same<std::atomic<char16_t>, std::atomic_char16_t>::value), "");
+ static_assert((std::is_same<std::atomic<char32_t>, std::atomic_char32_t>::value), "");
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/libcxx/test/atomics/atomics.types.operations/atomics.types.operations.arith/nothing_to_do.pass.cpp b/libcxx/test/atomics/atomics.types.operations/atomics.types.operations.arith/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..9a59227abdd
--- /dev/null
+++ b/libcxx/test/atomics/atomics.types.operations/atomics.types.operations.arith/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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()
+{
+}
diff --git a/libcxx/test/atomics/atomics.types.operations/atomics.types.operations.general/nothing_to_do.pass.cpp b/libcxx/test/atomics/atomics.types.operations/atomics.types.operations.general/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..9a59227abdd
--- /dev/null
+++ b/libcxx/test/atomics/atomics.types.operations/atomics.types.operations.general/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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()
+{
+}
diff --git a/libcxx/test/atomics/atomics.types.operations/atomics.types.operations.pointer/nothing_to_do.pass.cpp b/libcxx/test/atomics/atomics.types.operations/atomics.types.operations.pointer/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..9a59227abdd
--- /dev/null
+++ b/libcxx/test/atomics/atomics.types.operations/atomics.types.operations.pointer/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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()
+{
+}
diff --git a/libcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp b/libcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp
new file mode 100644
index 00000000000..05b335f71f6
--- /dev/null
+++ b/libcxx/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// #define ATOMIC_VAR_INIT(value)
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ std::atomic<int> v = ATOMIC_VAR_INIT(5);
+ assert(v == 5);
+}
diff --git a/libcxx/test/atomics/atomics.types.operations/atomics.types.operations.templ/nothing_to_do.pass.cpp b/libcxx/test/atomics/atomics.types.operations/atomics.types.operations.templ/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..9a59227abdd
--- /dev/null
+++ b/libcxx/test/atomics/atomics.types.operations/atomics.types.operations.templ/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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()
+{
+}
diff --git a/libcxx/test/atomics/atomics.types.operations/nothing_to_do.pass.cpp b/libcxx/test/atomics/atomics.types.operations/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..9a59227abdd
--- /dev/null
+++ b/libcxx/test/atomics/atomics.types.operations/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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()
+{
+}
OpenPOWER on IntegriCloud