Compare commits

..

17 Commits

Author SHA1 Message Date
Howard Hinnant
8296d401e7 Tagging 13
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/tags/libcpp-13@122094 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-17 22:19:35 +00:00
Howard Hinnant
2d72b1e393 Effort to reduce the number of exported symbols
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@122057 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-17 14:46:43 +00:00
Howard Hinnant
e48e36623b Reduced copying cost of tuple_cat from quadratic to linear.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@121655 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-12 23:04:37 +00:00
Howard Hinnant
0e1493ec5e LWG 1385 [FCD] tuple_cat should be a single variadic signature (http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#1385). This issue is only in Ready status, meaning it is not official, but probably will be this March in Madrid. It was tentatively accepted in Batavia with the previso that Bill and I didn't have any problems implementing it. This is my part of that agreement.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@121619 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-11 20:47:50 +00:00
Howard Hinnant
eee7698bac The implementation of the new definition of result_of (N3123) resulted in some test failures in [func.memfn] that I failed to previously notice. This corrects that mistake.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@121600 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-11 00:05:19 +00:00
Michael J. Spencer
626916fc25 Add CMake build and fix major Linux blockers.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@121510 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-10 19:47:54 +00:00
Howard Hinnant
b8f787b188 Test adjustment for recent changes in allocator_traits
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@121503 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-10 19:22:37 +00:00
Howard Hinnant
f190e97885 This got accidentally removed
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@121502 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-10 19:22:00 +00:00
Howard Hinnant
31aaf55f4c N3158 Missing preconditions for default-constructed match_result objects
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@121282 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-08 21:07:55 +00:00
Howard Hinnant
1b18a48e28 cleaning up...
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@121275 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-08 20:09:09 +00:00
Howard Hinnant
770d1c4ea7 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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@121267 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-08 17:20:28 +00:00
Michael J. Spencer
c9f5d9fca6 test: Rename string_op+= to string_op_plus_equal. Windows git doesn't like it.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@121265 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-08 17:06:47 +00:00
Howard Hinnant
d2f6afbfab atomics ...
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@121204 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-07 23:24:41 +00:00
Howard Hinnant
57e5e87323 atomics ...
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@121203 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-07 23:24:09 +00:00
Howard Hinnant
f02417b600 atomics ...
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@121202 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-07 23:20:28 +00:00
Howard Hinnant
91e2f26fec Work on <atomic> continues. The file size is actually sane now...
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@121181 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-07 20:46:14 +00:00
Howard Hinnant
4777bf2799 Getting <atomic> warmed back up. We have a hopefully more stable spec now. And I believe the intrinsic spec at http://libcxx.llvm.org/atomic_design_a.html is still good.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@121064 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-06 23:10:08 +00:00
98 changed files with 4914 additions and 12577 deletions

159
CMakeLists.txt Normal file
View File

@@ -0,0 +1,159 @@
# See www/CMake.html for instructions on how to build libcxx with CMake.
#===============================================================================
# Setup Project
#===============================================================================
project(libcxx CXX C)
cmake_minimum_required(VERSION 2.8)
set(PACKAGE_NAME libcxx)
set(PACKAGE_VERSION trunk-svn)
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "llvmbugs@cs.uiuc.edu")
# Add path for custom modules
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
)
# Require out of source build.
include(MacroEnsureOutOfSourceBuild)
MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
"${PROJECT_NAME} requires an out of source build. Please create a separate
build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there."
)
#===============================================================================
# Setup CMake Options
#===============================================================================
# Define options.
option(LIBCXX_ENABLE_EXCEPTIONS "Use exceptions." ON)
option(LIBCXX_ENABLE_RTTI "Use run time type information." ON)
option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON)
option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
option(LIBCXX_ENABLE_CXX0X "Enable -std=c++0x and use of c++0x language features if the compiler supports it." ON)
option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
#===============================================================================
# Configure System
#===============================================================================
# Get triples.
include(GetTriple)
get_host_triple(LIBCXX_HOST_TRIPLE
LIBCXX_HOST_ARCH
LIBCXX_HOST_VENDOR
LIBCXX_HOST_OS
)
set(LIBCXX_HOST_TRIPLE ${LIBCXX_HOST_TRIPLE} CACHE STRING "Host triple.")
get_target_triple(LIBCXX_TARGET_TRIPLE
LIBCXX_TARGET_ARCH
LIBCXX_TARGET_VENDOR
LIBCXX_TARGET_OS
)
set(LIBCXX_TARGET_TRIPLE ${LIBCXX_TARGET_TRIPLE} CACHE STRING "Target triple.")
# Configure compiler.
include(config-ix)
#===============================================================================
# Setup Compiler Flags
#===============================================================================
# Get required flags.
# On all systems the system c++ standard library headers need to be excluded.
if (MSVC)
# MSVC only has -X, which disables all default includes; including the crt.
# Thus, we do nothing and hope we don't accidentally include any of the C++
# headers.
else()
if (LIBCXX_HAS_NOSTDINCXX_FLAG)
set(LIBCXX_CXX_REQUIRED_FLAGS -nostdinc++)
endif()
if (LIBCXX_ENABLE_CXX0X AND LIBCXX_HAS_STDCXX0X_FLAG)
list(APPEND LIBCXX_CXX_REQUIRED_FLAGS -std=c++0x)
endif()
endif()
macro(append_if list condition var)
if (${condition})
list(APPEND ${list} ${var})
endif()
endmacro()
# Get warning flags
append_if(LIBCXX_WARNING_FLAGS LIBCXX_HAS_WALL_FLAG -Wall)
append_if(LIBCXX_WARNING_FLAGS LIBCXX_HAS_W_FLAG -W)
append_if(LIBCXX_WARNING_FLAGS LIBCXX_HAS_WNO_UNUSED_PARAMETER_FLAG -Wno-unused-parameter)
append_if(LIBCXX_WARNING_FLAGS LIBCXX_HAS_WWRITE_STRINGS_FLAG -Wwrite-strings)
append_if(LIBCXX_WARNING_FLAGS LIBCXX_HAS_WNO_LONG_LONG_FLAG -Wno-long-long)
if (LIBCXX_ENABLE_WERROR)
append_if(LIBCXX_WARNING_FLAGS LIBCXX_HAS_WERROR_FLAG -Werror)
append_if(LIBCXX_WARNING_FLAGS LIBCXX_HAS_WX_FLAG -WX)
endif()
if (LIBCXX_ENABLE_PEDANTIC)
append_if(LIBCXX_WARNING_FLAGS LIBCXX_HAS_PEDANTIC_FLAG -pedantic)
endif()
# Get feature flags.
# Exceptions
if (LIBCXX_ENABLE_EXCEPTIONS)
# Catches C++ exceptions only and tells the compiler to assume that extern C
# functions never throw a C++ exception.
append_if(LIBCXX_CXX_FEATURE_FLAGS LIBCXX_HAS_EHSC_FLAG -EHsc)
else()
list(APPEND LIBCXX_CXX_FEATURE_FLAGS -D_LIBCPP_NO_EXCEPTIONS)
append_if(LIBCXX_CXX_FEATURE_FLAGS LIBCXX_HAS_NO_EHS_FLAG -EHs-)
append_if(LIBCXX_CXX_FEATURE_FLAGS LIBCXX_HAS_NO_EHA_FLAG -EHa-)
append_if(LIBCXX_CXX_FEATURE_FLAGS LIBCXX_HAS_FNO_EXCEPTIONS_FLAG -fno-exceptions)
endif()
# RTTI
if (NOT LIBCXX_ENABLE_RTTI)
list(APPEND LIBCXX_CXX_FEATURE_FLAGS -D_LIBCPP_NO_RTTI)
append_if(LIBCXX_CXX_FEATURE_FLAGS LIBCXX_HAS_NO_GR_FLAG -GR-)
append_if(LIBCXX_CXX_FEATURE_FLAGS LIBCXX_HAS_FNO_RTTI_FLAG -fno-rtti)
endif()
# Assert
if (LLVM_ENABLE_ASSERTIONS)
# MSVC doesn't like _DEBUG on release builds. See PR 4379.
if (NOT MSVC)
list(APPEND LIBCXX_CXX_FEATURE_FLAGS -D_DEBUG)
endif()
# On Release builds cmake automatically defines NDEBUG, so we
# explicitly undefine it:
if (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
list(APPEND LIBCXX_CXX_FEATURE_FLAGS -UNDEBUG)
endif()
else()
if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
list(APPEND LIBCXX_CXX_FEATURE_FLAGS -DNDEBUG)
endif()
endif()
# This is the _ONLY_ place where add_definitions is called.
add_definitions(
${LIBCXX_CXX_REQUIRED_FLAGS}
${LIBCXX_CXX_WARNING_FLAGS}
${LIBCXX_CXX_FEATURE_FLAGS}
)
#===============================================================================
# Setup Source Code
#===============================================================================
include_directories(include)
# Add source code. This also contains all of the logic for deciding linker flags
# soname, etc...
add_subdirectory(lib)
#===============================================================================
# Setup Tests
#===============================================================================
add_subdirectory(test)

View File

@@ -0,0 +1,53 @@
# Define functions to get the host and target triple.
function(get_host_triple out out_arch out_vendor out_os)
# Get the architecture.
set(arch ${CMAKE_HOST_SYSTEM_PROCESSOR})
if (arch STREQUAL "x86")
set(arch "i686")
endif()
# Get the vendor.
if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin")
set(vendor "apple")
else()
set(vendor "pc")
endif()
# Get os.
if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
set(os "win32")
else()
string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} os)
endif()
set(triple "${arch}-${vendor}-${os}")
set(${out} ${triple} PARENT_SCOPE)
set(${out_arch} ${arch} PARENT_SCOPE)
set(${out_vendor} ${vendor} PARENT_SCOPE)
set(${out_os} ${os} PARENT_SCOPE)
message(STATUS "Host triple: ${triple}")
endfunction()
function(get_target_triple out out_arch out_vendor out_os)
# Get the architecture.
set(arch ${CMAKE_SYSTEM_PROCESSOR})
if (arch STREQUAL "x86")
set(arch "i686")
endif()
# Get the vendor.
if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(vendor "apple")
else()
set(vendor "pc")
endif()
# Get os.
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
set(os "win32")
else()
string(TOLOWER ${CMAKE_SYSTEM_NAME} os)
endif()
set(triple "${arch}-${vendor}-${os}")
set(${out} ${triple} PARENT_SCOPE)
set(${out_arch} ${arch} PARENT_SCOPE)
set(${out_vendor} ${vendor} PARENT_SCOPE)
set(${out_os} ${os} PARENT_SCOPE)
message(STATUS "Target triple: ${triple}")
endfunction()

View File

@@ -0,0 +1,18 @@
# MACRO_ENSURE_OUT_OF_SOURCE_BUILD(<errorMessage>)
macro( MACRO_ENSURE_OUT_OF_SOURCE_BUILD _errorMessage )
string( COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" _insource )
if( _insource )
message( SEND_ERROR "${_errorMessage}" )
message( FATAL_ERROR
"In-source builds are not allowed.
CMake would overwrite the makefiles distributed with Compiler-RT.
Please create a directory and run cmake from there, passing the path
to this source directory as the last argument.
This process created the file `CMakeCache.txt' and the directory `CMakeFiles'.
Please delete them."
)
endif( _insource )
endmacro( MACRO_ENSURE_OUT_OF_SOURCE_BUILD )

37
cmake/config-ix.cmake Normal file
View File

@@ -0,0 +1,37 @@
include(CheckLibraryExists)
include(CheckCXXCompilerFlag)
# Check compiler flags
check_cxx_compiler_flag(-std=c++0x LIBCXX_HAS_STDCXX0X_FLAG)
check_cxx_compiler_flag(-fPIC LIBCXX_HAS_FPIC_FLAG)
check_cxx_compiler_flag(-nodefaultlibs LIBCXX_HAS_NODEFAULTLIBS_FLAG)
check_cxx_compiler_flag(-nostdinc++ LIBCXX_HAS_NOSTDINCXX_FLAG)
check_cxx_compiler_flag(-Wall LIBCXX_HAS_WALL_FLAG)
check_cxx_compiler_flag(-W LIBCXX_HAS_W_FLAG)
check_cxx_compiler_flag(-Wno-unused-parameter LIBCXX_HAS_WNO_UNUSED_PARAMETER_FLAG)
check_cxx_compiler_flag(-Wwrite-strings LIBCXX_HAS_WWRITE_STRINGS_FLAG)
check_cxx_compiler_flag(-Wno-long-long LIBCXX_HAS_WNO_LONG_LONG_FLAG)
check_cxx_compiler_flag(-pedantic LIBCXX_HAS_PEDANTIC_FLAG)
check_cxx_compiler_flag(-Werror LIBCXX_HAS_WERROR_FLAG)
check_cxx_compiler_flag(-fno-exceptions LIBCXX_HAS_FNO_EXCEPTIONS_FLAG)
check_cxx_compiler_flag(-fno-rtti LIBCXX_HAS_FNO_RTTI_FLAG)
check_cxx_compiler_flag(/WX LIBCXX_HAS_WX_FLAG)
check_cxx_compiler_flag(/EHsc LIBCXX_HAS_EHSC_FLAG)
check_cxx_compiler_flag(/EHs- LIBCXX_HAS_NO_EHS_FLAG)
check_cxx_compiler_flag(/EHa- LIBCXX_HAS_NO_EHA_FLAG)
check_cxx_compiler_flag(/GR- LIBCXX_HAS_NO_GR_FLAG)
# Check libraries
check_library_exists(pthread pthread_create "" LIBCXX_HAS_PTHREAD_LIB)
check_library_exists(c printf "" LIBCXX_HAS_C_LIB)
check_library_exists(m ccos "" LIBCXX_HAS_M_LIB)
check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB)
# Check C++0x features
if (LIBCXX_ENABLE_CXX0X)
if (LIBCXX_HAS_STDCXX0X_FLAG)
set(CMAKE_REQUIRED_DEFINITIONS -std=c++0x)
endif()
else()
set(LIBCXX_HAS_STDCXX0X_FLAG FALSE)
endif()

View File

@@ -82,7 +82,7 @@
#define _LIBCPP_CANTTHROW __attribute__ ((__nothrow__))
#define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__))
#if defined(__clang__)
@@ -214,6 +214,7 @@ using namespace _LIBCPP_NAMESPACE;
#endif // !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 4)
#if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 6)
#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
#define _LIBCPP_HAS_NO_NULLPTR
#endif

View File

@@ -55,7 +55,8 @@ public:
explicit locale(const string&);
locale(const locale&, const char*, category);
locale(const locale&, const string&, category);
template <class _Facet> locale(const locale&, _Facet*);
template <class _Facet>
_LIBCPP_INLINE_VISIBILITY locale(const locale&, _Facet*);
locale(const locale&, const locale&, category);
~locale() throw();

View File

@@ -85,12 +85,14 @@ public:
void shrink_to_fit();
void push_front(const_reference __x);
void push_back(const_reference __x);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
void push_front(value_type&& __x);
void push_back(value_type&& __x);
#if !defined(_LIBCPP_HAS_NO_VARIADICS)
template <class... _Args>
void emplace_back(_Args&&... __args);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#endif // !defined(_LIBCPP_HAS_NO_VARIADICS)
#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
_LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);}
_LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);}

View File

@@ -68,12 +68,13 @@ template <class _Tp, size_t _Size> struct _LIBCPP_VISIBLE array;
template <class _Tp> struct __tuple_like : false_type {};
template <class _Tp> struct __tuple_like<const _Tp> : public __tuple_like<_Tp> {};
template <class _Tp> struct __tuple_like<volatile _Tp> : public __tuple_like<_Tp> {};
template <class _Tp> struct __tuple_like<const volatile _Tp> : public __tuple_like<_Tp> {};
template <class... _Tp> struct __tuple_like<tuple<_Tp...>> : true_type {};
template <class... _Tp> struct __tuple_like<const tuple<_Tp...>> : true_type {};
template <class _T1, class _T2> struct __tuple_like<pair<_T1, _T2> > : true_type {};
template <class _T1, class _T2> struct __tuple_like<const pair<_T1, _T2> > : true_type {};
template <class _Tp, size_t _Size> struct __tuple_like<array<_Tp, _Size> > : true_type {};
template <class _Tp, size_t _Size> struct __tuple_like<const array<_Tp, _Size> > : true_type {};
template <size_t _Ip, class ..._Tp>
typename tuple_element<_Ip, tuple<_Tp...>>::type&

File diff suppressed because it is too large Load Diff

View File

@@ -272,16 +272,16 @@ public:
class Init;
// 27.5.2.2 fmtflags state:
fmtflags flags() const;
fmtflags flags(fmtflags __fmtfl);
fmtflags setf(fmtflags __fmtfl);
fmtflags setf(fmtflags __fmtfl, fmtflags __mask);
void unsetf(fmtflags __mask);
_LIBCPP_INLINE_VISIBILITY fmtflags flags() const;
_LIBCPP_INLINE_VISIBILITY fmtflags flags(fmtflags __fmtfl);
_LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl);
_LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl, fmtflags __mask);
_LIBCPP_INLINE_VISIBILITY void unsetf(fmtflags __mask);
streamsize precision() const;
streamsize precision(streamsize __prec);
streamsize width() const;
streamsize width(streamsize __wide);
_LIBCPP_INLINE_VISIBILITY streamsize precision() const;
_LIBCPP_INLINE_VISIBILITY streamsize precision(streamsize __prec);
_LIBCPP_INLINE_VISIBILITY streamsize width() const;
_LIBCPP_INLINE_VISIBILITY streamsize width(streamsize __wide);
// 27.5.2.3 locales:
locale imbue(const locale& __loc);
@@ -307,17 +307,17 @@ private:
public:
static bool sync_with_stdio(bool __sync = true);
iostate rdstate() const;
_LIBCPP_INLINE_VISIBILITY iostate rdstate() const;
void clear(iostate __state = goodbit);
void setstate(iostate __state);
_LIBCPP_INLINE_VISIBILITY void setstate(iostate __state);
bool good() const;
bool eof() const;
bool fail() const;
bool bad() const;
_LIBCPP_INLINE_VISIBILITY bool good() const;
_LIBCPP_INLINE_VISIBILITY bool eof() const;
_LIBCPP_INLINE_VISIBILITY bool fail() const;
_LIBCPP_INLINE_VISIBILITY bool bad() const;
iostate exceptions() const;
void exceptions(iostate __except);
_LIBCPP_INLINE_VISIBILITY iostate exceptions() const;
_LIBCPP_INLINE_VISIBILITY void exceptions(iostate __except);
void __set_badbit_and_consider_rethrow();
void __set_failbit_and_consider_rethrow();
@@ -587,38 +587,52 @@ public:
_LIBCPP_ALWAYS_INLINE void exceptions(iostate __except) {ios_base::exceptions(__except);}
// 27.5.4.1 Constructor/destructor:
_LIBCPP_INLINE_VISIBILITY
explicit basic_ios(basic_streambuf<char_type,traits_type>* __sb);
virtual ~basic_ios();
// 27.5.4.2 Members:
_LIBCPP_INLINE_VISIBILITY
basic_ostream<char_type, traits_type>* tie() const;
_LIBCPP_INLINE_VISIBILITY
basic_ostream<char_type, traits_type>* tie(basic_ostream<char_type, traits_type>* __tiestr);
_LIBCPP_INLINE_VISIBILITY
basic_streambuf<char_type, traits_type>* rdbuf() const;
_LIBCPP_INLINE_VISIBILITY
basic_streambuf<char_type, traits_type>* rdbuf(basic_streambuf<char_type, traits_type>* __sb);
basic_ios& copyfmt(const basic_ios& __rhs);
_LIBCPP_INLINE_VISIBILITY
char_type fill() const;
_LIBCPP_INLINE_VISIBILITY
char_type fill(char_type __ch);
_LIBCPP_INLINE_VISIBILITY
locale imbue(const locale& __loc);
_LIBCPP_INLINE_VISIBILITY
char narrow(char_type __c, char __dfault) const;
_LIBCPP_INLINE_VISIBILITY
char_type widen(char __c) const;
protected:
_LIBCPP_ALWAYS_INLINE
basic_ios() {// purposefully does no initialization
}
_LIBCPP_INLINE_VISIBILITY
void init(basic_streambuf<char_type, traits_type>* __sb);
_LIBCPP_INLINE_VISIBILITY
void move(basic_ios& __rhs);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_ALWAYS_INLINE
void move(basic_ios&& __rhs) {move(__rhs);}
#endif
_LIBCPP_INLINE_VISIBILITY
void swap(basic_ios& __rhs);
_LIBCPP_INLINE_VISIBILITY
void set_rdbuf(basic_streambuf<char_type, traits_type>* __sb);
private:
basic_ostream<char_type, traits_type>* __tie_;

View File

@@ -265,7 +265,10 @@ __nolocale_isdigit(int __c)
}
#else // __APPLE__
inline _LIBCPP_INLINE_VISIBILITY
inline
#ifndef _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
_LIBCPP_INLINE_VISIBILITY
#endif
int
__nolocale_sprintf(char* __restrict __str,
const char* __restrict __format, ...)
@@ -276,7 +279,10 @@ __nolocale_sprintf(char* __restrict __str,
va_end(__ap);
return __result;
}
inline _LIBCPP_INLINE_VISIBILITY
inline
#ifndef _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
_LIBCPP_INLINE_VISIBILITY
#endif
int
__nolocale_snprintf(char* __restrict __str, size_t __size,
const char* __restrict __format, ...)
@@ -287,7 +293,10 @@ __nolocale_snprintf(char* __restrict __str, size_t __size,
va_end(__ap);
return __result;
}
inline _LIBCPP_INLINE_VISIBILITY
inline
#ifndef _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
_LIBCPP_INLINE_VISIBILITY
#endif
int
__nolocale_asprintf(char** __ret,
const char* __restrict __format, ...)
@@ -298,7 +307,10 @@ __nolocale_asprintf(char** __ret,
va_end(__ap);
return __result;
}
inline _LIBCPP_INLINE_VISIBILITY
inline
#ifndef _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
_LIBCPP_INLINE_VISIBILITY
#endif
int
__nolocale_sscanf(const char* __restrict __str,
const char* __restrict __format, ...)
@@ -1756,7 +1768,7 @@ public:
};
template <class _CharT>
class __time_get_c_storage
class __time_get_c_storage // purposefully not decorated
{
protected:
typedef basic_string<_CharT> string_type;
@@ -2638,24 +2650,15 @@ protected:
_LIBCPP_ALWAYS_INLINE
~moneypunct() {}
_LIBCPP_ALWAYS_INLINE
virtual char_type do_decimal_point() const {return numeric_limits<char_type>::max();}
_LIBCPP_ALWAYS_INLINE
virtual char_type do_thousands_sep() const {return numeric_limits<char_type>::max();}
_LIBCPP_ALWAYS_INLINE
virtual string do_grouping() const {return string();}
_LIBCPP_ALWAYS_INLINE
virtual string_type do_curr_symbol() const {return string_type();}
_LIBCPP_ALWAYS_INLINE
virtual string_type do_positive_sign() const {return string_type();}
_LIBCPP_ALWAYS_INLINE
virtual string_type do_negative_sign() const {return string_type(1, '-');}
_LIBCPP_ALWAYS_INLINE
virtual int do_frac_digits() const {return 0;}
_LIBCPP_ALWAYS_INLINE
virtual pattern do_pos_format() const
{pattern __p = {symbol, sign, none, value}; return __p;}
_LIBCPP_ALWAYS_INLINE
virtual pattern do_neg_format() const
{pattern __p = {symbol, sign, none, value}; return __p;}
};
@@ -2692,23 +2695,14 @@ protected:
_LIBCPP_ALWAYS_INLINE
~moneypunct_byname() {}
_LIBCPP_ALWAYS_INLINE
virtual char_type do_decimal_point() const {return __decimal_point_;}
_LIBCPP_ALWAYS_INLINE
virtual char_type do_thousands_sep() const {return __thousands_sep_;}
_LIBCPP_ALWAYS_INLINE
virtual string do_grouping() const {return __grouping_;}
_LIBCPP_ALWAYS_INLINE
virtual string_type do_curr_symbol() const {return __curr_symbol_;}
_LIBCPP_ALWAYS_INLINE
virtual string_type do_positive_sign() const {return __positive_sign_;}
_LIBCPP_ALWAYS_INLINE
virtual string_type do_negative_sign() const {return __negative_sign_;}
_LIBCPP_ALWAYS_INLINE
virtual int do_frac_digits() const {return __frac_digits_;}
_LIBCPP_ALWAYS_INLINE
virtual pattern do_pos_format() const {return __pos_format_;}
_LIBCPP_ALWAYS_INLINE
virtual pattern do_neg_format() const {return __neg_format_;}
private:

View File

@@ -1487,7 +1487,7 @@ struct _LIBCPP_VISIBLE uses_allocator
{
};
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
// uses-allocator construction
@@ -1505,7 +1505,7 @@ struct __uses_alloc_ctor
: integral_constant<int, __uses_alloc_ctor_imp<_Tp, _Alloc, _Args...>::value>
{};
#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
// allocator
@@ -1546,6 +1546,7 @@ public:
{
::new((void*)__p) _Tp();
}
# if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
template <class _A0>
_LIBCPP_INLINE_VISIBILITY
typename enable_if
@@ -1579,6 +1580,7 @@ public:
{
::new((void*)__p) _Tp(_STD::move(__a0));
}
# endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
void

View File

@@ -208,6 +208,8 @@ public:
bool matched;
constexpr sub_match();
difference_type length() const;
operator string_type() const;
string_type str() const;
@@ -452,6 +454,8 @@ public:
match_results& operator=(match_results&& m);
~match_results();
bool ready() const;
// size:
size_type size() const;
size_type max_size() const;
@@ -4683,6 +4687,9 @@ public:
bool matched;
_LIBCPP_INLINE_VISIBILITY
/*constexpr*/ sub_match() : matched() {}
_LIBCPP_INLINE_VISIBILITY
difference_type length() const
{return matched ? _STD::distance(this->first, this->second) : 0;}
@@ -5104,6 +5111,7 @@ private:
value_type __unmatched_;
value_type __prefix_;
value_type __suffix_;
bool __ready_;
public:
_BidirectionalIterator __position_start_;
typedef const value_type& const_reference;
@@ -5123,6 +5131,9 @@ public:
// match_results& operator=(match_results&& __m) = default;
// ~match_results() = default;
_LIBCPP_INLINE_VISIBILITY
bool ready() const {return __ready_;}
// size:
_LIBCPP_INLINE_VISIBILITY
size_type size() const {return __matches_.size();}
@@ -5224,6 +5235,7 @@ public:
__suffix_.matched = __m.suffix().matched;
if (!__no_update_pos)
__position_start_ = __prefix_.first;
__ready_ = __m.ready();
}
private:
@@ -5254,7 +5266,8 @@ match_results<_BidirectionalIterator, _Allocator>::match_results(
__unmatched_(),
__prefix_(),
__suffix_(),
__position_start_()
__position_start_(),
__ready_(false)
{
}
@@ -5274,6 +5287,7 @@ match_results<_BidirectionalIterator, _Allocator>::__init(unsigned __s,
__suffix_ = __unmatched_;
if (!__no_update_pos)
__position_start_ = __prefix_.first;
__ready_ = true;
}
template <class _BidirectionalIterator, class _Allocator>
@@ -5379,6 +5393,7 @@ match_results<_BidirectionalIterator, _Allocator>::swap(match_results& __m)
swap(__prefix_, __m.__prefix_);
swap(__suffix_, __m.__suffix_);
swap(__position_start_, __m.__position_start_);
swap(__ready_, __m.__ready_);
}
typedef match_results<const char*> cmatch;
@@ -5391,10 +5406,13 @@ bool
operator==(const match_results<_BidirectionalIterator, _Allocator>& __x,
const match_results<_BidirectionalIterator, _Allocator>& __y)
{
if (__x.__ready_ != __y.__ready_)
return false;
if (!__x.__ready_)
return true;
return __x.__matches_ == __y.__matches_ &&
__x.__prefix_ == __y.__prefix_ &&
__x.__suffix_ == __y.__suffix_ &&
__x.__position_start_ == __y.__position_start_;
__x.__suffix_ == __y.__suffix_;
}
template <class _BidirectionalIterator, class _Allocator>

View File

@@ -1028,33 +1028,43 @@ private:
public:
static const size_type npos = -1;
basic_string();
explicit basic_string(const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY basic_string();
_LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a);
basic_string(const basic_string& __str);
basic_string(const basic_string& __str, const allocator_type& __a);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
basic_string(basic_string&& __str);
basic_string(basic_string&& __str, const allocator_type& __a);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
basic_string(const_pointer __s);
_LIBCPP_INLINE_VISIBILITY basic_string(const_pointer __s);
_LIBCPP_INLINE_VISIBILITY
basic_string(const_pointer __s, const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY
basic_string(const_pointer __s, size_type __n);
_LIBCPP_INLINE_VISIBILITY
basic_string(const_pointer __s, size_type __n, const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY
basic_string(size_type __n, value_type __c);
_LIBCPP_INLINE_VISIBILITY
basic_string(size_type __n, value_type __c, const allocator_type& __a);
basic_string(const basic_string& __str, size_type __pos, size_type __n = npos,
const allocator_type& __a = allocator_type());
template<class _InputIterator>
_LIBCPP_INLINE_VISIBILITY
basic_string(_InputIterator __first, _InputIterator __last);
template<class _InputIterator>
_LIBCPP_INLINE_VISIBILITY
basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY
basic_string(initializer_list<value_type> __il);
_LIBCPP_INLINE_VISIBILITY
basic_string(initializer_list<value_type> __il, const allocator_type& __a);
~basic_string();
basic_string& operator=(const basic_string& __str);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
basic_string& operator=(basic_string&& __str);
#endif
_LIBCPP_INLINE_VISIBILITY basic_string& operator=(const_pointer __s) {return assign(__s);}
@@ -1086,7 +1096,7 @@ public:
_LIBCPP_INLINE_VISIBILITY size_type size() const
{return __is_long() ? __get_long_size() : __get_short_size();}
_LIBCPP_INLINE_VISIBILITY size_type length() const {return size();}
size_type max_size() const;
_LIBCPP_INLINE_VISIBILITY size_type max_size() const;
_LIBCPP_INLINE_VISIBILITY size_type capacity() const
{return (__is_long() ? __get_long_cap() : __min_cap) - 1;}
@@ -1096,6 +1106,7 @@ public:
void reserve(size_type res_arg = 0);
_LIBCPP_INLINE_VISIBILITY
void shrink_to_fit() {reserve();}
_LIBCPP_INLINE_VISIBILITY
void clear();
_LIBCPP_INLINE_VISIBILITY bool empty() const {return size() == 0;}
@@ -1110,6 +1121,7 @@ public:
_LIBCPP_INLINE_VISIBILITY basic_string& operator+=(value_type __c) {push_back(__c); return *this;}
_LIBCPP_INLINE_VISIBILITY basic_string& operator+=(initializer_list<value_type> __il) {return append(__il);}
_LIBCPP_INLINE_VISIBILITY
basic_string& append(const basic_string& __str);
basic_string& append(const basic_string& __str, size_type __pos, size_type __n);
basic_string& append(const_pointer __s, size_type __n);
@@ -1134,12 +1146,14 @@ public:
basic_string& append(initializer_list<value_type> __il) {return append(__il.begin(), __il.size());}
void push_back(value_type __c);
_LIBCPP_INLINE_VISIBILITY
void pop_back();
reference front();
const_reference front() const;
reference back();
const_reference back() const;
_LIBCPP_INLINE_VISIBILITY reference front();
_LIBCPP_INLINE_VISIBILITY const_reference front() const;
_LIBCPP_INLINE_VISIBILITY reference back();
_LIBCPP_INLINE_VISIBILITY const_reference back() const;
_LIBCPP_INLINE_VISIBILITY
basic_string& assign(const basic_string& __str);
basic_string& assign(const basic_string& __str, size_type __pos, size_type __n);
basic_string& assign(const_pointer __s, size_type __n);
@@ -1163,12 +1177,14 @@ public:
_LIBCPP_INLINE_VISIBILITY
basic_string& assign(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}
_LIBCPP_INLINE_VISIBILITY
basic_string& insert(size_type __pos1, const basic_string& __str);
basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n);
basic_string& insert(size_type __pos, const_pointer __s, size_type __n);
basic_string& insert(size_type __pos, const_pointer __s);
basic_string& insert(size_type __pos, size_type __n, value_type __c);
iterator insert(const_iterator __pos, value_type __c);
_LIBCPP_INLINE_VISIBILITY
iterator insert(const_iterator __pos, size_type __n, value_type __c);
template<class _InputIterator>
typename enable_if
@@ -1190,17 +1206,24 @@ public:
{return insert(__pos, __il.begin(), __il.end());}
basic_string& erase(size_type __pos = 0, size_type __n = npos);
_LIBCPP_INLINE_VISIBILITY
iterator erase(const_iterator __pos);
_LIBCPP_INLINE_VISIBILITY
iterator erase(const_iterator __first, const_iterator __last);
_LIBCPP_INLINE_VISIBILITY
basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str);
basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2);
basic_string& replace(size_type __pos, size_type __n1, const_pointer __s, size_type __n2);
basic_string& replace(size_type __pos, size_type __n1, const_pointer __s);
basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c);
_LIBCPP_INLINE_VISIBILITY
basic_string& replace(const_iterator __i1, const_iterator __i2, const basic_string& __str);
_LIBCPP_INLINE_VISIBILITY
basic_string& replace(const_iterator __i1, const_iterator __i2, const_pointer __s, size_type __n);
_LIBCPP_INLINE_VISIBILITY
basic_string& replace(const_iterator __i1, const_iterator __i2, const_pointer __s);
_LIBCPP_INLINE_VISIBILITY
basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c);
template<class _InputIterator>
typename enable_if
@@ -1214,8 +1237,10 @@ public:
{return replace(__i1, __i2, __il.begin(), __il.end());}
size_type copy(pointer __s, size_type __n, size_type __pos = 0) const;
_LIBCPP_INLINE_VISIBILITY
basic_string substr(size_type __pos = 0, size_type __n = npos) const;
_LIBCPP_INLINE_VISIBILITY
void swap(basic_string& __str);
_LIBCPP_INLINE_VISIBILITY const_pointer c_str() const {return data();}
@@ -1223,44 +1248,62 @@ public:
_LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const {return __alloc();}
_LIBCPP_INLINE_VISIBILITY
size_type find(const basic_string& __str, size_type __pos = 0) const;
size_type find(const_pointer __s, size_type __pos, size_type __n) const;
_LIBCPP_INLINE_VISIBILITY
size_type find(const_pointer __s, size_type __pos = 0) const;
size_type find(value_type __c, size_type __pos = 0) const;
_LIBCPP_INLINE_VISIBILITY
size_type rfind(const basic_string& __str, size_type __pos = npos) const;
size_type rfind(const_pointer __s, size_type __pos, size_type __n) const;
_LIBCPP_INLINE_VISIBILITY
size_type rfind(const_pointer __s, size_type __pos = npos) const;
size_type rfind(value_type __c, size_type __pos = npos) const;
_LIBCPP_INLINE_VISIBILITY
size_type find_first_of(const basic_string& __str, size_type __pos = 0) const;
size_type find_first_of(const_pointer __s, size_type __pos, size_type __n) const;
_LIBCPP_INLINE_VISIBILITY
size_type find_first_of(const_pointer __s, size_type __pos = 0) const;
_LIBCPP_INLINE_VISIBILITY
size_type find_first_of(value_type __c, size_type __pos = 0) const;
_LIBCPP_INLINE_VISIBILITY
size_type find_last_of(const basic_string& __str, size_type __pos = npos) const;
size_type find_last_of(const_pointer __s, size_type __pos, size_type __n) const;
_LIBCPP_INLINE_VISIBILITY
size_type find_last_of(const_pointer __s, size_type __pos = npos) const;
_LIBCPP_INLINE_VISIBILITY
size_type find_last_of(value_type __c, size_type __pos = npos) const;
_LIBCPP_INLINE_VISIBILITY
size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const;
size_type find_first_not_of(const_pointer __s, size_type __pos, size_type __n) const;
_LIBCPP_INLINE_VISIBILITY
size_type find_first_not_of(const_pointer __s, size_type __pos = 0) const;
_LIBCPP_INLINE_VISIBILITY
size_type find_first_not_of(value_type __c, size_type __pos = 0) const;
_LIBCPP_INLINE_VISIBILITY
size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const;
size_type find_last_not_of(const_pointer __s, size_type __pos, size_type __n) const;
_LIBCPP_INLINE_VISIBILITY
size_type find_last_not_of(const_pointer __s, size_type __pos = npos) const;
_LIBCPP_INLINE_VISIBILITY
size_type find_last_not_of(value_type __c, size_type __pos = npos) const;
_LIBCPP_INLINE_VISIBILITY
int compare(const basic_string& __str) const;
_LIBCPP_INLINE_VISIBILITY
int compare(size_type __pos1, size_type __n1, const basic_string& __str) const;
int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2) const;
int compare(const_pointer __s) const;
int compare(size_type __pos1, size_type __n1, const_pointer __s) const;
int compare(size_type __pos1, size_type __n1, const_pointer __s, size_type __n2) const;
bool __invariants() const;
_LIBCPP_INLINE_VISIBILITY bool __invariants() const;
private:
_LIBCPP_INLINE_VISIBILITY allocator_type& __alloc() {return __r_.second();}
_LIBCPP_INLINE_VISIBILITY const allocator_type& __alloc() const {return __r_.second();}
@@ -1338,6 +1381,7 @@ private:
size_type __n_copy, size_type __n_del,
size_type __n_add, const_pointer __p_new_stuff);
_LIBCPP_INLINE_VISIBILITY
void __erase_to_end(size_type __pos);
_LIBCPP_INLINE_VISIBILITY
@@ -1361,7 +1405,9 @@ private:
{}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
void __move_assign(basic_string& __str, false_type);
_LIBCPP_INLINE_VISIBILITY
void __move_assign(basic_string& __str, true_type);
#endif
@@ -1380,8 +1426,8 @@ private:
static void __swap_alloc(allocator_type& __x, allocator_type& __y, false_type)
{}
void __invalidate_all_iterators();
void __invalidate_iterators_past(size_type);
_LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
_LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(size_type);
friend basic_string operator+<>(const basic_string&, const basic_string&);
friend basic_string operator+<>(const value_type*, const basic_string&);
@@ -1741,7 +1787,6 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(initializer_list<value_t
}
template <class _CharT, class _Traits, class _Allocator>
_LIBCPP_INLINE_VISIBILITY inline
basic_string<_CharT, _Traits, _Allocator>::~basic_string()
{
__invalidate_all_iterators();
@@ -3204,6 +3249,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type _
// __invariants
template<class _CharT, class _Traits, class _Allocator>
_LIBCPP_INLINE_VISIBILITY inline
bool
basic_string<_CharT, _Traits, _Allocator>::__invariants() const
{

View File

@@ -297,7 +297,7 @@ public:
class __assoc_sub_state;
class __thread_struct_imp;
class _LIBCPP_HIDDEN __thread_struct_imp;
class __thread_struct
{

View File

@@ -74,11 +74,8 @@ const unspecified ignore;
template <class... T> tuple<V...> make_tuple(T&&...);
template <class... T> tuple<ATypes...> forward_as_tuple(T&&...);
template <class... T> tuple<T&...> tie(T&...);
template <class... T, class... U> tuple<T..., U...> tuple_cat(const tuple<T...>&, const tuple<U...>&);
template <class... T, class... U> tuple<T..., U...> tuple_cat(tuple<T...>&&, const tuple<U...>&);
template <class... T, class... U> tuple<T..., U...> tuple_cat(const tuple<T...>&, tuple<U...>&&);
template <class... T, class... U> tuple<T..., U...> tuple_cat(tuple<T...>&&, tuple<U...>&&);
template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls);
// 20.4.1.4, tuple helper classes:
template <class T> class tuple_size; // undefined
template <class... T> class tuple_size<tuple<T...>>;
@@ -751,72 +748,140 @@ operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
// tuple_cat
template <class... _Tp, size_t ..._I1, class... _Up, size_t ..._I2>
inline _LIBCPP_INLINE_VISIBILITY
tuple<_Tp..., _Up...>
__tuple_cat(const tuple<_Tp...>& __x, __tuple_indices<_I1...>, const tuple<_Up...>& __y, __tuple_indices<_I2...>)
template <class _Tp, class _Up> struct __tuple_cat_type;
template <class ..._Ttypes, class ..._Utypes>
struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...>>
{
return tuple<_Tp..., _Up...>(get<_I1>(__x)..., get<_I2>(__y)...);
typedef tuple<_Ttypes..., _Utypes...> type;
};
template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
struct __tuple_cat_return_1
{
};
template <class ..._Types, class _Tuple0>
struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
{
typedef typename __tuple_cat_type<tuple<_Types...>,
typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type
type;
};
template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
: public __tuple_cat_return_1<
typename __tuple_cat_type<
tuple<_Types...>,
typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type
>::type,
__tuple_like<typename remove_reference<_Tuple1>::type>::value,
_Tuple1, _Tuples...>
{
};
template <class ..._Tuples> struct __tuple_cat_return;
template <class _Tuple0, class ..._Tuples>
struct __tuple_cat_return<_Tuple0, _Tuples...>
: public __tuple_cat_return_1<tuple<>,
__tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
_Tuples...>
{
};
template <>
struct __tuple_cat_return<>
{
typedef tuple<> type;
};
inline _LIBCPP_INLINE_VISIBILITY
tuple<>
tuple_cat()
{
return tuple<>();
}
template <class... _Tp, class... _Up>
inline _LIBCPP_INLINE_VISIBILITY
tuple<_Tp..., _Up...>
tuple_cat(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
{
return __tuple_cat(__x, typename __make_tuple_indices<sizeof...(_Tp)>::type(),
__y, typename __make_tuple_indices<sizeof...(_Up)>::type());
}
template <class _R, class _Indices, class _Tuple0, class ..._Tuples>
struct __tuple_cat_return_ref_imp;
template <class... _Tp, size_t ..._I1, class... _Up, size_t ..._I2>
inline _LIBCPP_INLINE_VISIBILITY
tuple<_Tp..., _Up...>
__tuple_cat(tuple<_Tp...>&& __x, __tuple_indices<_I1...>, const tuple<_Up...>& __y, __tuple_indices<_I2...>)
template <class ..._Types, size_t ..._I0, class _Tuple0>
struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
{
return tuple<_Tp..., _Up...>(_STD::forward<_Tp>(get<_I1>(__x))..., get<_I2>(__y)...);
}
typedef typename remove_reference<_Tuple0>::type _T0;
typedef tuple<_Types..., typename __apply_cv<_Tuple0,
typename tuple_element<_I0, _T0>::type>::type&&...> type;
};
template <class... _Tp, class... _Up>
inline _LIBCPP_INLINE_VISIBILITY
tuple<_Tp..., _Up...>
tuple_cat(tuple<_Tp...>&& __x, const tuple<_Up...>& __y)
template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
_Tuple0, _Tuple1, _Tuples...>
: public __tuple_cat_return_ref_imp<
tuple<_Types..., typename __apply_cv<_Tuple0,
typename tuple_element<_I0,
typename remove_reference<_Tuple0>::type>::type>::type&&...>,
typename __make_tuple_indices<tuple_size<typename
remove_reference<_Tuple1>::type>::value>::type,
_Tuple1, _Tuples...>
{
return __tuple_cat(_STD::move(__x), typename __make_tuple_indices<sizeof...(_Tp)>::type(),
__y, typename __make_tuple_indices<sizeof...(_Up)>::type());
}
};
template <class... _Tp, size_t ..._I1, class... _Up, size_t ..._I2>
inline _LIBCPP_INLINE_VISIBILITY
tuple<_Tp..., _Up...>
__tuple_cat(const tuple<_Tp...>& __x, __tuple_indices<_I1...>, tuple<_Up...>&& __y, __tuple_indices<_I2...>)
template <class _Tuple0, class ..._Tuples>
struct __tuple_cat_return_ref
: public __tuple_cat_return_ref_imp<tuple<>,
typename __make_tuple_indices<
tuple_size<typename remove_reference<_Tuple0>::type>::value
>::type, _Tuple0, _Tuples...>
{
return tuple<_Tp..., _Up...>(get<_I1>(__x)..., _STD::forward<_Up>(get<_I2>(__y))...);
}
};
template <class... _Tp, class... _Up>
inline _LIBCPP_INLINE_VISIBILITY
tuple<_Tp..., _Up...>
tuple_cat(const tuple<_Tp...>& __x, tuple<_Up...>&& __y)
{
return __tuple_cat(__x, typename __make_tuple_indices<sizeof...(_Tp)>::type(),
_STD::move(__y), typename __make_tuple_indices<sizeof...(_Up)>::type());
}
template <class _Types, class _I0, class _J0>
struct __tuple_cat;
template <class... _Tp, size_t ..._I1, class... _Up, size_t ..._I2>
inline _LIBCPP_INLINE_VISIBILITY
tuple<_Tp..., _Up...>
__tuple_cat(tuple<_Tp...>&& __x, __tuple_indices<_I1...>, tuple<_Up...>&& __y, __tuple_indices<_I2...>)
template <class ..._Types, size_t ..._I0, size_t ..._J0>
struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...>>
{
return tuple<_Tp..., _Up...>(_STD::forward<_Tp>(get<_I1>(__x))..., _STD::forward<_Up>(get<_I2>(__y))...);
}
template <class _Tuple0>
_LIBCPP_INLINE_VISIBILITY
typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
operator()(tuple<_Types...> __t, _Tuple0&& __t0)
{
return _STD::forward_as_tuple(_STD::forward<_Types>(get<_I0>(__t))...,
get<_J0>(_STD::forward<_Tuple0>(__t0))...);
}
template <class... _Tp, class... _Up>
template <class _Tuple0, class _Tuple1, class ..._Tuples>
_LIBCPP_INLINE_VISIBILITY
typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
{
typedef typename remove_reference<_Tuple0>::type _T0;
typedef typename remove_reference<_Tuple1>::type _T1;
return __tuple_cat<
tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
(_STD::forward_as_tuple(
_STD::forward<_Types>(get<_I0>(__t))...,
get<_J0>(_STD::forward<_Tuple0>(__t0))...
),
_STD::forward<_Tuple1>(__t1),
_STD::forward<_Tuples>(__tpls)...);
}
};
template <class _Tuple0, class... _Tuples>
inline _LIBCPP_INLINE_VISIBILITY
tuple<_Tp..., _Up...>
tuple_cat(tuple<_Tp...>&& __x, tuple<_Up...>&& __y)
typename __tuple_cat_return<_Tuple0, _Tuples...>::type
tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
{
return __tuple_cat(_STD::move(__x), typename __make_tuple_indices<sizeof...(_Tp)>::type(),
_STD::move(__y), typename __make_tuple_indices<sizeof...(_Up)>::type());
typedef typename remove_reference<_Tuple0>::type _T0;
return __tuple_cat<tuple<>, __tuple_indices<>,
typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
(tuple<>(), _STD::forward<_Tuple0>(__t0),
_STD::forward<_Tuples>(__tpls)...);
}
template <class ..._Tp, class _Alloc>

View File

@@ -1394,31 +1394,31 @@ public:
typedef decltype(declval<_Fn>()(declval<_ArgTypes>()...)) type;
};
template <class _MP, class _Tp, class ..._Args>
template <class _MP, class _Tp, bool _IsMemberFunctionPtr, class ..._Args>
struct __result_of_mp {};
// member function pointer
template <class _R, class _Class, class _Tp, class ..._Params, class ..._Args>
struct __result_of_mp<_R (_Class::*)(_Params...), _Tp, _Args...>
struct __result_of_mp<_R (_Class::*)(_Params...), _Tp, true, _Args...>
{
typedef _R type;
};
template <class _R, class _Class, class _Tp, class ..._Params, class ..._Args>
struct __result_of_mp<_R (_Class::*)(_Params...) const, _Tp, _Args...>
struct __result_of_mp<_R (_Class::*)(_Params...) const, _Tp, true, _Args...>
{
typedef _R type;
};
template <class _R, class _Class, class _Tp, class ..._Params, class ..._Args>
struct __result_of_mp<_R (_Class::*)(_Params...) volatile, _Tp, _Args...>
struct __result_of_mp<_R (_Class::*)(_Params...) volatile, _Tp, true, _Args...>
{
typedef _R type;
};
template <class _R, class _Class, class _Tp, class ..._Params, class ..._Args>
struct __result_of_mp<_R (_Class::*)(_Params...) const volatile, _Tp, _Args...>
struct __result_of_mp<_R (_Class::*)(_Params...) const volatile, _Tp, true, _Args...>
{
typedef _R type;
};
@@ -1441,7 +1441,7 @@ struct __result_of_mdp<_R _Class::*, _Tp, true>
};
template <class _R, class _Class, class _Tp>
struct __result_of_mp<_R _Class::*, _Tp>
struct __result_of_mp<_R _Class::*, _Tp, false>
: public __result_of_mdp<_R _Class::*, _Tp,
is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
{
@@ -1449,7 +1449,8 @@ struct __result_of_mp<_R _Class::*, _Tp>
template <class _Fn, class _Tp, class ..._ArgTypes>
class __result_of<_Fn(_Tp, _ArgTypes...), false> // _Fn must be member pointer
: public __result_of_mp<_Fn, _Tp, _ArgTypes...>
: public __result_of_mp<_Fn, _Tp, is_member_function_pointer<_Fn>::value,
_ArgTypes...>
{
};

View File

@@ -222,6 +222,8 @@ struct _LIBCPP_VISIBLE pair
second(_STD::forward<_U2>(__u2))
{}
#ifndef _LIBCPP_HAS_NO_VARIADICS
template<class _Tuple,
class = typename enable_if<__tuple_convertible<_Tuple, pair>::value>::type>
_LIBCPP_INLINE_VISIBILITY
@@ -232,7 +234,7 @@ struct _LIBCPP_VISIBLE pair
typename __make_tuple_types<_Tuple>::type>::type>(get<1>(__p)))
{}
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
_LIBCPP_INLINE_VISIBILITY
@@ -243,8 +245,6 @@ struct _LIBCPP_VISIBLE pair
typename __make_tuple_indices<sizeof...(_Args2) >::type())
{}
#endif // _LIBCPP_HAS_NO_VARIADICS
template <class _Tuple,
class = typename enable_if<__tuple_assignable<_Tuple, pair>::value>::type>
_LIBCPP_INLINE_VISIBILITY
@@ -259,6 +259,8 @@ struct _LIBCPP_VISIBLE pair
return *this;
}
#endif // _LIBCPP_HAS_NO_VARIADICS
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template<class _U1, class _U2>
_LIBCPP_INLINE_VISIBILITY pair(const pair<_U1, _U2>& __p)

View File

@@ -318,8 +318,8 @@ protected:
_LIBCPP_INLINE_VISIBILITY pointer& __end_cap() {return __end_cap_.first();}
_LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const {return __end_cap_.first();}
__vector_base();
__vector_base(const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY __vector_base();
_LIBCPP_INLINE_VISIBILITY __vector_base(const allocator_type& __a);
~__vector_base();
_LIBCPP_INLINE_VISIBILITY void clear() {__destruct_at_end(__begin_);}
@@ -327,8 +327,8 @@ protected:
_LIBCPP_INLINE_VISIBILITY void __destruct_at_end(const_pointer __new_last)
{__destruct_at_end(__new_last, is_trivially_destructible<value_type>());}
void __destruct_at_end(const_pointer __new_last, false_type);
void __destruct_at_end(const_pointer __new_last, true_type);
_LIBCPP_INLINE_VISIBILITY void __destruct_at_end(const_pointer __new_last, false_type);
_LIBCPP_INLINE_VISIBILITY void __destruct_at_end(const_pointer __new_last, true_type);
_LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const __vector_base& __c)
@@ -484,7 +484,9 @@ public:
template <class _ForwardIterator>
vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type* = 0);
_LIBCPP_INLINE_VISIBILITY
vector(initializer_list<value_type> __il);
_LIBCPP_INLINE_VISIBILITY
vector(initializer_list<value_type> __il, const allocator_type& __a);
#ifdef _LIBCPP_DEBUG
_LIBCPP_INLINE_VISIBILITY
@@ -493,10 +495,14 @@ public:
vector(const vector& __x);
vector(const vector& __x, const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY
vector& operator=(const vector& __x);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
vector(vector&& __x);
_LIBCPP_INLINE_VISIBILITY
vector(vector&& __x, const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY
vector& operator=(vector&& __x);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
@@ -526,10 +532,10 @@ public:
_LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const {return this->__alloc();}
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
_LIBCPP_INLINE_VISIBILITY iterator begin();
_LIBCPP_INLINE_VISIBILITY const_iterator begin() const;
_LIBCPP_INLINE_VISIBILITY iterator end();
_LIBCPP_INLINE_VISIBILITY const_iterator end() const;
_LIBCPP_INLINE_VISIBILITY reverse_iterator rbegin() {return reverse_iterator(end());}
_LIBCPP_INLINE_VISIBILITY const_reverse_iterator rbegin() const {return const_reverse_iterator(end());}
@@ -563,7 +569,7 @@ public:
_LIBCPP_INLINE_VISIBILITY const value_type* data() const
{return _STD::__to_raw_pointer(this->__begin_);}
void push_back(const_reference __x);
_LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
void push_back(value_type&& __x);
#ifndef _LIBCPP_HAS_NO_VARIADICS
@@ -601,7 +607,7 @@ public:
iterator insert(const_iterator __position, initializer_list<value_type> __il)
{return insert(__position, __il.begin(), __il.end());}
iterator erase(const_iterator __position);
_LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);
iterator erase(const_iterator __first, const_iterator __last);
_LIBCPP_INLINE_VISIBILITY void clear() {__base::clear();}
@@ -614,15 +620,17 @@ public:
bool __invariants() const;
private:
void __invalidate_all_iterators();
_LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
void allocate(size_type __n);
void deallocate();
size_type __recommend(size_type __new_size) const;
void __construct_at_end(size_type __n);
_LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
_LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n);
void __construct_at_end(size_type __n, false_type);
void __construct_at_end(size_type __n, true_type);
_LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, true_type);
_LIBCPP_INLINE_VISIBILITY
void __construct_at_end(size_type __n, const_reference __x);
void __construct_at_end(size_type __n, const_reference __x, false_type);
void __construct_at_end(size_type __n, const_reference __x, false_type);
_LIBCPP_INLINE_VISIBILITY
void __construct_at_end(size_type __n, const_reference __x, true_type);
template <class _ForwardIterator>
typename enable_if
@@ -634,7 +642,9 @@ private:
void __move_construct_at_end(pointer __first, pointer __last);
void __append(size_type __n);
void __append(size_type __n, const_reference __x);
_LIBCPP_INLINE_VISIBILITY
iterator __make_iter(pointer __p);
_LIBCPP_INLINE_VISIBILITY
const_iterator __make_iter(const_pointer __p) const;
void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);
pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p);
@@ -1757,8 +1767,8 @@ private:
{return (__n - 1) / __bits_per_word + 1;}
public:
vector();
explicit vector(const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY vector();
_LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a);
~vector();
explicit vector(size_type __n);
vector(size_type __n, const value_type& __v);
@@ -1785,9 +1795,9 @@ public:
vector(initializer_list<value_type> __il, const allocator_type& __a);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
vector(vector&& __v);
_LIBCPP_INLINE_VISIBILITY vector(vector&& __v);
vector(vector&& __v, const allocator_type& __a);
vector& operator=(vector&& __v);
_LIBCPP_INLINE_VISIBILITY vector& operator=(vector&& __v);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
vector& operator=(initializer_list<value_type> __il)
@@ -1874,7 +1884,7 @@ public:
iterator insert(const_iterator __position, initializer_list<value_type> __il)
{return insert(__position, __il.begin(), __il.end());}
iterator erase(const_iterator __position);
_LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);
iterator erase(const_iterator __first, const_iterator __last);
_LIBCPP_INLINE_VISIBILITY void clear() {__size_ = 0;}
@@ -1887,13 +1897,13 @@ public:
bool __invariants() const;
private:
void __invalidate_all_iterators();
_LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
void allocate(size_type __n);
void deallocate();
_LIBCPP_INLINE_VISIBILITY static size_type __align(size_type __new_size)
{return __new_size + (__bits_per_word-1) & ~(__bits_per_word-1);};
size_type __recommend(size_type __new_size) const;
void __construct_at_end(size_type __n, bool __x);
_LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
_LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, bool __x);
template <class _ForwardIterator>
typename enable_if
<
@@ -2250,7 +2260,6 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const alloca
}
template <class _Allocator>
_LIBCPP_INLINE_VISIBILITY inline
vector<bool, _Allocator>::~vector()
{
if (__begin_ != 0)

56
lib/CMakeLists.txt Normal file
View File

@@ -0,0 +1,56 @@
# Get sources
file(GLOB_RECURSE sources ../src/*.cpp)
# Add all the headers to the project for IDEs.
if (MSVC_IDE OR XCODE)
file(GLOB_RECURSE headers ../include/*)
# Force them all into the headers dir on MSVC, otherwise they end up at
# project scope because they don't have extensions.
if (MSVC_IDE)
source_group("Header Files" FILES ${headers})
endif()
endif()
if (LIBCXX_ENABLE_SHARED)
add_library(cxx SHARED
${sources}
${headers}
)
else()
add_library(cxx STATIC
${sources}
${headers}
)
endif()
# Generate library list.
append_if(libraries LIBCXX_HAS_PTHREAD_LIB pthread)
append_if(libraries LIBCXX_HAS_C_LIB c)
append_if(libraries LIBCXX_HAS_M_LIB m)
append_if(libraries LIBCXX_HAS_GCC_S_LIB gcc_s)
target_link_libraries(cxx ${libraries})
# Setup flags.
append_if(compile_flags LIBCXX_HAS_FPIC_FLAG -fPIC)
append_if(link_flags LIBCXX_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs)
set_target_properties(cxx
PROPERTIES
COMPILE_FLAGS "${compile_flags}"
LINK_FLAGS "${link_flags}"
OUTPUT_NAME "c++"
VERSION "1.0"
SOVERSION "1"
)
install(TARGETS cxx
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
install(DIRECTORY ../include/
DESTINATION include/c++/v1
FILES_MATCHING
PATTERN "*"
)

View File

@@ -2,7 +2,7 @@
#
# Set the $TRIPLE environment variable to your system's triple before
# running this script. If you set $CXX, that will be used to compile
# the library. Otherwise we'll use g++.
# the library. Otherwise we'll use clang++.
set -e
@@ -41,6 +41,7 @@ case $TRIPLE in
-compatibility_version 1 \
-install_name /usr/lib/libc++.dylib \
-Wl,-reexport_library,/usr/lib/libc++abi.dylib \
-Wl,-unexported_symbols_list,libc++unexp.exp \
/usr/lib/libSystem.B.dylib"
else
LDSHARED_FLAGS="-o libc++.1.dylib \
@@ -49,6 +50,7 @@ case $TRIPLE in
-install_name /usr/lib/libc++.dylib \
${SDKROOT}/usr/lib/libc++abi.dylib \
-lSystem \
-Wl,-unexported_symbols_list,libc++unexp.exp \
-Wl,-reexported_symbols_list,libc++abi.exp \
-Wl,-force_symbols_not_weak_list,notweak.exp"
fi
@@ -74,7 +76,7 @@ for FILE in ../src/*.cpp; do
done
cc *.o $RC_CFLAGS $LDSHARED_FLAGS
cc *.o $RC_CFLAGS $LDSHARED_FLAGS
#libtool -static -o libc++.a *.o

19
lib/libc++unexp.exp Normal file
View File

@@ -0,0 +1,19 @@
# all guard variables
__ZGVNSt3__*
# all vtables
# __ZTV*
# all VTT
# __ZTT*
# all non-virtual thunks
# __ZTh*
# all virtual thunks
# __ZTv*
# typeinfo for std::__1::__types
# There are no std::__types
# __ZTINSt3__1[0-9][0-9]*__*
# typeinfo name for std::__1::__types
__ZTSNSt3__1[0-9][0-9]*__*
# anything using __hidden_allocator
*__hidden_allocator*
# anything using __sso_allocator
*__sso_allocator*

View File

@@ -21,8 +21,6 @@
#include <langinfo.h>
#include <stdlib.h>
// FIXME: Locales are hard.
#if __APPLE__
_LIBCPP_BEGIN_NAMESPACE_STD
namespace {
@@ -676,61 +674,93 @@ ctype<wchar_t>::~ctype()
bool
ctype<wchar_t>::do_is(mask m, char_type c) const
{
#ifdef __APPLE__
return isascii(c) ? _DefaultRuneLocale.__runetype[c] & m : false;
#else
return false;
#endif
}
const wchar_t*
ctype<wchar_t>::do_is(const char_type* low, const char_type* high, mask* vec) const
{
#ifdef __APPLE__
for (; low != high; ++low, ++vec)
*vec = static_cast<mask>(isascii(*low) ? _DefaultRuneLocale.__runetype[*low] : 0);
return low;
#else
return NULL;
#endif
}
const wchar_t*
ctype<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const
{
#ifdef __APPLE__
for (; low != high; ++low)
if (isascii(*low) && (_DefaultRuneLocale.__runetype[*low] & m))
break;
return low;
#else
return NULL;
#endif
}
const wchar_t*
ctype<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const
{
#ifdef __APPLE__
for (; low != high; ++low)
if (!(isascii(*low) && (_DefaultRuneLocale.__runetype[*low] & m)))
break;
return low;
#else
return NULL;
#endif
}
wchar_t
ctype<wchar_t>::do_toupper(char_type c) const
{
#ifdef __APPLE__
return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c;
#else
return 0;
#endif
}
const wchar_t*
ctype<wchar_t>::do_toupper(char_type* low, const char_type* high) const
{
#ifdef __APPLE__
for (; low != high; ++low)
*low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low;
return low;
#else
return NULL;
#endif
}
wchar_t
ctype<wchar_t>::do_tolower(char_type c) const
{
#ifdef __APPLE__
return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c;
#else
return 0;
#endif
}
const wchar_t*
ctype<wchar_t>::do_tolower(char_type* low, const char_type* high) const
{
#ifdef __APPLE__
for (; low != high; ++low)
*low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low;
return low;
#else
return NULL;
#endif
}
wchar_t
@@ -775,8 +805,10 @@ ctype<char>::ctype(const mask* tab, bool del, size_t refs)
__tab_(tab),
__del_(del)
{
#ifdef __APPLE__
if (__tab_ == 0)
__tab_ = _DefaultRuneLocale.__runetype;
#endif
}
ctype<char>::~ctype()
@@ -788,29 +820,45 @@ ctype<char>::~ctype()
char
ctype<char>::do_toupper(char_type c) const
{
#ifdef __APPLE__
return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c;
#else
return 0;
#endif
}
const char*
ctype<char>::do_toupper(char_type* low, const char_type* high) const
{
#ifdef __APPLE__
for (; low != high; ++low)
*low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low;
return low;
#else
return NULL;
#endif
}
char
ctype<char>::do_tolower(char_type c) const
{
#ifdef __APPLE__
return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c;
#else
return 0;
#endif
}
const char*
ctype<char>::do_tolower(char_type* low, const char_type* high) const
{
#ifdef __APPLE__
for (; low != high; ++low)
*low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low;
return low;
#else
return NULL;
#endif
}
char
@@ -849,7 +897,11 @@ ctype<char>::do_narrow(const char_type* low, const char_type* high, char dfault,
const ctype<char>::mask*
ctype<char>::classic_table() throw()
{
#ifdef __APPLE__
return _DefaultRuneLocale.__runetype;
#else
return NULL;
#endif
}
// template <> class ctype_byname<char>
@@ -947,6 +999,7 @@ ctype_byname<wchar_t>::do_is(mask m, char_type c) const
const wchar_t*
ctype_byname<wchar_t>::do_is(const char_type* low, const char_type* high, mask* vec) const
{
#ifdef __APPLE__
for (; low != high; ++low, ++vec)
{
if (isascii(*low))
@@ -975,6 +1028,9 @@ ctype_byname<wchar_t>::do_is(const char_type* low, const char_type* high, mask*
}
}
return low;
#else
return NULL;
#endif
}
const wchar_t*
@@ -1026,33 +1082,49 @@ ctype_byname<wchar_t>::do_tolower(char_type* low, const char_type* high) const
wchar_t
ctype_byname<wchar_t>::do_widen(char c) const
{
#ifdef __APPLE__
return btowc_l(c, __l);
#else
return 0;
#endif
}
const char*
ctype_byname<wchar_t>::do_widen(const char* low, const char* high, char_type* dest) const
{
#ifdef __APPLE__
for (; low != high; ++low, ++dest)
*dest = btowc_l(*low, __l);
return low;
#else
return NULL;
#endif
}
char
ctype_byname<wchar_t>::do_narrow(char_type c, char dfault) const
{
#ifdef __APPLE__
int r = wctob_l(c, __l);
return r != WEOF ? static_cast<char>(r) : dfault;
#else
return 0;
#endif
}
const wchar_t*
ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const
{
#ifdef __APPLE__
for (; low != high; ++low, ++dest)
{
int r = wctob_l(*low, __l);
*dest = r != WEOF ? static_cast<char>(r) : dfault;
}
return low;
#else
return NULL;
#endif
}
// template <> class codecvt<char, char, mbstate_t>
@@ -1148,6 +1220,7 @@ codecvt<wchar_t, char, mbstate_t>::do_out(state_type& st,
const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
{
#ifdef __APPLE__
// look for first internal null in frm
const intern_type* fend = frm;
for (; fend != frm_end; ++fend)
@@ -1197,6 +1270,9 @@ codecvt<wchar_t, char, mbstate_t>::do_out(state_type& st,
}
}
return frm_nxt == frm_end ? ok : partial;
#else
return error;
#endif
}
codecvt<wchar_t, char, mbstate_t>::result
@@ -1204,6 +1280,7 @@ codecvt<wchar_t, char, mbstate_t>::do_in(state_type& st,
const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
{
#ifdef __APPLE__
// look for first internal null in frm
const extern_type* fend = frm;
for (; fend != frm_end; ++fend)
@@ -1261,12 +1338,16 @@ codecvt<wchar_t, char, mbstate_t>::do_in(state_type& st,
}
}
return frm_nxt == frm_end ? ok : partial;
#else
return error;
#endif
}
codecvt<wchar_t, char, mbstate_t>::result
codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st,
extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
{
#ifdef __APPLE__
to_nxt = to;
extern_type tmp[MB_LEN_MAX];
size_t n = wcrtomb_l(tmp, intern_type(), &st, __l);
@@ -1278,11 +1359,15 @@ codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st,
for (extern_type* p = tmp; n; --n) // write it
*to_nxt++ = *p++;
return ok;
#else
return error;
#endif
}
int
codecvt<wchar_t, char, mbstate_t>::do_encoding() const throw()
{
#ifdef __APPLE__
if (mbtowc_l(0, 0, MB_LEN_MAX, __l) == 0)
{
// stateless encoding
@@ -1291,6 +1376,9 @@ codecvt<wchar_t, char, mbstate_t>::do_encoding() const throw()
return 0;
}
return -1;
#else
return 0;
#endif
}
bool
@@ -1303,6 +1391,7 @@ int
codecvt<wchar_t, char, mbstate_t>::do_length(state_type& st,
const extern_type* frm, const extern_type* frm_end, size_t mx) const
{
#ifdef __APPLE__
int nbytes = 0;
for (size_t nwchar_t = 0; nwchar_t < mx && frm != frm_end; ++nwchar_t)
{
@@ -1323,12 +1412,19 @@ codecvt<wchar_t, char, mbstate_t>::do_length(state_type& st,
}
}
return nbytes;
#else
return 0;
#endif
}
int
codecvt<wchar_t, char, mbstate_t>::do_max_length() const throw()
{
#ifdef __APPLE__
return __l == 0 ? 1 : MB_CUR_MAX_L(__l);
#else
return 0;
#endif
}
// Valid UTF ranges
@@ -3869,6 +3965,7 @@ numpunct_byname<char>::~numpunct_byname()
void
numpunct_byname<char>::__init(const char* nm)
{
#ifdef __APPLE__
if (strcmp(nm, "C") != 0)
{
unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
@@ -3885,6 +3982,7 @@ numpunct_byname<char>::__init(const char* nm)
__grouping_ = lc->grouping;
// locallization for truename and falsename is not available
}
#endif
}
// numpunct_byname<wchar_t>
@@ -3908,6 +4006,7 @@ numpunct_byname<wchar_t>::~numpunct_byname()
void
numpunct_byname<wchar_t>::__init(const char* nm)
{
#ifdef __APPLE__
if (strcmp(nm, "C") != 0)
{
unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
@@ -3924,6 +4023,7 @@ numpunct_byname<wchar_t>::__init(const char* nm)
__grouping_ = lc->grouping;
// locallization for truename and falsename is not available
}
#endif
}
// num_get helpers
@@ -4488,6 +4588,7 @@ template <>
wstring
__time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& ct)
{
#ifdef __APPLE__
tm t;
t.tm_sec = 59;
t.tm_min = 55;
@@ -4632,6 +4733,9 @@ __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& ct)
++wbb;
}
return result;
#else
return wstring();
#endif
}
template <>
@@ -4675,6 +4779,7 @@ template <>
void
__time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
{
#ifdef __APPLE__
tm t = {0};
char buf[100];
size_t be;
@@ -4746,6 +4851,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
__r_ = __analyze('r', ct);
__x_ = __analyze('x', ct);
__X_ = __analyze('X', ct);
#endif
}
template <class CharT>
@@ -5007,6 +5113,7 @@ void
__time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm,
char __fmt, char __mod) const
{
#ifdef __APPLE__
char __nar[100];
char* __ne = __nar + 100;
__do_put(__nar, __ne, __tm, __fmt, __mod);
@@ -5016,6 +5123,7 @@ __time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm,
if (j == -1)
__throw_runtime_error("locale not supported");
__we = __wb + j;
#endif
}
// moneypunct_byname
@@ -5260,6 +5368,7 @@ template<>
void
moneypunct_byname<char, false>::init(const char* nm)
{
#ifdef __APPLE__
typedef moneypunct<char, false> base;
unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -5292,12 +5401,14 @@ moneypunct_byname<char, false>::init(const char* nm)
__negative_sign_ = lc->negative_sign;
__init_pat(__pos_format_, lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn);
__init_pat(__neg_format_, lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn);
#endif
}
template<>
void
moneypunct_byname<char, true>::init(const char* nm)
{
#ifdef __APPLE__
typedef moneypunct<char, true> base;
unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -5330,12 +5441,14 @@ moneypunct_byname<char, true>::init(const char* nm)
__negative_sign_ = lc->negative_sign;
__init_pat(__pos_format_, lc->int_p_cs_precedes, lc->int_p_sep_by_space, lc->int_p_sign_posn);
__init_pat(__neg_format_, lc->int_n_cs_precedes, lc->int_n_sep_by_space, lc->int_n_sign_posn);
#endif
}
template<>
void
moneypunct_byname<wchar_t, false>::init(const char* nm)
{
#ifdef __APPLE__
typedef moneypunct<wchar_t, false> base;
unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -5391,12 +5504,14 @@ moneypunct_byname<wchar_t, false>::init(const char* nm)
}
__init_pat(__pos_format_, lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn);
__init_pat(__neg_format_, lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn);
#endif
}
template<>
void
moneypunct_byname<wchar_t, true>::init(const char* nm)
{
#ifdef __APPLE__
typedef moneypunct<wchar_t, true> base;
unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -5452,6 +5567,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm)
}
__init_pat(__pos_format_, lc->int_p_cs_precedes, lc->int_p_sep_by_space, lc->int_p_sign_posn);
__init_pat(__neg_format_, lc->int_n_cs_precedes, lc->int_n_sep_by_space, lc->int_n_sign_posn);
#endif
}
void __do_nothing(void*) {}
@@ -5526,4 +5642,3 @@ template class codecvt_byname<char32_t, char, mbstate_t>;
template class __vector_base_common<true>;
_LIBCPP_END_NAMESPACE_STD
#endif // __APPLE__

View File

@@ -92,10 +92,25 @@ __thread_local_data()
// __thread_struct_imp
class __thread_struct_imp
template <class T>
class _LIBCPP_HIDDEN __hidden_allocator
{
typedef vector<__assoc_sub_state*> _AsyncStates;
typedef vector<pair<condition_variable*, mutex*> > _Notify;
public:
typedef T value_type;
T* allocate(size_t __n)
{return static_cast<T*>(::operator new(__n * sizeof(T)));}
void deallocate(T* __p, size_t) {::operator delete((void*)__p);}
size_t max_size() const {return size_t(~0) / sizeof(T);}
};
class _LIBCPP_HIDDEN __thread_struct_imp
{
typedef vector<__assoc_sub_state*,
__hidden_allocator<__assoc_sub_state*> > _AsyncStates;
typedef vector<pair<condition_variable*, mutex*>,
__hidden_allocator<pair<condition_variable*, mutex*> > > _Notify;
_AsyncStates async_states_;
_Notify notify_;

44
test/CMakeLists.txt Normal file
View File

@@ -0,0 +1,44 @@
macro(pythonize_bool var)
if (${var})
set(${var} True)
else()
set(${var} False)
endif()
endmacro()
include(FindPythonInterp)
if(PYTHONINTERP_FOUND)
set(LIT_EXECUTABLE "" CACHE FILEPATH "Path to LLVM's lit.py.")
set(LIT_ARGS_DEFAULT "-sv")
if (MSVC OR XCODE)
set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
endif()
set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}"
CACHE STRING "Default options for lit")
set(LIT_ARGS "${LLVM_LIT_ARGS}")
separate_arguments(LIT_ARGS)
set(LIBCXX_COMPILER ${CMAKE_CXX_COMPILER})
set(LIBCXX_SOURCE_DIR ${CMAKE_SOURCE_DIR})
set(LIBCXX_BINARY_DIR ${CMAKE_BINARY_DIR})
set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
pythonize_bool(LIBCXX_ENABLE_SHARED)
pythonize_bool(LIBCXX_HAS_STDCXX0X_FLAG)
set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
@ONLY)
add_custom_target(check
COMMAND ${PYTHON_EXECUTABLE}
${LIT_EXECUTABLE}
${LIT_ARGS}
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS
COMMENT "Running libcxx tests")
else()
message(WARNING "Could not find Python, no check target will be available!")
endif()

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -0,0 +1,126 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class T>
// struct atomic<T*>
// {
// bool is_lock_free() const volatile;
// bool is_lock_free() const;
// 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);
//
// 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>
template <class A, class T>
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));
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(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(0));
assert((obj = T(0)) == T(0));
assert(obj == T(0));
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>
void test()
{
do_test<A, T>();
do_test<volatile A, T>();
}
int main()
{
test<std::atomic<int*>, int*>();
}

View File

@@ -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*>();
}

View File

@@ -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);
}
}

View File

@@ -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>();
}

View File

@@ -0,0 +1,163 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class T>
// struct atomic
// {
// bool is_lock_free() const volatile;
// bool is_lock_free() const;
// 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);
//
// 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>
int main()
{
{
volatile std::atomic<bool> _;
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,
std::memory_order_seq_cst) == false);
assert(obj == false);
assert(x == 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);
x = true;
obj.store(true);
assert(obj.compare_exchange_strong(x, false) == true);
assert(obj == false);
assert(x == true);
assert(obj.compare_exchange_strong(x, true,
std::memory_order_seq_cst) == false);
assert(obj == false);
assert(x == true);
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 == true);
assert((obj = false) == false);
assert(obj == false);
assert((obj = true) == true);
assert(obj == true);
}
{
std::atomic<bool> _;
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,
std::memory_order_seq_cst) == false);
assert(obj == false);
assert(x == 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);
x = true;
obj.store(true);
assert(obj.compare_exchange_strong(x, false) == true);
assert(obj == false);
assert(x == true);
assert(obj.compare_exchange_strong(x, true,
std::memory_order_seq_cst) == false);
assert(obj == false);
assert(x == true);
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 == true);
assert((obj = false) == false);
assert(obj == false);
assert((obj = true) == true);
assert(obj == true);
}
}

View File

@@ -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), "");
}

View File

@@ -0,0 +1,191 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <>
// struct atomic<integral>
// {
// bool is_lock_free() const volatile;
// bool is_lock_free() const;
// 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);
//
// 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>
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(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(0));
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));
}
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>();
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>();
}

View File

@@ -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
}

View File

@@ -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()
{
}

View File

@@ -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()
{
}

View File

@@ -0,0 +1,88 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class T>
// bool
// atomic_compare_exchange_strong(volatile atomic<T>* obj, T* expc, T desr);
//
// template <class T>
// bool
// atomic_compare_exchange_strong(atomic<T>* obj, T* expc, T desr);
#include <atomic>
#include <cassert>
template <class T>
void
test()
{
{
typedef std::atomic<T> A;
A a;
T t(T(1));
std::atomic_init(&a, t);
assert(std::atomic_compare_exchange_strong(&a, &t, T(2)) == true);
assert(a == T(2));
assert(t == T(1));
assert(std::atomic_compare_exchange_strong(&a, &t, T(3)) == false);
assert(a == T(2));
assert(t == T(3));
}
{
typedef std::atomic<T> A;
volatile A a;
T t(T(1));
std::atomic_init(&a, t);
assert(std::atomic_compare_exchange_strong(&a, &t, T(2)) == true);
assert(a == T(2));
assert(t == T(1));
assert(std::atomic_compare_exchange_strong(&a, &t, T(3)) == false);
assert(a == T(2));
assert(t == T(3));
}
}
struct A
{
int i;
explicit A(int d = 0) : i(d) {}
A(const A& a) : i(a.i) {}
A(const volatile A& a) : i(a.i) {}
void operator=(const volatile A& a) volatile {i = a.i;}
friend bool operator==(const A& x, const A& y)
{return x.i == y.i;}
};
int main()
{
test<A>();
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
test<int*>();
test<const int*>();
}

View File

@@ -0,0 +1,95 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class T>
// bool
// atomic_compare_exchange_strong_explicit(volatile atomic<T>* obj, T* expc,
// T desr,
// memory_order s, memory_order f);
//
// template <class T>
// bool
// atomic_compare_exchange_strong_explicit(atomic<T>* obj, T* expc, T desr,
// memory_order s, memory_order f);
#include <atomic>
#include <cassert>
template <class T>
void
test()
{
{
typedef std::atomic<T> A;
A a;
T t(T(1));
std::atomic_init(&a, t);
assert(std::atomic_compare_exchange_strong_explicit(&a, &t, T(2),
std::memory_order_seq_cst, std::memory_order_seq_cst) == true);
assert(a == T(2));
assert(t == T(1));
assert(std::atomic_compare_exchange_strong_explicit(&a, &t, T(3),
std::memory_order_seq_cst, std::memory_order_seq_cst) == false);
assert(a == T(2));
assert(t == T(3));
}
{
typedef std::atomic<T> A;
volatile A a;
T t(T(1));
std::atomic_init(&a, t);
assert(std::atomic_compare_exchange_strong_explicit(&a, &t, T(2),
std::memory_order_seq_cst, std::memory_order_seq_cst) == true);
assert(a == T(2));
assert(t == T(1));
assert(std::atomic_compare_exchange_strong_explicit(&a, &t, T(3),
std::memory_order_seq_cst, std::memory_order_seq_cst) == false);
assert(a == T(2));
assert(t == T(3));
}
}
struct A
{
int i;
explicit A(int d = 0) : i(d) {}
A(const A& a) : i(a.i) {}
A(const volatile A& a) : i(a.i) {}
void operator=(const volatile A& a) volatile {i = a.i;}
friend bool operator==(const A& x, const A& y)
{return x.i == y.i;}
};
int main()
{
test<A>();
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
test<int*>();
test<const int*>();
}

View File

@@ -0,0 +1,88 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class T>
// bool
// atomic_compare_exchange_weak(volatile atomic<T>* obj, T* expc, T desr);
//
// template <class T>
// bool
// atomic_compare_exchange_weak(atomic<T>* obj, T* expc, T desr);
#include <atomic>
#include <cassert>
template <class T>
void
test()
{
{
typedef std::atomic<T> A;
A a;
T t(T(1));
std::atomic_init(&a, t);
assert(std::atomic_compare_exchange_weak(&a, &t, T(2)) == true);
assert(a == T(2));
assert(t == T(1));
assert(std::atomic_compare_exchange_weak(&a, &t, T(3)) == false);
assert(a == T(2));
assert(t == T(3));
}
{
typedef std::atomic<T> A;
volatile A a;
T t(T(1));
std::atomic_init(&a, t);
assert(std::atomic_compare_exchange_weak(&a, &t, T(2)) == true);
assert(a == T(2));
assert(t == T(1));
assert(std::atomic_compare_exchange_weak(&a, &t, T(3)) == false);
assert(a == T(2));
assert(t == T(3));
}
}
struct A
{
int i;
explicit A(int d = 0) : i(d) {}
A(const A& a) : i(a.i) {}
A(const volatile A& a) : i(a.i) {}
void operator=(const volatile A& a) volatile {i = a.i;}
friend bool operator==(const A& x, const A& y)
{return x.i == y.i;}
};
int main()
{
test<A>();
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
test<int*>();
test<const int*>();
}

View File

@@ -0,0 +1,95 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class T>
// bool
// atomic_compare_exchange_weak_explicit(volatile atomic<T>* obj, T* expc,
// T desr,
// memory_order s, memory_order f);
//
// template <class T>
// bool
// atomic_compare_exchange_weak_explicit(atomic<T>* obj, T* expc, T desr,
// memory_order s, memory_order f);
#include <atomic>
#include <cassert>
template <class T>
void
test()
{
{
typedef std::atomic<T> A;
A a;
T t(T(1));
std::atomic_init(&a, t);
assert(std::atomic_compare_exchange_weak_explicit(&a, &t, T(2),
std::memory_order_seq_cst, std::memory_order_seq_cst) == true);
assert(a == T(2));
assert(t == T(1));
assert(std::atomic_compare_exchange_weak_explicit(&a, &t, T(3),
std::memory_order_seq_cst, std::memory_order_seq_cst) == false);
assert(a == T(2));
assert(t == T(3));
}
{
typedef std::atomic<T> A;
volatile A a;
T t(T(1));
std::atomic_init(&a, t);
assert(std::atomic_compare_exchange_weak_explicit(&a, &t, T(2),
std::memory_order_seq_cst, std::memory_order_seq_cst) == true);
assert(a == T(2));
assert(t == T(1));
assert(std::atomic_compare_exchange_weak_explicit(&a, &t, T(3),
std::memory_order_seq_cst, std::memory_order_seq_cst) == false);
assert(a == T(2));
assert(t == T(3));
}
}
struct A
{
int i;
explicit A(int d = 0) : i(d) {}
A(const A& a) : i(a.i) {}
A(const volatile A& a) : i(a.i) {}
void operator=(const volatile A& a) volatile {i = a.i;}
friend bool operator==(const A& x, const A& y)
{return x.i == y.i;}
};
int main()
{
test<A>();
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
test<int*>();
test<const int*>();
}

View File

@@ -0,0 +1,73 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class T>
// T
// atomic_exchange(volatile atomic<T>* obj, T desr);
//
// template <class T>
// T
// atomic_exchange(atomic<T>* obj, T desr);
#include <atomic>
#include <cassert>
template <class T>
void
test()
{
typedef std::atomic<T> A;
A t;
std::atomic_init(&t, T(1));
assert(std::atomic_exchange(&t, T(2)) == T(1));
assert(t == T(2));
volatile A vt;
std::atomic_init(&vt, T(3));
assert(std::atomic_exchange(&vt, T(4)) == T(3));
assert(vt == T(4));
}
struct A
{
int i;
explicit A(int d = 0) : i(d) {}
A(const A& a) : i(a.i) {}
A(const volatile A& a) : i(a.i) {}
void operator=(const volatile A& a) volatile {i = a.i;}
friend bool operator==(const A& x, const A& y)
{return x.i == y.i;}
};
int main()
{
test<A>();
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
test<int*>();
test<const int*>();
}

View File

@@ -0,0 +1,75 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class T>
// T
// atomic_exchange_explicit(volatile atomic<T>* obj, T desr, memory_order m);
//
// template <class T>
// T
// atomic_exchange_explicit(atomic<T>* obj, T desr, memory_order m);
#include <atomic>
#include <cassert>
template <class T>
void
test()
{
typedef std::atomic<T> A;
A t;
std::atomic_init(&t, T(1));
assert(std::atomic_exchange_explicit(&t, T(2), std::memory_order_seq_cst)
== T(1));
assert(t == T(2));
volatile A vt;
std::atomic_init(&vt, T(3));
assert(std::atomic_exchange_explicit(&vt, T(4), std::memory_order_seq_cst)
== T(3));
assert(vt == T(4));
}
struct A
{
int i;
explicit A(int d = 0) : i(d) {}
A(const A& a) : i(a.i) {}
A(const volatile A& a) : i(a.i) {}
void operator=(const volatile A& a) volatile {i = a.i;}
friend bool operator==(const A& x, const A& y)
{return x.i == y.i;}
};
int main()
{
test<A>();
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
test<int*>();
test<const int*>();
}

View File

@@ -0,0 +1,107 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class Integral>
// Integral
// atomic_fetch_add(volatile atomic<Integral>* obj, Integral op);
//
// template <class Integral>
// Integral
// atomic_fetch_add(atomic<Integral>* obj, Integral op);
//
// template <class T>
// T*
// atomic_fetch_add(volatile atomic<T*>* obj, ptrdiff_t op);
//
// template <class T>
// T*
// atomic_fetch_add(atomic<T*>* obj, ptrdiff_t op);
#include <atomic>
#include <cassert>
template <class T>
void
test()
{
{
typedef std::atomic<T> A;
A t;
std::atomic_init(&t, T(1));
assert(std::atomic_fetch_add(&t, T(2)) == T(1));
assert(t == T(3));
}
{
typedef std::atomic<T> A;
volatile A t;
std::atomic_init(&t, T(1));
assert(std::atomic_fetch_add(&t, T(2)) == T(1));
assert(t == T(3));
}
}
template <class T>
void
testp()
{
{
typedef std::atomic<T> A;
typedef typename std::remove_pointer<T>::type X;
A t;
std::atomic_init(&t, T(1*sizeof(X)));
assert(std::atomic_fetch_add(&t, 2) == T(1*sizeof(X)));
assert(t == T(3*sizeof(X)));
}
{
typedef std::atomic<T> A;
typedef typename std::remove_pointer<T>::type X;
volatile A t;
std::atomic_init(&t, T(1*sizeof(X)));
assert(std::atomic_fetch_add(&t, 2) == T(1*sizeof(X)));
assert(t == T(3*sizeof(X)));
}
}
struct A
{
int i;
explicit A(int d = 0) : i(d) {}
A(const A& a) : i(a.i) {}
A(const volatile A& a) : i(a.i) {}
void operator=(const volatile A& a) volatile {i = a.i;}
friend bool operator==(const A& x, const A& y)
{return x.i == y.i;}
};
int main()
{
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
testp<int*>();
testp<const int*>();
}

View File

@@ -0,0 +1,111 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class Integral>
// Integral
// atomic_fetch_add_explicit(volatile atomic<Integral>* obj, Integral op,
// memory_order m);
// template <class Integral>
// Integral
// atomic_fetch_add_explicit(atomic<Integral>* obj, Integral op,
// memory_order m);
// template <class T>
// T*
// atomic_fetch_add_explicit(volatile atomic<T*>* obj, ptrdiff_t op,
// memory_order m);
// template <class T>
// T*
// atomic_fetch_add_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m);
#include <atomic>
#include <cassert>
template <class T>
void
test()
{
{
typedef std::atomic<T> A;
A t;
std::atomic_init(&t, T(1));
assert(std::atomic_fetch_add_explicit(&t, T(2),
std::memory_order_seq_cst) == T(1));
assert(t == T(3));
}
{
typedef std::atomic<T> A;
volatile A t;
std::atomic_init(&t, T(1));
assert(std::atomic_fetch_add_explicit(&t, T(2),
std::memory_order_seq_cst) == T(1));
assert(t == T(3));
}
}
template <class T>
void
testp()
{
{
typedef std::atomic<T> A;
typedef typename std::remove_pointer<T>::type X;
A t;
std::atomic_init(&t, T(1*sizeof(X)));
assert(std::atomic_fetch_add_explicit(&t, 2,
std::memory_order_seq_cst) == T(1*sizeof(X)));
assert(t == T(3*sizeof(X)));
}
{
typedef std::atomic<T> A;
typedef typename std::remove_pointer<T>::type X;
volatile A t;
std::atomic_init(&t, T(1*sizeof(X)));
assert(std::atomic_fetch_add_explicit(&t, 2,
std::memory_order_seq_cst) == T(1*sizeof(X)));
assert(t == T(3*sizeof(X)));
}
}
struct A
{
int i;
explicit A(int d = 0) : i(d) {}
A(const A& a) : i(a.i) {}
A(const volatile A& a) : i(a.i) {}
void operator=(const volatile A& a) volatile {i = a.i;}
friend bool operator==(const A& x, const A& y)
{return x.i == y.i;}
};
int main()
{
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
testp<int*>();
testp<const int*>();
}

View File

@@ -0,0 +1,61 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class Integral>
// Integral
// atomic_fetch_and(volatile atomic<Integral>* obj, Integral op);
//
// template <class Integral>
// Integral
// atomic_fetch_and(atomic<Integral>* obj, Integral op);
#include <atomic>
#include <cassert>
template <class T>
void
test()
{
{
typedef std::atomic<T> A;
A t;
std::atomic_init(&t, T(1));
assert(std::atomic_fetch_and(&t, T(2)) == T(1));
assert(t == T(0));
}
{
typedef std::atomic<T> A;
volatile A t;
std::atomic_init(&t, T(3));
assert(std::atomic_fetch_and(&t, T(2)) == T(3));
assert(t == T(2));
}
}
int main()
{
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
}

View File

@@ -0,0 +1,63 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class Integral>
// Integral
// atomic_fetch_and_explicit(volatile atomic<Integral>* obj, Integral op);
//
// template <class Integral>
// Integral
// atomic_fetch_and_explicit(atomic<Integral>* obj, Integral op);
#include <atomic>
#include <cassert>
template <class T>
void
test()
{
{
typedef std::atomic<T> A;
A t;
std::atomic_init(&t, T(1));
assert(std::atomic_fetch_and_explicit(&t, T(2),
std::memory_order_seq_cst) == T(1));
assert(t == T(0));
}
{
typedef std::atomic<T> A;
volatile A t;
std::atomic_init(&t, T(3));
assert(std::atomic_fetch_and_explicit(&t, T(2),
std::memory_order_seq_cst) == T(3));
assert(t == T(2));
}
}
int main()
{
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
}

View File

@@ -0,0 +1,61 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class Integral>
// Integral
// atomic_fetch_or(volatile atomic<Integral>* obj, Integral op);
//
// template <class Integral>
// Integral
// atomic_fetch_or(atomic<Integral>* obj, Integral op);
#include <atomic>
#include <cassert>
template <class T>
void
test()
{
{
typedef std::atomic<T> A;
A t;
std::atomic_init(&t, T(1));
assert(std::atomic_fetch_or(&t, T(2)) == T(1));
assert(t == T(3));
}
{
typedef std::atomic<T> A;
volatile A t;
std::atomic_init(&t, T(3));
assert(std::atomic_fetch_or(&t, T(2)) == T(3));
assert(t == T(3));
}
}
int main()
{
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
}

View File

@@ -0,0 +1,63 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class Integral>
// Integral
// atomic_fetch_or_explicit(volatile atomic<Integral>* obj, Integral op);
//
// template <class Integral>
// Integral
// atomic_fetch_or_explicit(atomic<Integral>* obj, Integral op);
#include <atomic>
#include <cassert>
template <class T>
void
test()
{
{
typedef std::atomic<T> A;
A t;
std::atomic_init(&t, T(1));
assert(std::atomic_fetch_or_explicit(&t, T(2),
std::memory_order_seq_cst) == T(1));
assert(t == T(3));
}
{
typedef std::atomic<T> A;
volatile A t;
std::atomic_init(&t, T(3));
assert(std::atomic_fetch_or_explicit(&t, T(2),
std::memory_order_seq_cst) == T(3));
assert(t == T(3));
}
}
int main()
{
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
}

View File

@@ -0,0 +1,107 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class Integral>
// Integral
// atomic_fetch_sub(volatile atomic<Integral>* obj, Integral op);
//
// template <class Integral>
// Integral
// atomic_fetch_sub(atomic<Integral>* obj, Integral op);
//
// template <class T>
// T*
// atomic_fetch_sub(volatile atomic<T*>* obj, ptrdiff_t op);
//
// template <class T>
// T*
// atomic_fetch_sub(atomic<T*>* obj, ptrdiff_t op);
#include <atomic>
#include <cassert>
template <class T>
void
test()
{
{
typedef std::atomic<T> A;
A t;
std::atomic_init(&t, T(3));
assert(std::atomic_fetch_sub(&t, T(2)) == T(3));
assert(t == T(1));
}
{
typedef std::atomic<T> A;
volatile A t;
std::atomic_init(&t, T(3));
assert(std::atomic_fetch_sub(&t, T(2)) == T(3));
assert(t == T(1));
}
}
template <class T>
void
testp()
{
{
typedef std::atomic<T> A;
typedef typename std::remove_pointer<T>::type X;
A t;
std::atomic_init(&t, T(3*sizeof(X)));
assert(std::atomic_fetch_sub(&t, 2) == T(3*sizeof(X)));
assert(t == T(1*sizeof(X)));
}
{
typedef std::atomic<T> A;
typedef typename std::remove_pointer<T>::type X;
volatile A t;
std::atomic_init(&t, T(3*sizeof(X)));
assert(std::atomic_fetch_sub(&t, 2) == T(3*sizeof(X)));
assert(t == T(1*sizeof(X)));
}
}
struct A
{
int i;
explicit A(int d = 0) : i(d) {}
A(const A& a) : i(a.i) {}
A(const volatile A& a) : i(a.i) {}
void operator=(const volatile A& a) volatile {i = a.i;}
friend bool operator==(const A& x, const A& y)
{return x.i == y.i;}
};
int main()
{
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
testp<int*>();
testp<const int*>();
}

View File

@@ -0,0 +1,112 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class Integral>
// Integral
// atomic_fetch_sub_explicit(volatile atomic<Integral>* obj, Integral op,
// memory_order m);
// template <class Integral>
// Integral
// atomic_fetch_sub_explicit(atomic<Integral>* obj, Integral op,
// memory_order m);
//
// template <class T>
// T*
// atomic_fetch_sub_explicit(volatile atomic<T*>* obj, ptrdiff_t op,
// memory_order m);
// template <class T>
// T*
// atomic_fetch_sub_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m);
#include <atomic>
#include <cassert>
template <class T>
void
test()
{
{
typedef std::atomic<T> A;
A t;
std::atomic_init(&t, T(3));
assert(std::atomic_fetch_sub_explicit(&t, T(2),
std::memory_order_seq_cst) == T(3));
assert(t == T(1));
}
{
typedef std::atomic<T> A;
volatile A t;
std::atomic_init(&t, T(3));
assert(std::atomic_fetch_sub_explicit(&t, T(2),
std::memory_order_seq_cst) == T(3));
assert(t == T(1));
}
}
template <class T>
void
testp()
{
{
typedef std::atomic<T> A;
typedef typename std::remove_pointer<T>::type X;
A t;
std::atomic_init(&t, T(3*sizeof(X)));
assert(std::atomic_fetch_sub_explicit(&t, 2,
std::memory_order_seq_cst) == T(3*sizeof(X)));
assert(t == T(1*sizeof(X)));
}
{
typedef std::atomic<T> A;
typedef typename std::remove_pointer<T>::type X;
volatile A t;
std::atomic_init(&t, T(3*sizeof(X)));
assert(std::atomic_fetch_sub_explicit(&t, 2,
std::memory_order_seq_cst) == T(3*sizeof(X)));
assert(t == T(1*sizeof(X)));
}
}
struct A
{
int i;
explicit A(int d = 0) : i(d) {}
A(const A& a) : i(a.i) {}
A(const volatile A& a) : i(a.i) {}
void operator=(const volatile A& a) volatile {i = a.i;}
friend bool operator==(const A& x, const A& y)
{return x.i == y.i;}
};
int main()
{
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
testp<int*>();
testp<const int*>();
}

View File

@@ -0,0 +1,61 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class Integral>
// Integral
// atomic_fetch_xor(volatile atomic<Integral>* obj, Integral op);
//
// template <class Integral>
// Integral
// atomic_fetch_xor(atomic<Integral>* obj, Integral op);
#include <atomic>
#include <cassert>
template <class T>
void
test()
{
{
typedef std::atomic<T> A;
A t;
std::atomic_init(&t, T(1));
assert(std::atomic_fetch_xor(&t, T(2)) == T(1));
assert(t == T(3));
}
{
typedef std::atomic<T> A;
volatile A t;
std::atomic_init(&t, T(3));
assert(std::atomic_fetch_xor(&t, T(2)) == T(3));
assert(t == T(1));
}
}
int main()
{
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
}

View File

@@ -0,0 +1,63 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class Integral>
// Integral
// atomic_fetch_xor_explicit(volatile atomic<Integral>* obj, Integral op);
//
// template <class Integral>
// Integral
// atomic_fetch_xor_explicit(atomic<Integral>* obj, Integral op);
#include <atomic>
#include <cassert>
template <class T>
void
test()
{
{
typedef std::atomic<T> A;
A t;
std::atomic_init(&t, T(1));
assert(std::atomic_fetch_xor_explicit(&t, T(2),
std::memory_order_seq_cst) == T(1));
assert(t == T(3));
}
{
typedef std::atomic<T> A;
volatile A t;
std::atomic_init(&t, T(3));
assert(std::atomic_fetch_xor_explicit(&t, T(2),
std::memory_order_seq_cst) == T(3));
assert(t == T(1));
}
}
int main()
{
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
}

View File

@@ -0,0 +1,71 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class T>
// void
// atomic_init(volatile atomic<T>* obj, T desr);
//
// template <class T>
// void
// atomic_init(atomic<T>* obj, T desr);
#include <atomic>
#include <cassert>
template <class T>
void
test()
{
typedef std::atomic<T> A;
A t;
std::atomic_init(&t, T(1));
assert(t == T(1));
volatile A vt;
std::atomic_init(&vt, T(2));
assert(vt == T(2));
}
struct A
{
int i;
explicit A(int d = 0) : i(d) {}
A(const A& a) : i(a.i) {}
A(const volatile A& a) : i(a.i) {}
void operator=(const volatile A& a) volatile {i = a.i;}
friend bool operator==(const A& x, const A& y)
{return x.i == y.i;}
};
int main()
{
test<A>();
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
test<int*>();
test<const int*>();
}

View File

@@ -0,0 +1,59 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class T>
// bool
// atomic_is_lock_free(const volatile atomic<T>* obj);
//
// template <class T>
// bool
// atomic_is_lock_free(const atomic<T>* obj);
#include <atomic>
template <class T>
void
test()
{
typedef std::atomic<T> A;
const A ct;
bool b1 = std::atomic_is_lock_free(&ct);
const volatile A cvt;
bool b2 = std::atomic_is_lock_free(&cvt);
}
struct A
{
char _[4];
};
int main()
{
test<A>();
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
test<int*>();
test<const int*>();
}

View File

@@ -0,0 +1,71 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class T>
// T
// atomic_load(const volatile atomic<T>* obj);
//
// template <class T>
// T
// atomic_load(const atomic<T>* obj);
#include <atomic>
#include <cassert>
template <class T>
void
test()
{
typedef std::atomic<T> A;
A t;
std::atomic_init(&t, T(1));
assert(std::atomic_load(&t) == T(1));
volatile A vt;
std::atomic_init(&vt, T(2));
assert(std::atomic_load(&vt) == T(2));
}
struct A
{
int i;
explicit A(int d = 0) : i(d) {}
A(const A& a) : i(a.i) {}
A(const volatile A& a) : i(a.i) {}
void operator=(const volatile A& a) volatile {i = a.i;}
friend bool operator==(const A& x, const A& y)
{return x.i == y.i;}
};
int main()
{
test<A>();
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
test<int*>();
test<const int*>();
}

View File

@@ -0,0 +1,71 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class T>
// T
// atomic_load_explicit(const volatile atomic<T>* obj, memory_order m);
//
// template <class T>
// T
// atomic_load_explicit(const atomic<T>* obj, memory_order m);
#include <atomic>
#include <cassert>
template <class T>
void
test()
{
typedef std::atomic<T> A;
A t;
std::atomic_init(&t, T(1));
assert(std::atomic_load_explicit(&t, std::memory_order_seq_cst) == T(1));
volatile A vt;
std::atomic_init(&vt, T(2));
assert(std::atomic_load_explicit(&vt, std::memory_order_seq_cst) == T(2));
}
struct A
{
int i;
explicit A(int d = 0) : i(d) {}
A(const A& a) : i(a.i) {}
A(const volatile A& a) : i(a.i) {}
void operator=(const volatile A& a) volatile {i = a.i;}
friend bool operator==(const A& x, const A& y)
{return x.i == y.i;}
};
int main()
{
test<A>();
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
test<int*>();
test<const int*>();
}

View File

@@ -0,0 +1,71 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class T>
// void
// atomic_store(volatile atomic<T>* obj, T desr);
//
// template <class T>
// void
// atomic_store(atomic<T>* obj, T desr);
#include <atomic>
#include <cassert>
template <class T>
void
test()
{
typedef std::atomic<T> A;
A t;
std::atomic_store(&t, T(1));
assert(t == T(1));
volatile A vt;
std::atomic_store(&vt, T(2));
assert(vt == T(2));
}
struct A
{
int i;
explicit A(int d = 0) : i(d) {}
A(const A& a) : i(a.i) {}
A(const volatile A& a) : i(a.i) {}
void operator=(const volatile A& a) volatile {i = a.i;}
friend bool operator==(const A& x, const A& y)
{return x.i == y.i;}
};
int main()
{
test<A>();
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
test<int*>();
test<const int*>();
}

View File

@@ -0,0 +1,71 @@
//===----------------------------------------------------------------------===//
//
// 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>
// template <class T>
// void
// atomic_store_explicit(volatile atomic<T>* obj, T desr, memory_order m);
//
// template <class T>
// void
// atomic_store_explicit(atomic<T>* obj, T desr, memory_order m);
#include <atomic>
#include <cassert>
template <class T>
void
test()
{
typedef std::atomic<T> A;
A t;
std::atomic_store_explicit(&t, T(1), std::memory_order_seq_cst);
assert(t == T(1));
volatile A vt;
std::atomic_store_explicit(&vt, T(2), std::memory_order_seq_cst);
assert(vt == T(2));
}
struct A
{
int i;
explicit A(int d = 0) : i(d) {}
A(const A& a) : i(a.i) {}
A(const volatile A& a) : i(a.i) {}
void operator=(const volatile A& a) volatile {i = a.i;}
friend bool operator==(const A& x, const A& y)
{return x.i == y.i;}
};
int main()
{
test<A>();
test<char>();
test<signed char>();
test<unsigned char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
test<wchar_t>();
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
test<int*>();
test<const int*>();
}

View File

@@ -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);
}

View File

@@ -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()
{
}

View File

@@ -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()
{
}

View File

@@ -0,0 +1,28 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <functional>
// template <class Arg1, class Arg2, class Result>
// struct binary_function
// {
// typedef Arg1 first_argument_type;
// typedef Arg2 second_argument_type;
// typedef Result result_type;
// };
#include <functional>
#include <type_traits>
int main()
{
static_assert((std::is_same<std::binary_function<int, unsigned, char>::first_argument_type, int>::value), "");
static_assert((std::is_same<std::binary_function<int, unsigned, char>::second_argument_type, unsigned>::value), "");
static_assert((std::is_same<std::binary_function<int, unsigned, char>::result_type, char>::value), "");
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <functional>
// template <class Arg, class Result>
// struct unary_function
// {
// typedef Arg argument_type;
// typedef Result result_type;
// };
#include <functional>
#include <type_traits>
int main()
{
static_assert((std::is_same<std::unary_function<unsigned, char>::argument_type, unsigned>::value), "");
static_assert((std::is_same<std::unary_function<unsigned, char>::result_type, char>::value), "");
}

View File

@@ -0,0 +1,12 @@
//===----------------------------------------------------------------------===//
//
// 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()
{
}

View File

@@ -3,6 +3,7 @@
# Configuration file for the 'lit' test runner.
import os
import sys
import platform
import tempfile
import signal
@@ -66,8 +67,9 @@ class LibcxxTestFormat(lit.formats.FileBasedTest):
exec_file.close()
try:
cmd = [self.cxx_under_test, '-o', exec_path,
compile_cmd = [self.cxx_under_test, '-o', exec_path,
source_path] + self.cpp_flags + self.ld_flags
cmd = compile_cmd
out, err, exitCode = self.execute_command(cmd)
if exitCode != 0:
report = """Command: %s\n""" % ' '.join(["'%s'" % a
@@ -83,7 +85,9 @@ class LibcxxTestFormat(lit.formats.FileBasedTest):
cmd = [exec_path]
out, err, exitCode = self.execute_command(cmd)
if exitCode != 0:
report = """Command: %s\n""" % ' '.join(["'%s'" % a
report = """Compiled With: %s\n""" % ' '.join(["'%s'" % a
for a in compile_cmd])
report += """Command: %s\n""" % ' '.join(["'%s'" % a
for a in cmd])
report += """Exit Code: %d\n""" % exitCode
if out:
@@ -111,12 +115,35 @@ config.test_source_root = os.path.dirname(__file__)
# FIXME: Would be nice to Use -stdlib=libc++ option with Clang's that accept it.
cxx_under_test = lit.params.get('cxx_under_test', None)
if cxx_under_test is None:
lit.fatal('must specify user parameter cxx_under_test '
'(e.g., --param=cxx_under_test=clang++)')
cxx_under_test = getattr(config, 'cxx_under_test', None)
if cxx_under_test is None:
lit.fatal('must specify user parameter cxx_under_test '
'(e.g., --param=cxx_under_test=clang++)')
include_paths = []
library_paths = []
libcxx_src_root = getattr(config, 'libcxx_src_root', None)
if libcxx_src_root is not None:
include_paths += ['-I' + libcxx_src_root + '/include']
else:
include_paths += ['-I/usr/include/c++/v1']
libcxx_obj_root = getattr(config, 'libcxx_obj_root', None)
if libcxx_obj_root is not None:
library_paths += ['-L' + libcxx_obj_root + '/lib']
else:
libcxx_obj_root = "/usr"
# Configure extra libraries.
libraries = []
if sys.platform == 'darwin':
libraries += ['-lSystem']
if sys.platform == 'linux2':
libraries += ['-lgcc_eh', '-lsupc++', '-lc', '-lm', '-lgcc_s']
libraries += ['-Wl,-R', libcxx_obj_root + '/lib']
config.test_format = LibcxxTestFormat(cxx_under_test,
cpp_flags = ['-nostdinc++',
'-I/usr/include/c++/v1'],
ld_flags = ['-nodefaultlibs', '-lc++',
'-lSystem'])
cpp_flags = ['-nostdinc++'] + include_paths,
ld_flags = ['-nodefaultlibs'] + library_paths + ['-lc++'] + libraries)
config.target_triple = None

10
test/lit.site.cfg.in Normal file
View File

@@ -0,0 +1,10 @@
@AUTO_GEN_COMMENT@
config.cxx_under_test = "@LIBCXX_COMPILER@"
config.cxx_has_stdcxx0x_flag = @LIBCXX_HAS_STDCXX0X_FLAG@
config.libcxx_src_root = "@LIBCXX_SOURCE_DIR@"
config.libcxx_obj_root = "@LIBCXX_BINARY_DIR@"
config.python_executable = "@PYTHON_EXECUTABLE@"
config.enable_shared = @LIBCXX_ENABLE_SHARED@
# Let the main config do the real work.
lit.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg")

View File

@@ -0,0 +1,43 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <regex>
// class match_results<BidirectionalIterator, Allocator>
// bool ready() const;
#include <regex>
#include <cassert>
void
test1()
{
std::match_results<const char*> m;
const char s[] = "abcdefghijk";
assert(m.ready() == false);
std::regex_search(s, m, std::regex("cd((e)fg)hi"));
assert(m.ready() == true);
}
void
test2()
{
std::match_results<const char*> m;
const char s[] = "abcdefghijk";
assert(m.ready() == false);
std::regex_search(s, m, std::regex("z"));
assert(m.ready() == true);
}
int main()
{
test1();
test2();
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <regex>
// template <class BidirectionalIterator> class sub_match;
// constexpr sub_match();
#include <regex>
#include <cassert>
int main()
{
{
typedef char CharT;
typedef std::sub_match<const CharT*> SM;
SM sm;
assert(sm.matched == false);
}
{
typedef wchar_t CharT;
typedef std::sub_match<const CharT*> SM;
SM sm;
assert(sm.matched == false);
}
}

View File

@@ -43,7 +43,7 @@ int main()
static_assert((std::is_same<
std::scoped_allocator_adaptor<A1<int>>::size_type,
std::size_t>::value), "");
std::make_unsigned<std::ptrdiff_t>::type>::value), "");
static_assert((std::is_same<
std::scoped_allocator_adaptor<A1<int>>::difference_type,

View File

@@ -11,23 +11,11 @@
// template <class... Types> class tuple;
// template <class... TTypes, class... UTypes>
// tuple<TTypes..., UTypes...>
// tuple_cat(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
//
// template <class... TTypes, class... UTypes>
// tuple<TTypes..., UTypes...>
// tuple_cat(const tuple<TTypes...>&& t, const tuple<UTypes...>& u);
//
// template <class... TTypes, class... UTypes>
// tuple<TTypes..., UTypes...>
// tuple_cat(const tuple<TTypes...>& t, const tuple<UTypes...>&& u);
//
// template <class... TTypes, class... UTypes>
// tuple<TTypes..., UTypes...>
// tuple_cat(const tuple<TTypes...>&& t, const tuple<UTypes...>&& u);
// template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls);
#include <tuple>
#include <utility>
#include <array>
#include <string>
#include <cassert>
@@ -35,6 +23,43 @@
int main()
{
{
std::tuple<> t = std::tuple_cat();
}
{
std::tuple<> t1;
std::tuple<> t2 = std::tuple_cat(t1);
}
{
std::tuple<> t = std::tuple_cat(std::tuple<>());
}
{
std::tuple<> t = std::tuple_cat(std::array<int, 0>());
}
{
std::tuple<int> t1(1);
std::tuple<int> t = std::tuple_cat(t1);
assert(std::get<0>(t) == 1);
}
{
std::tuple<int, MoveOnly> t =
std::tuple_cat(std::tuple<int, MoveOnly>(1, 2));
assert(std::get<0>(t) == 1);
assert(std::get<1>(t) == 2);
}
{
std::tuple<int, int, int> t = std::tuple_cat(std::array<int, 3>());
assert(std::get<0>(t) == 0);
assert(std::get<1>(t) == 0);
assert(std::get<2>(t) == 0);
}
{
std::tuple<int, MoveOnly> t = std::tuple_cat(std::pair<int, MoveOnly>(2, 1));
assert(std::get<0>(t) == 2);
assert(std::get<1>(t) == 1);
}
{
std::tuple<> t1;
std::tuple<> t2;
@@ -112,4 +137,54 @@ int main()
assert(std::get<2>(t3) == nullptr);
assert(std::get<3>(t3) == 4);
}
{
std::tuple<MoveOnly, MoveOnly> t1(1, 2);
std::tuple<int*, MoveOnly> t2(nullptr, 4);
std::tuple<MoveOnly, MoveOnly, int*, MoveOnly> t3 =
std::tuple_cat(std::tuple<>(),
std::move(t1),
std::move(t2));
assert(std::get<0>(t3) == 1);
assert(std::get<1>(t3) == 2);
assert(std::get<2>(t3) == nullptr);
assert(std::get<3>(t3) == 4);
}
{
std::tuple<MoveOnly, MoveOnly> t1(1, 2);
std::tuple<int*, MoveOnly> t2(nullptr, 4);
std::tuple<MoveOnly, MoveOnly, int*, MoveOnly> t3 =
std::tuple_cat(std::move(t1),
std::tuple<>(),
std::move(t2));
assert(std::get<0>(t3) == 1);
assert(std::get<1>(t3) == 2);
assert(std::get<2>(t3) == nullptr);
assert(std::get<3>(t3) == 4);
}
{
std::tuple<MoveOnly, MoveOnly> t1(1, 2);
std::tuple<int*, MoveOnly> t2(nullptr, 4);
std::tuple<MoveOnly, MoveOnly, int*, MoveOnly> t3 =
std::tuple_cat(std::move(t1),
std::move(t2),
std::tuple<>());
assert(std::get<0>(t3) == 1);
assert(std::get<1>(t3) == 2);
assert(std::get<2>(t3) == nullptr);
assert(std::get<3>(t3) == 4);
}
{
std::tuple<MoveOnly, MoveOnly> t1(1, 2);
std::tuple<int*, MoveOnly> t2(nullptr, 4);
std::tuple<MoveOnly, MoveOnly, int*, MoveOnly, int> t3 =
std::tuple_cat(std::move(t1),
std::move(t2),
std::tuple<int>(5));
assert(std::get<0>(t3) == 1);
assert(std::get<1>(t3) == 2);
assert(std::get<2>(t3) == nullptr);
assert(std::get<3>(t3) == 4);
assert(std::get<4>(t3) == 5);
}
}