diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-01-04 22:11:41 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-01-04 22:11:41 +0000 |
commit | cb08bb04c85c6dcd3d951725505317c31eeff323 (patch) | |
tree | affc3d589de957aeb81a9ba2d0849e2bddde7861 /include | |
parent | 53a420fba21cf1644972b34dcd811a43cdb8368d (diff) | |
download | src-test2-cb08bb04c85c6dcd3d951725505317c31eeff323.tar.gz src-test2-cb08bb04c85c6dcd3d951725505317c31eeff323.zip |
Notes
Diffstat (limited to 'include')
-rw-r--r-- | include/CMakeLists.txt | 10 | ||||
-rw-r--r-- | include/__config | 41 | ||||
-rw-r--r-- | include/__locale | 2 | ||||
-rw-r--r-- | include/__threading_support | 233 | ||||
-rw-r--r-- | include/__tuple | 21 | ||||
-rw-r--r-- | include/array | 28 | ||||
-rw-r--r-- | include/experimental/string_view | 7 | ||||
-rw-r--r-- | include/ios | 17 | ||||
-rw-r--r-- | include/iterator | 66 | ||||
-rw-r--r-- | include/new | 2 | ||||
-rw-r--r-- | include/support/win32/locale_win32.h | 6 | ||||
-rw-r--r-- | include/support/win32/support.h | 13 | ||||
-rw-r--r-- | include/system_error | 3 | ||||
-rw-r--r-- | include/tuple | 2 | ||||
-rw-r--r-- | include/type_traits | 4 |
15 files changed, 274 insertions, 181 deletions
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 7b574353193d..1c6790ab4652 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -28,15 +28,13 @@ if (LIBCXX_INSTALL_HEADERS) ) if (LIBCXX_NEEDS_SITE_CONFIG) - set(UNIX_CAT cat) - if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") - set(UNIX_CAT type) - endif() # Generate and install a custom __config header. The new header is created # by prepending __config_site to the current __config header. add_custom_command(OUTPUT ${LIBCXX_BINARY_DIR}/__generated_config - COMMAND ${CMAKE_COMMAND} -E copy ${LIBCXX_BINARY_DIR}/__config_site ${LIBCXX_BINARY_DIR}/__generated_config - COMMAND ${UNIX_CAT} ${LIBCXX_SOURCE_DIR}/include/__config >> ${LIBCXX_BINARY_DIR}/__generated_config + COMMAND ${PYTHON_EXECUTABLE} ${LIBCXX_SOURCE_DIR}/utils/cat_files.py + ${LIBCXX_BINARY_DIR}/__config_site + ${LIBCXX_SOURCE_DIR}/include/__config + -o ${LIBCXX_BINARY_DIR}/__generated_config DEPENDS ${LIBCXX_SOURCE_DIR}/include/__config ${LIBCXX_BINARY_DIR}/__config_site ) diff --git a/include/__config b/include/__config index 321e71778228..269d8635d96a 100644 --- a/include/__config +++ b/include/__config @@ -53,6 +53,10 @@ // of nullptr_t. This option is ABI incompatible with GCC in C++03 mode. #define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR #elif _LIBCPP_ABI_VERSION == 1 +#if !defined(_WIN32) +// Enable compiling a definition of error_category() into the libc++ dylib. +#define _LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR +#endif // Feature macros for disabling pre ABI v1 features. All of these options // are deprecated. #if defined(__FreeBSD__) @@ -150,11 +154,13 @@ # define _LIBCPP_HAS_QUICK_EXIT #endif // __NetBSD__ -#ifdef _WIN32 +#if defined(_WIN32) +# define _LIBCPP_WIN32API 1 # define _LIBCPP_LITTLE_ENDIAN 1 # define _LIBCPP_BIG_ENDIAN 0 +# define _LIBCPP_SHORT_WCHAR 1 // Compiler intrinsics (MSVC) -#if defined(_MSC_VER) && _MSC_VER >= 1400 +# if defined(_MSC_VER) && _MSC_VER >= 1400 # define _LIBCPP_HAS_IS_BASE_OF # endif # if defined(_MSC_VER) && !defined(__clang__) @@ -163,11 +169,14 @@ # define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) # define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x)) # endif -# // If mingw not explicitly detected, assume using MS C runtime only. +// If mingw not explicitly detected, assume using MS C runtime only. # ifndef __MINGW32__ # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library # endif -#endif // _WIN32 +# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__)) +# define _LIBCPP_HAS_BITSCAN64 +# endif +#endif // defined(_WIN32) #ifdef __sun__ # include <sys/isa_defs.h> @@ -191,7 +200,7 @@ // including accesses to the special files under /dev. C++11's // std::random_device is instead exposed through a NaCl syscall. # define _LIBCPP_USING_NACL_RANDOM -#elif defined(_WIN32) +#elif defined(_LIBCPP_WIN32API) # define _LIBCPP_USING_WIN32_RANDOM #else # define _LIBCPP_USING_DEV_RANDOM @@ -466,7 +475,9 @@ using namespace _LIBCPP_NAMESPACE __attribute__((__strong__)); #define _LIBCPP_HAS_NO_CONSTEXPR #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES +#if _MSC_VER <= 1800 #define _LIBCPP_HAS_NO_UNICODE_CHARS +#endif #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS #define _LIBCPP_HAS_NO_NOEXCEPT #define __alignof__ __alignof @@ -516,8 +527,15 @@ namespace std { #endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__ +#if defined(__ELF__) +#define _LIBCPP_OBJECT_FORMAT_ELF 1 +#elif defined(__MACH__) +#define _LIBCPP_OBJECT_FORMAT_MACHO 1 +#else +#define _LIBCPP_OBJECT_FORMAT_COFF 1 +#endif -#ifdef _WIN32 +#if defined(_LIBCPP_OBJECT_FORMAT_COFF) #if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) # define _LIBCPP_DLL_VIS # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS @@ -542,6 +560,7 @@ namespace std { #define _LIBCPP_TYPE_VIS_ONLY #define _LIBCPP_FUNC_VIS_ONLY #define _LIBCPP_ENUM_VIS + #if defined(_LIBCPP_MSVC) # define _LIBCPP_INLINE_VISIBILITY __forceinline # define _LIBCPP_ALWAYS_INLINE __forceinline @@ -551,7 +570,7 @@ namespace std { # define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) # define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__ ((__always_inline__)) #endif -#endif // _WIN32 +#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) #ifndef _LIBCPP_HIDDEN #if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) @@ -727,7 +746,7 @@ template <unsigned> struct __static_assert_check {}; #define _NOALIAS #endif -#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \ +#if __has_extension(cxx_explicit_conversions) || defined(__IBMCPP__) || \ (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions # define _LIBCPP_EXPLICIT explicit #else @@ -774,14 +793,14 @@ template <unsigned> struct __static_assert_check {}; #define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63) #endif -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || \ +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT) || \ defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__) #define _LIBCPP_LOCALE__L_EXTENSIONS 1 #endif #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) // Most unix variants have catopen. These are the specific ones that don't. -#if !defined(_WIN32) && !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) +#if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) #define _LIBCPP_HAS_CATOPEN 1 #endif #endif @@ -955,7 +974,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( #endif #if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) -#if defined(_WIN32) || defined(_NEWLIB_VERSION) +#if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION) #define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS #endif #endif diff --git a/include/__locale b/include/__locale index 535ee165f652..3f29bc5e9941 100644 --- a/include/__locale +++ b/include/__locale @@ -342,7 +342,7 @@ public: static const mask punct = _ISpunct; static const mask xdigit = _ISxdigit; static const mask blank = _ISblank; -#elif defined(_WIN32) +#elif defined(_LIBCPP_MSVCRT) typedef unsigned short mask; static const mask space = _SPACE; static const mask print = _BLANK|_PUNCT|_ALPHA|_DIGIT; diff --git a/include/__threading_support b/include/__threading_support index 36f1701f178c..b1eaf25ae8a4 100644 --- a/include/__threading_support +++ b/include/__threading_support @@ -28,11 +28,26 @@ #endif #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && \ + !__libcpp_has_include(<__external_threading>) +// If the <__external_threading> header is absent, build libc++ against a +// pthread-oriented thread api but leave out its implementation. This setup +// allows building+testing of an externally-threaded library variant (on any +// platform that supports pthreads). Here, an 'externally-threaded' library +// variant is one where the implementation of the libc++ thread api is provided +// as a separate library. +#define _LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD +#endif + +#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && \ __libcpp_has_include(<__external_threading>) #include <__external_threading> #else + +#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \ + defined(_LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD) #include <pthread.h> #include <sched.h> +#endif #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) #define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS @@ -42,200 +57,258 @@ _LIBCPP_BEGIN_NAMESPACE_STD +#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \ + defined(_LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD) // Mutex typedef pthread_mutex_t __libcpp_mutex_t; #define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER +// Condition Variable +typedef pthread_cond_t __libcpp_condvar_t; +#define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER + +// Execute once +typedef pthread_once_t __libcpp_exec_once_flag; +#define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT + +// Thread id +typedef pthread_t __libcpp_thread_id; + +// Thread +typedef pthread_t __libcpp_thread_t; + +// Thrad Local Storage +typedef pthread_key_t __libcpp_tls_key; +#endif + +// Mutex _LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m); +int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m); + _LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_mutex_lock(__libcpp_mutex_t* __m); +int __libcpp_mutex_lock(__libcpp_mutex_t *__m); + _LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_mutex_trylock(__libcpp_mutex_t* __m); +int __libcpp_mutex_trylock(__libcpp_mutex_t *__m); + _LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_mutex_unlock(__libcpp_mutex_t* __m); +int __libcpp_mutex_unlock(__libcpp_mutex_t *__m); + _LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_mutex_destroy(__libcpp_mutex_t* __m); +int __libcpp_mutex_destroy(__libcpp_mutex_t *__m); // Condition variable -typedef pthread_cond_t __libcpp_condvar_t; -#define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_condvar_signal(__libcpp_condvar_t* __cv); + _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv); + _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m); + _LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, timespec* __ts); +int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m, + timespec *__ts); + _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv); +// Execute once +_LIBCPP_THREAD_ABI_VISIBILITY +int __libcpp_execute_once(__libcpp_exec_once_flag *flag, + void (*init_routine)(void)); + // Thread id -typedef pthread_t __libcpp_thread_id; +#if defined(__APPLE__) && !defined(__arm__) +_LIBCPP_THREAD_ABI_VISIBILITY +mach_port_t __libcpp_thread_get_port(); +#endif + _LIBCPP_THREAD_ABI_VISIBILITY bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2); + _LIBCPP_THREAD_ABI_VISIBILITY bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2); // Thread -typedef pthread_t __libcpp_thread_t; _LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg); +int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *), + void *__arg); + _LIBCPP_THREAD_ABI_VISIBILITY __libcpp_thread_id __libcpp_thread_get_current_id(); + _LIBCPP_THREAD_ABI_VISIBILITY -__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t); +__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t); + _LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_thread_join(__libcpp_thread_t* __t); +int __libcpp_thread_join(__libcpp_thread_t *__t); + _LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_thread_detach(__libcpp_thread_t* __t); +int __libcpp_thread_detach(__libcpp_thread_t *__t); + _LIBCPP_THREAD_ABI_VISIBILITY void __libcpp_thread_yield(); // Thread local storage -typedef pthread_key_t __libcpp_tls_key; _LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_tls_create(__libcpp_tls_key* __key, void (*__at_exit)(void*)); +int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *)); + _LIBCPP_THREAD_ABI_VISIBILITY -void* __libcpp_tls_get(__libcpp_tls_key __key); +void *__libcpp_tls_get(__libcpp_tls_key __key); + _LIBCPP_THREAD_ABI_VISIBILITY -void __libcpp_tls_set(__libcpp_tls_key __key, void* __p); +int __libcpp_tls_set(__libcpp_tls_key __key, void *__p); -#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || defined(_LIBCPP_BUILDING_EXTERNAL_THREADS) +#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \ + defined(_LIBCPP_BUILDING_THREAD_API_EXTERNAL_PTHREAD) -int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m) +int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m) { - pthread_mutexattr_t attr; - int __ec = pthread_mutexattr_init(&attr); - if (__ec) return __ec; - __ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - if (__ec) - { - pthread_mutexattr_destroy(&attr); - return __ec; - } - __ec = pthread_mutex_init(__m, &attr); - if (__ec) - { - pthread_mutexattr_destroy(&attr); - return __ec; - } - __ec = pthread_mutexattr_destroy(&attr); - if (__ec) - { - pthread_mutex_destroy(__m); - return __ec; - } - return 0; + pthread_mutexattr_t attr; + int __ec = pthread_mutexattr_init(&attr); + if (__ec) + return __ec; + __ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + if (__ec) { + pthread_mutexattr_destroy(&attr); + return __ec; + } + __ec = pthread_mutex_init(__m, &attr); + if (__ec) { + pthread_mutexattr_destroy(&attr); + return __ec; + } + __ec = pthread_mutexattr_destroy(&attr); + if (__ec) { + pthread_mutex_destroy(__m); + return __ec; + } + return 0; } -int __libcpp_mutex_lock(__libcpp_mutex_t* __m) +int __libcpp_mutex_lock(__libcpp_mutex_t *__m) { - return pthread_mutex_lock(__m); + return pthread_mutex_lock(__m); } -int __libcpp_mutex_trylock(__libcpp_mutex_t* __m) +int __libcpp_mutex_trylock(__libcpp_mutex_t *__m) { - return pthread_mutex_trylock(__m); + return pthread_mutex_trylock(__m); } -int __libcpp_mutex_unlock(__libcpp_mutex_t* __m) +int __libcpp_mutex_unlock(__libcpp_mutex_t *__m) { - return pthread_mutex_unlock(__m); + return pthread_mutex_unlock(__m); } -int __libcpp_mutex_destroy(__libcpp_mutex_t* __m) +int __libcpp_mutex_destroy(__libcpp_mutex_t *__m) { - return pthread_mutex_destroy(__m); + return pthread_mutex_destroy(__m); } -// Condition variable -int __libcpp_condvar_signal(__libcpp_condvar_t* __cv) +// Condition Variable +int __libcpp_condvar_signal(__libcpp_condvar_t *__cv) { - return pthread_cond_signal(__cv); + return pthread_cond_signal(__cv); } -int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv) +int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv) { - return pthread_cond_broadcast(__cv); + return pthread_cond_broadcast(__cv); } -int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m) +int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m) { - return pthread_cond_wait(__cv, __m); + return pthread_cond_wait(__cv, __m); } -int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, timespec* __ts) +int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m, + timespec *__ts) { - return pthread_cond_timedwait(__cv, __m, __ts); + return pthread_cond_timedwait(__cv, __m, __ts); } -int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv) +int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv) { - return pthread_cond_destroy(__cv); + return pthread_cond_destroy(__cv); } +// Execute once +int __libcpp_execute_once(__libcpp_exec_once_flag *flag, + void (*init_routine)(void)) { + return pthread_once(flag, init_routine); +} + +// Thread id +#if defined(__APPLE__) && !defined(__arm__) +mach_port_t __libcpp_thread_get_port() { + return pthread_mach_thread_np(pthread_self()); +} +#endif + // Returns non-zero if the thread ids are equal, otherwise 0 bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2) { - return pthread_equal(t1, t2) != 0; + return pthread_equal(t1, t2) != 0; } // Returns non-zero if t1 < t2, otherwise 0 bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2) { - return t1 < t2; + return t1 < t2; } // Thread -int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg) +int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *), + void *__arg) { - return pthread_create(__t, 0, __func, __arg); + return pthread_create(__t, 0, __func, __arg); } __libcpp_thread_id __libcpp_thread_get_current_id() { - return pthread_self(); + return pthread_self(); } -__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t) +__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t) { - return *__t; + return *__t; } -int __libcpp_thread_join(__libcpp_thread_t* __t) +int __libcpp_thread_join(__libcpp_thread_t *__t) { - return pthread_join(*__t, 0); + return pthread_join(*__t, 0); } -int __libcpp_thread_detach(__libcpp_thread_t* __t) +int __libcpp_thread_detach(__libcpp_thread_t *__t) { - return pthread_detach(*__t); + return pthread_detach(*__t); } void __libcpp_thread_yield() { - sched_yield(); + sched_yield(); } // Thread local storage -int __libcpp_tls_create(__libcpp_tls_key* __key, void (*__at_exit)(void*)) +int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *)) { - return pthread_key_create(__key, __at_exit); + return pthread_key_create(__key, __at_exit); } -void* __libcpp_tls_get(__libcpp_tls_key __key) +void *__libcpp_tls_get(__libcpp_tls_key __key) { - return pthread_getspecific(__key); + return pthread_getspecific(__key); } -void __libcpp_tls_set(__libcpp_tls_key __key, void* __p) +int __libcpp_tls_set(__libcpp_tls_key __key, void *__p) { - pthread_setspecific(__key, __p); + return pthread_setspecific(__key, __p); } -#endif // _LIBCPP_HAS_THREAD_API_PTHREAD || _LIBCPP_BUILDING_EXTERNAL_THREADS +#endif // _LIBCPP_HAS_THREAD_API_PTHREAD _LIBCPP_END_NAMESPACE_STD diff --git a/include/__tuple b/include/__tuple index 775d7340b54d..7aad08163662 100644 --- a/include/__tuple +++ b/include/__tuple @@ -22,19 +22,32 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_size {}; +template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_size; + +struct __empty_tuple_size_base {}; + +template <class _Tp, class = void> +struct __tuple_size_base_type { + typedef __empty_tuple_size_base type; +}; + +template <class _Tp> +struct __tuple_size_base_type<_Tp, typename __void_t<decltype(tuple_size<_Tp>::value)>::type> +{ + typedef integral_constant<size_t, tuple_size<_Tp>::value> type; +}; template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_size<const _Tp> - : public tuple_size<_Tp> {}; + : public __tuple_size_base_type<_Tp>::type {}; template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_size<volatile _Tp> - : public tuple_size<_Tp> {}; + : public __tuple_size_base_type<_Tp>::type {}; template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_size<const volatile _Tp> - : public tuple_size<_Tp> {}; + : public __tuple_size_base_type<_Tp>::type {}; template <size_t _Ip, class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_element; diff --git a/include/array b/include/array index d3f8463cf664..7e205cbf8e48 100644 --- a/include/array +++ b/include/array @@ -149,31 +149,31 @@ struct _LIBCPP_TYPE_VIS_ONLY array { _VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);} // iterators: - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 iterator begin() _NOEXCEPT {return iterator(__elems_);} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 const_iterator begin() const _NOEXCEPT {return const_iterator(__elems_);} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 iterator end() _NOEXCEPT {return iterator(__elems_ + _Size);} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 const_iterator end() const _NOEXCEPT {return const_iterator(__elems_ + _Size);} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 const_iterator cbegin() const _NOEXCEPT {return begin();} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 const_iterator cend() const _NOEXCEPT {return end();} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 const_reverse_iterator crend() const _NOEXCEPT {return rend();} // capacity: @@ -195,9 +195,9 @@ struct _LIBCPP_TYPE_VIS_ONLY array _LIBCPP_INLINE_VISIBILITY reference back() {return __elems_[_Size > 0 ? _Size-1 : 0];} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const {return __elems_[_Size > 0 ? _Size-1 : 0];} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 value_type* data() _NOEXCEPT {return __elems_;} - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 const value_type* data() const _NOEXCEPT {return __elems_;} }; diff --git a/include/experimental/string_view b/include/experimental/string_view index a62fe6e95a10..ccc886ea98f7 100644 --- a/include/experimental/string_view +++ b/include/experimental/string_view @@ -340,7 +340,12 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS // [string.view.ops], string operations: template<class _Allocator> _LIBCPP_INLINE_VISIBILITY - _LIBCPP_EXPLICIT operator basic_string<_CharT, _Traits, _Allocator>() const + // Clang's extended C++11 explict conversions don't work with + // string_view in C++03. +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_EXPLICIT +#endif + operator basic_string<_CharT, _Traits, _Allocator>() const { return basic_string<_CharT, _Traits, _Allocator>( begin(), end()); } template<class _Allocator = allocator<_CharT> > diff --git a/include/ios b/include/ios index fb8f88dddab2..ea83822ac169 100644 --- a/include/ios +++ b/include/ios @@ -572,13 +572,6 @@ ios_base::exceptions(iostate __iostate) clear(__rdstate_); } -#if defined(_LIBCPP_CXX03_LANG) -struct _LIBCPP_TYPE_VIS_ONLY __cxx03_bool { - typedef void (__cxx03_bool::*__bool_type)(); - void __true_value() {} -}; -#endif - template <class _CharT, class _Traits> class _LIBCPP_TYPE_VIS_ONLY basic_ios : public ios_base @@ -592,18 +585,8 @@ public: typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; - // __true_value will generate undefined references when linking unless - // we give it internal linkage. - -#if defined(_LIBCPP_CXX03_LANG) - _LIBCPP_ALWAYS_INLINE - operator __cxx03_bool::__bool_type() const { - return !fail() ? &__cxx03_bool::__true_value : nullptr; - } -#else _LIBCPP_ALWAYS_INLINE _LIBCPP_EXPLICIT operator bool() const {return !fail();} -#endif _LIBCPP_ALWAYS_INLINE bool operator!() const {return fail();} _LIBCPP_ALWAYS_INLINE iostate rdstate() const {return ios_base::rdstate();} diff --git a/include/iterator b/include/iterator index ba9a83b9e5e5..797ec5332e39 100644 --- a/include/iterator +++ b/include/iterator @@ -378,25 +378,25 @@ public: bool failed() const noexcept; }; -template <class C> auto begin(C& c) -> decltype(c.begin()); -template <class C> auto begin(const C& c) -> decltype(c.begin()); -template <class C> auto end(C& c) -> decltype(c.end()); -template <class C> auto end(const C& c) -> decltype(c.end()); -template <class T, size_t N> T* begin(T (&array)[N]); -template <class T, size_t N> T* end(T (&array)[N]); - -template <class C> auto cbegin(const C& c) -> decltype(std::begin(c)); // C++14 -template <class C> auto cend(const C& c) -> decltype(std::end(c)); // C++14 -template <class C> auto rbegin(C& c) -> decltype(c.rbegin()); // C++14 -template <class C> auto rbegin(const C& c) -> decltype(c.rbegin()); // C++14 -template <class C> auto rend(C& c) -> decltype(c.rend()); // C++14 -template <class C> auto rend(const C& c) -> decltype(c.rend()); // C++14 -template <class E> reverse_iterator<const E*> rbegin(initializer_list<E> il); // C++14 -template <class E> reverse_iterator<const E*> rend(initializer_list<E> il); // C++14 -template <class T, size_t N> reverse_iterator<T*> rbegin(T (&array)[N]); // C++14 -template <class T, size_t N> reverse_iterator<T*> rend(T (&array)[N]); // C++14 -template <class C> auto crbegin(const C& c) -> decltype(std::rbegin(c)); // C++14 -template <class C> auto crend(const C& c) -> decltype(std::rend(c)); // C++14 +template <class C> constexpr auto begin(C& c) -> decltype(c.begin()); +template <class C> constexpr auto begin(const C& c) -> decltype(c.begin()); +template <class C> constexpr auto end(C& c) -> decltype(c.end()); +template <class C> constexpr auto end(const C& c) -> decltype(c.end()); +template <class T, size_t N> constexpr T* begin(T (&array)[N]); +template <class T, size_t N> constexpr T* end(T (&array)[N]); + +template <class C> auto constexpr cbegin(const C& c) -> decltype(std::begin(c)); // C++14 +template <class C> auto constexpr cend(const C& c) -> decltype(std::end(c)); // C++14 +template <class C> auto constexpr rbegin(C& c) -> decltype(c.rbegin()); // C++14 +template <class C> auto constexpr rbegin(const C& c) -> decltype(c.rbegin()); // C++14 +template <class C> auto constexpr rend(C& c) -> decltype(c.rend()); // C++14 +template <class C> constexpr auto rend(const C& c) -> decltype(c.rend()); // C++14 +template <class E> reverse_iterator<const E*> constexpr rbegin(initializer_list<E> il); // C++14 +template <class E> reverse_iterator<const E*> constexpr rend(initializer_list<E> il); // C++14 +template <class T, size_t N> reverse_iterator<T*> constexpr rbegin(T (&array)[N]); // C++14 +template <class T, size_t N> reverse_iterator<T*> constexpr rend(T (&array)[N]); // C++14 +template <class C> constexpr auto crbegin(const C& c) -> decltype(std::rbegin(c)); // C++14 +template <class C> constexpr auto crend(const C& c) -> decltype(std::rend(c)); // C++14 // 24.8, container access: template <class C> constexpr auto size(const C& c) -> decltype(c.size()); // C++17 @@ -1616,7 +1616,7 @@ end(_Tp (&__array)[_Np]) #if !defined(_LIBCPP_CXX03_LANG) template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 auto begin(_Cp& __c) -> decltype(__c.begin()) { @@ -1624,7 +1624,7 @@ begin(_Cp& __c) -> decltype(__c.begin()) } template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 auto begin(const _Cp& __c) -> decltype(__c.begin()) { @@ -1632,7 +1632,7 @@ begin(const _Cp& __c) -> decltype(__c.begin()) } template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 auto end(_Cp& __c) -> decltype(__c.end()) { @@ -1640,7 +1640,7 @@ end(_Cp& __c) -> decltype(__c.end()) } template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 auto end(const _Cp& __c) -> decltype(__c.end()) { @@ -1650,28 +1650,28 @@ end(const _Cp& __c) -> decltype(__c.end()) #if _LIBCPP_STD_VER > 11 template <class _Tp, size_t _Np> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np]) { return reverse_iterator<_Tp*>(__array + _Np); } template <class _Tp, size_t _Np> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np]) { return reverse_iterator<_Tp*>(__array); } template <class _Ep> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il) { return reverse_iterator<const _Ep*>(__il.end()); } template <class _Ep> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il) { return reverse_iterator<const _Ep*>(__il.begin()); @@ -1692,42 +1692,42 @@ auto cend(const _Cp& __c) -> decltype(_VSTD::end(__c)) } template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 auto rbegin(_Cp& __c) -> decltype(__c.rbegin()) { return __c.rbegin(); } template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 auto rbegin(const _Cp& __c) -> decltype(__c.rbegin()) { return __c.rbegin(); } template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 auto rend(_Cp& __c) -> decltype(__c.rend()) { return __c.rend(); } template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 auto rend(const _Cp& __c) -> decltype(__c.rend()) { return __c.rend(); } template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 auto crbegin(const _Cp& __c) -> decltype(_VSTD::rbegin(__c)) { return _VSTD::rbegin(__c); } template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c)) { return _VSTD::rend(__c); diff --git a/include/new b/include/new index 6b432f231bf6..442e113665dd 100644 --- a/include/new +++ b/include/new @@ -162,7 +162,7 @@ _LIBCPP_FUNC_VIS new_handler get_new_handler() _NOEXCEPT; } // std -#if !__has_feature(cxx_noexcept) +#if defined(_LIBCPP_CXX03_LANG) #define _THROW_BAD_ALLOC throw(std::bad_alloc) #else #define _THROW_BAD_ALLOC diff --git a/include/support/win32/locale_win32.h b/include/support/win32/locale_win32.h index 0f5527e570ab..ebf5bda740a5 100644 --- a/include/support/win32/locale_win32.h +++ b/include/support/win32/locale_win32.h @@ -11,8 +11,12 @@ #ifndef _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H #define _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H +#include <crtversion.h> + +#if _VC_CRT_MAJOR_VERSION < 14 // ctype mask table defined in msvcrt.dll -extern "C" unsigned short __declspec(dllimport) _ctype[]; +extern "C" unsigned short __declspec(dllimport) _ctype[]; +#endif #include "support/win32/support.h" #include "support/win32/locale_mgmt_win32.h" diff --git a/include/support/win32/support.h b/include/support/win32/support.h index 6a5763b5e49b..17ee1980a643 100644 --- a/include/support/win32/support.h +++ b/include/support/win32/support.h @@ -110,10 +110,11 @@ _LIBCPP_ALWAYS_INLINE int __builtin_ctzll(unsigned long long mask) unsigned long where; // Search from LSB to MSB for first set bit. // Returns zero if no set bit is found. -#if defined(_WIN64) +#if defined(_LIBCPP_HAS_BITSCAN64) + (defined(_M_AMD64) || defined(__x86_64__)) if (_BitScanForward64(&where, mask)) return static_cast<int>(where); -#elif defined(_WIN32) +#else // Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls. // Scan the Low Word. if (_BitScanForward(&where, static_cast<unsigned long>(mask))) @@ -121,8 +122,6 @@ _LIBCPP_ALWAYS_INLINE int __builtin_ctzll(unsigned long long mask) // Scan the High Word. if (_BitScanForward(&where, static_cast<unsigned long>(mask >> 32))) return static_cast<int>(where + 32); // Create a bit offset from the LSB. -#else -#error "Implementation of __builtin_ctzll required" #endif return 64; } @@ -152,10 +151,10 @@ _LIBCPP_ALWAYS_INLINE int __builtin_clzll(unsigned long long mask) unsigned long where; // BitScanReverse scans from MSB to LSB for first set bit. // Returns 0 if no set bit is found. -#if defined(_WIN64) +#if defined(_LIBCPP_HAS_BITSCAN64) if (_BitScanReverse64(&where, mask)) return static_cast<int>(63 - where); -#elif defined(_WIN32) +#else // Scan the high 32 bits. if (_BitScanReverse(&where, static_cast<unsigned long>(mask >> 32))) return static_cast<int>(63 - @@ -163,8 +162,6 @@ _LIBCPP_ALWAYS_INLINE int __builtin_clzll(unsigned long long mask) // Scan the low 32 bits. if (_BitScanReverse(&where, static_cast<unsigned long>(mask))) return static_cast<int>(63 - where); -#else -#error "Implementation of __builtin_clzll required" #endif return 64; // Undefined Behavior. } diff --git a/include/system_error b/include/system_error index c7e73d4ab82b..58040639d3ec 100644 --- a/include/system_error +++ b/include/system_error @@ -384,7 +384,8 @@ class _LIBCPP_TYPE_VIS error_category public: virtual ~error_category() _NOEXCEPT; -#ifdef _LIBCPP_BUILDING_SYSTEM_ERROR +#if defined(_LIBCPP_BUILDING_SYSTEM_ERROR) && \ + defined(_LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR) error_category() _NOEXCEPT; #else _LIBCPP_ALWAYS_INLINE diff --git a/include/tuple b/include/tuple index 553d8e546f89..2f71cce74139 100644 --- a/include/tuple +++ b/include/tuple @@ -84,7 +84,7 @@ template <class T, class Tuple> constexpr T make_from_tuple(Tuple&& t); // C++17 // 20.4.1.4, tuple helper classes: -template <class T> class tuple_size; +template <class T> class tuple_size; // undefined template <class... T> class tuple_size<tuple<T...>>; template <class T> constexpr size_t tuple_size_v = tuple_size<T>::value; // C++17 diff --git a/include/type_traits b/include/type_traits index e2b537799dcc..db9c1d11c983 100644 --- a/include/type_traits +++ b/include/type_traits @@ -1681,9 +1681,9 @@ _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000); // PE/COFF does not support alignment beyond 8192 (=0x2000) -#if !defined(_WIN32) +#if !defined(_LIBCPP_OBJECT_FORMAT_COFF) _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000); -#endif // !_WIN32 +#endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF) #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION |