diff options
Diffstat (limited to 'system/lib/libcxx')
25 files changed, 1318 insertions, 1134 deletions
diff --git a/system/lib/libcxx/CREDITS.TXT b/system/lib/libcxx/CREDITS.TXT index 52948510..368b526f 100644 --- a/system/lib/libcxx/CREDITS.TXT +++ b/system/lib/libcxx/CREDITS.TXT @@ -31,6 +31,14 @@ D: FreeBSD and Solaris ports, libcxxrt support, some atomics work. N: Marshall Clow E: mclow.lists@gmail.com E: marshall@idio.com +D: C++14 support, patches and bug fixes. + +N: Bill Fisher +E: william.w.fisher@gmail.com +D: Regex bug fixes. + +N: Matthew Dempsky +E: matthew@dempsky.org D: Minor patches and bug fixes. N: Google Inc. @@ -48,6 +56,10 @@ N: Argyrios Kyrtzidis E: kyrtzidis@apple.com D: Bug fixes. +N: Bruce Mitchener, Jr. +E: bruce.mitchener@gmail.com +D: Emscripten-related changes. + N: Michel Morin E: mimomorin@gmail.com D: Minor patches to is_convertible. @@ -64,6 +76,10 @@ N: Bjorn Reese E: breese@users.sourceforge.net D: Initial regex prototype +N: Nico Rieck +E: nico.rieck@gmail.com +D: Windows fixes + N: Jonathan Sauer D: Minor patches, mostly related to constexpr @@ -74,6 +90,14 @@ D: Implemented Cityhash as the string hash function on 64-bit machines N: Richard Smith D: Minor patches. +N: Joerg Sonnenberger +E: joerg@NetBSD.org +D: NetBSD port. + +N: Stephan Tolksdorf +E: st@quanttec.com +D: Minor <atomic> fix + N: Michael van der Westhuizen E: r1mikey at gmail dot com @@ -85,6 +109,14 @@ N: Zhang Xiongpang E: zhangxiongpang@gmail.com D: Minor patches and bug fixes. +N: Xing Xue +E: xingxue@ca.ibm.com +D: AIX port + +N: Zhihao Yuan +E: lichray@gmail.com +D: Standard compatibility fixes. + N: Jeffrey Yasskin E: jyasskin@gmail.com E: jyasskin@google.com diff --git a/system/lib/libcxx/algorithm.cpp b/system/lib/libcxx/algorithm.cpp index 6d5cf7c0..10c4c331 100644 --- a/system/lib/libcxx/algorithm.cpp +++ b/system/lib/libcxx/algorithm.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; #include "algorithm" #include "random" #include "mutex" diff --git a/system/lib/libcxx/debug.cpp b/system/lib/libcxx/debug.cpp index 2d4b094b..d0e86795 100644 --- a/system/lib/libcxx/debug.cpp +++ b/system/lib/libcxx/debug.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#define _LIBCPP_DEBUG2 1 +#define _LIBCPP_DEBUG 1 #include "__config" #include "__debug" #include "functional" @@ -110,8 +110,7 @@ __libcpp_db::__find_c_from_i(void* __i) const { RLock _(mut()); __i_node* i = __find_iterator(__i); - _LIBCPP_ASSERT(i != nullptr, "iterator constructed in translation unit with debug mode not enabled." - " #define _LIBCPP_DEBUG2 1 for that translation unit."); + _LIBCPP_ASSERT(i != nullptr, "iterator not found in debug database."); return i->__c_ != nullptr ? i->__c_->__c_ : nullptr; } @@ -119,20 +118,19 @@ void __libcpp_db::__insert_ic(void* __i, const void* __c) { WLock _(mut()); - __i_node* i = __insert_iterator(__i); - const char* errmsg = - "Container constructed in a translation unit with debug mode disabled." - " But it is being used in a translation unit with debug mode enabled." - " Enable it in the other translation unit with #define _LIBCPP_DEBUG2 1"; - _LIBCPP_ASSERT(__cbeg_ != __cend_, errmsg); + if (__cbeg_ == __cend_) + return; size_t hc = hash<const void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); __c_node* c = __cbeg_[hc]; - _LIBCPP_ASSERT(c != nullptr, errmsg); + if (c == nullptr) + return; while (c->__c_ != __c) { c = c->__next_; - _LIBCPP_ASSERT(c != nullptr, errmsg); + if (c == nullptr) + return; } + __i_node* i = __insert_iterator(__i); c->__add(i); i->__c_ = c; } @@ -144,7 +142,7 @@ __libcpp_db::__insert_c(void* __c) if (__csz_ + 1 > static_cast<size_t>(__cend_ - __cbeg_)) { size_t nc = __next_prime(2*static_cast<size_t>(__cend_ - __cbeg_) + 1); - __c_node** cbeg = (__c_node**)calloc(nc, sizeof(void*)); + __c_node** cbeg = static_cast<__c_node**>(calloc(nc, sizeof(void*))); if (cbeg == nullptr) #ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); @@ -169,7 +167,8 @@ __libcpp_db::__insert_c(void* __c) } size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); __c_node* p = __cbeg_[hc]; - __c_node* r = __cbeg_[hc] = (__c_node*)malloc(sizeof(__c_node)); + __c_node* r = __cbeg_[hc] = + static_cast<__c_node*>(malloc(sizeof(__c_node))); if (__cbeg_[hc] == nullptr) #ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); @@ -217,18 +216,23 @@ void __libcpp_db::__invalidate_all(void* __c) { WLock _(mut()); - size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); - __c_node* p = __cbeg_[hc]; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __invalidate_all A"); - while (p->__c_ != __c) - { - p = p->__next_; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __invalidate_all B"); - } - while (p->end_ != p->beg_) + if (__cend_ != __cbeg_) { - --p->end_; - (*p->end_)->__c_ = nullptr; + size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); + __c_node* p = __cbeg_[hc]; + if (p == nullptr) + return; + while (p->__c_ != __c) + { + p = p->__next_; + if (p == nullptr) + return; + } + while (p->end_ != p->beg_) + { + --p->end_; + (*p->end_)->__c_ = nullptr; + } } } @@ -236,13 +240,26 @@ __c_node* __libcpp_db::__find_c_and_lock(void* __c) const { mut().lock(); + if (__cend_ == __cbeg_) + { + mut().unlock(); + return nullptr; + } size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); __c_node* p = __cbeg_[hc]; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c_and_lock A"); + if (p == nullptr) + { + mut().unlock(); + return nullptr; + } while (p->__c_ != __c) { p = p->__next_; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c_and_lock B"); + if (p == nullptr) + { + mut().unlock(); + return nullptr; + } } return p; } @@ -271,28 +288,35 @@ void __libcpp_db::__erase_c(void* __c) { WLock _(mut()); - size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); - __c_node* p = __cbeg_[hc]; - __c_node* q = nullptr; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c A"); - while (p->__c_ != __c) + if (__cend_ != __cbeg_) { - q = p; - p = p->__next_; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c B"); - } - if (q == nullptr) - __cbeg_[hc] = p->__next_; - else - q->__next_ = p->__next_; - while (p->end_ != p->beg_) - { - --p->end_; - (*p->end_)->__c_ = nullptr; + size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); + __c_node* p = __cbeg_[hc]; + if (p == nullptr) + return; + __c_node* q = nullptr; + _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c A"); + while (p->__c_ != __c) + { + q = p; + p = p->__next_; + if (p == nullptr) + return; + _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c B"); + } + if (q == nullptr) + __cbeg_[hc] = p->__next_; + else + q->__next_ = p->__next_; + while (p->end_ != p->beg_) + { + --p->end_; + (*p->end_)->__c_ = nullptr; + } + free(p->beg_); + free(p); + --__csz_; } - free(p->beg_); - free(p); - --__csz_; } void @@ -302,7 +326,7 @@ __libcpp_db::__iterator_copy(void* __i, const void* __i0) __i_node* i = __find_iterator(__i); __i_node* i0 = __find_iterator(__i0); __c_node* c0 = i0 != nullptr ? i0->__c_ : nullptr; - if (i == nullptr && c0 != nullptr) + if (i == nullptr && i0 != nullptr) i = __insert_iterator(__i); __c_node* c = i != nullptr ? i->__c_ : nullptr; if (c != c0) @@ -354,7 +378,7 @@ __libcpp_db::__subscriptable(const void* __i, ptrdiff_t __n) const } bool -__libcpp_db::__comparable(const void* __i, const void* __j) const +__libcpp_db::__less_than_comparable(const void* __i, const void* __j) const { RLock _(mut()); __i_node* i = __find_iterator(__i); @@ -408,7 +432,8 @@ __c_node::__add(__i_node* i) size_t nc = 2*static_cast<size_t>(cap_ - beg_); if (nc == 0) nc = 1; - __i_node** beg = (__i_node**)malloc(nc * sizeof(__i_node*)); + __i_node** beg = + static_cast<__i_node**>(malloc(nc * sizeof(__i_node*))); if (beg == nullptr) #ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); @@ -434,7 +459,7 @@ __libcpp_db::__insert_iterator(void* __i) if (__isz_ + 1 > static_cast<size_t>(__iend_ - __ibeg_)) { size_t nc = __next_prime(2*static_cast<size_t>(__iend_ - __ibeg_) + 1); - __i_node** ibeg = (__i_node**)calloc(nc, sizeof(void*)); + __i_node** ibeg = static_cast<__i_node**>(calloc(nc, sizeof(void*))); if (ibeg == nullptr) #ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); @@ -459,7 +484,8 @@ __libcpp_db::__insert_iterator(void* __i) } size_t hi = hash<void*>()(__i) % static_cast<size_t>(__iend_ - __ibeg_); __i_node* p = __ibeg_[hi]; - __i_node* r = __ibeg_[hi] = (__i_node*)malloc(sizeof(__i_node)); + __i_node* r = __ibeg_[hi] = + static_cast<__i_node*>(malloc(sizeof(__i_node))); if (r == nullptr) #ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); diff --git a/system/lib/libcxx/exception.cpp b/system/lib/libcxx/exception.cpp index 1d2f6b25..3ce6f2e1 100644 --- a/system/lib/libcxx/exception.cpp +++ b/system/lib/libcxx/exception.cpp @@ -7,8 +7,10 @@ // //===----------------------------------------------------------------------===// #include <stdlib.h> +#include <stdio.h> #include "exception" +#include "new" #ifndef __has_include #define __has_include(inc) 0 @@ -22,7 +24,7 @@ #ifndef _LIBCPPABI_VERSION using namespace __cxxabiapple; // On Darwin, there are two STL shared libraries and a lower level ABI - // shared libray. The globals holding the current terminate handler and + // shared library. The globals holding the current terminate handler and // current unexpected handler are in the ABI library. #define __terminate_handler __cxxabiapple::__cxa_terminate_handler #define __unexpected_handler __cxxabiapple::__cxa_unexpected_handler @@ -77,7 +79,7 @@ get_terminate() _NOEXCEPT return __sync_fetch_and_add(&__terminate_handler, (terminate_handler)0); } -#ifndef EMSCRIPTEN // We provide this in JS +#ifndef __EMSCRIPTEN__ // We provide this in JS _LIBCPP_NORETURN void terminate() _NOEXCEPT @@ -88,31 +90,39 @@ terminate() _NOEXCEPT #endif // _LIBCPP_NO_EXCEPTIONS (*get_terminate())(); // handler should not return - ::abort (); + printf("terminate_handler unexpectedly returned\n"); + ::abort(); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { // handler should not throw exception - ::abort (); + printf("terminate_handler unexpectedly threw an exception\n"); + ::abort(); } #endif // _LIBCPP_NO_EXCEPTIONS } -#endif // !EMSCRIPTEN +#endif // !__EMSCRIPTEN__ #endif // !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION) -#if !defined(LIBCXXRT) && !defined(__GLIBCXX__) && !defined(EMSCRIPTEN) +#if !defined(LIBCXXRT) && !defined(__GLIBCXX__) && !defined(__EMSCRIPTEN__) bool uncaught_exception() _NOEXCEPT { #if defined(__APPLE__) || defined(_LIBCPPABI_VERSION) // on Darwin, there is a helper function so __cxa_get_globals is private return __cxa_uncaught_exception(); #else // __APPLE__ - #warning uncaught_exception not yet implemented +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("uncaught_exception not yet implemented") +# else +# warning uncaught_exception not yet implemented +# endif + printf("uncaught_exception not yet implemented\n"); ::abort(); #endif // __APPLE__ } + #ifndef _LIBCPPABI_VERSION exception::~exception() _NOEXCEPT @@ -139,15 +149,50 @@ const char* bad_exception::what() const _NOEXCEPT #endif +#if defined(__GLIBCXX__) + +// libsupc++ does not implement the dependent EH ABI and the functionality +// it uses to implement std::exception_ptr (which it declares as an alias of +// std::__exception_ptr::exception_ptr) is not directly exported to clients. So +// we have little choice but to hijack std::__exception_ptr::exception_ptr's +// (which fortunately has the same layout as our std::exception_ptr) copy +// constructor, assignment operator and destructor (which are part of its +// stable ABI), and its rethrow_exception(std::__exception_ptr::exception_ptr) +// function. + +namespace __exception_ptr +{ + +struct exception_ptr +{ + void* __ptr_; + + exception_ptr(const exception_ptr&) _NOEXCEPT; + exception_ptr& operator=(const exception_ptr&) _NOEXCEPT; + ~exception_ptr() _NOEXCEPT; +}; + +} + +_LIBCPP_NORETURN void rethrow_exception(__exception_ptr::exception_ptr); + +#endif exception_ptr::~exception_ptr() _NOEXCEPT { #if HAVE_DEPENDENT_EH_ABI __cxa_decrement_exception_refcount(__ptr_); +#elif defined(__GLIBCXX__) + reinterpret_cast<__exception_ptr::exception_ptr*>(this)->~exception_ptr(); #else - #warning exception_ptr not yet implemented +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("exception_ptr not yet implemented") +# else +# warning exception_ptr not yet implemented +# endif + printf("exception_ptr not yet implemented\n"); ::abort(); -#endif // __APPLE__ +#endif } exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT @@ -155,10 +200,18 @@ exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT { #if HAVE_DEPENDENT_EH_ABI __cxa_increment_exception_refcount(__ptr_); +#elif defined(__GLIBCXX__) + new (reinterpret_cast<void*>(this)) __exception_ptr::exception_ptr( + reinterpret_cast<const __exception_ptr::exception_ptr&>(other)); #else - #warning exception_ptr not yet implemented +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("exception_ptr not yet implemented") +# else +# warning exception_ptr not yet implemented +# endif + printf("exception_ptr not yet implemented\n"); ::abort(); -#endif // __APPLE__ +#endif } exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT @@ -171,10 +224,19 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT __ptr_ = other.__ptr_; } return *this; -#else // __APPLE__ - #warning exception_ptr not yet implemented +#elif defined(__GLIBCXX__) + *reinterpret_cast<__exception_ptr::exception_ptr*>(this) = + reinterpret_cast<const __exception_ptr::exception_ptr&>(other); + return *this; +#else +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("exception_ptr not yet implemented") +# else +# warning exception_ptr not yet implemented +# endif + printf("exception_ptr not yet implemented\n"); ::abort(); -#endif // __APPLE__ +#endif } nested_exception::nested_exception() _NOEXCEPT @@ -182,10 +244,14 @@ nested_exception::nested_exception() _NOEXCEPT { } +#if !defined(__GLIBCXX__) + nested_exception::~nested_exception() _NOEXCEPT { } +#endif + _LIBCPP_NORETURN void nested_exception::rethrow_nested() const @@ -195,6 +261,7 @@ nested_exception::rethrow_nested() const rethrow_exception(__ptr_); } +#if !defined(__GLIBCXX__) exception_ptr current_exception() _NOEXCEPT { @@ -205,12 +272,19 @@ exception_ptr current_exception() _NOEXCEPT exception_ptr ptr; ptr.__ptr_ = __cxa_current_primary_exception(); return ptr; -#else // __APPLE__ - #warning exception_ptr not yet implemented +#else +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING( "exception_ptr not yet implemented" ) +# else +# warning exception_ptr not yet implemented +# endif + printf("exception_ptr not yet implemented\n"); ::abort(); -#endif // __APPLE__ +#endif } +#endif // !__GLIBCXX__ + _LIBCPP_NORETURN void rethrow_exception(exception_ptr p) { @@ -218,9 +292,16 @@ void rethrow_exception(exception_ptr p) __cxa_rethrow_primary_exception(p.__ptr_); // if p.__ptr_ is NULL, above returns so we terminate terminate(); -#else // __APPLE__ - #warning exception_ptr not yet implemented +#elif defined(__GLIBCXX__) + rethrow_exception(reinterpret_cast<__exception_ptr::exception_ptr&>(p)); +#else +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("exception_ptr not yet implemented") +# else +# warning exception_ptr not yet implemented +# endif + printf("exception_ptr not yet implemented\n"); ::abort(); -#endif // __APPLE__ +#endif } } // std diff --git a/system/lib/libcxx/future.cpp b/system/lib/libcxx/future.cpp index 7d9a5b5d..70919ab7 100644 --- a/system/lib/libcxx/future.cpp +++ b/system/lib/libcxx/future.cpp @@ -26,11 +26,15 @@ __future_error_category::name() const _NOEXCEPT return "future"; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wswitch" + string __future_error_category::message(int ev) const { switch (static_cast<future_errc>(ev)) { + case future_errc(0): // For backwards compatibility with C++11 (LWG 2056) case future_errc::broken_promise: return string("The associated promise has been destructed prior " "to the associated state becoming ready."); @@ -46,6 +50,8 @@ __future_error_category::message(int ev) const return string("unspecified future_errc value\n"); } +#pragma clang diagnostic pop + const error_category& future_category() _NOEXCEPT { diff --git a/system/lib/libcxx/hash.cpp b/system/lib/libcxx/hash.cpp index a0135002..388ab2eb 100644 --- a/system/lib/libcxx/hash.cpp +++ b/system/lib/libcxx/hash.cpp @@ -12,7 +12,9 @@ #include "stdexcept" #include "type_traits" +#ifdef __clang__ #pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -155,6 +157,8 @@ __check_for_overflow(size_t N) #ifndef _LIBCPP_NO_EXCEPTIONS if (N > 0xFFFFFFFB) throw overflow_error("__next_prime overflow"); +#else + (void)N; #endif } @@ -166,6 +170,8 @@ __check_for_overflow(size_t N) #ifndef _LIBCPP_NO_EXCEPTIONS if (N > 0xFFFFFFFFFFFFFFC5ull) throw overflow_error("__next_prime overflow"); +#else + (void)N; #endif } diff --git a/system/lib/libcxx/ios.cpp b/system/lib/libcxx/ios.cpp index 732a61bb..004d3183 100644 --- a/system/lib/libcxx/ios.cpp +++ b/system/lib/libcxx/ios.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; + #include "ios" #include "streambuf" #include "istream" @@ -61,7 +63,7 @@ __iostream_category::message(int ev) const } const error_category& -iostream_category() +iostream_category() _NOEXCEPT { static __iostream_category s; return s; @@ -147,8 +149,11 @@ ios_base::getloc() const } // xalloc - +#if __has_feature(cxx_atomic) && !defined(__EMSCRIPTEN__) +atomic<int> ios_base::__xindex_ = ATOMIC_VAR_INIT(0); +#else int ios_base::__xindex_ = 0; +#endif int ios_base::xalloc() diff --git a/system/lib/libcxx/iostream.cpp b/system/lib/libcxx/iostream.cpp index 7fc71df4..7102e438 100644 --- a/system/lib/libcxx/iostream.cpp +++ b/system/lib/libcxx/iostream.cpp @@ -22,14 +22,14 @@ _ALIGNAS_TYPE (__stdinbuf<wchar_t> ) static char __wcin [sizeof(__stdinbuf <wcha _ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)]; _ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcerr[sizeof(__stdoutbuf<wchar_t>)]; -_ALIGNAS_TYPE (istream) char cin [sizeof(istream)]; -_ALIGNAS_TYPE (ostream) char cout[sizeof(ostream)]; -_ALIGNAS_TYPE (ostream) char cerr[sizeof(ostream)]; -_ALIGNAS_TYPE (ostream) char clog[sizeof(ostream)]; -_ALIGNAS_TYPE (wistream) char wcin [sizeof(wistream)]; -_ALIGNAS_TYPE (wostream) char wcout[sizeof(wostream)]; -_ALIGNAS_TYPE (wostream) char wcerr[sizeof(wostream)]; -_ALIGNAS_TYPE (wostream) char wclog[sizeof(wostream)]; +_ALIGNAS_TYPE (istream) _LIBCPP_FUNC_VIS char cin [sizeof(istream)]; +_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cout[sizeof(ostream)]; +_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cerr[sizeof(ostream)]; +_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char clog[sizeof(ostream)]; +_ALIGNAS_TYPE (wistream) _LIBCPP_FUNC_VIS char wcin [sizeof(wistream)]; +_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcout[sizeof(wostream)]; +_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcerr[sizeof(wostream)]; +_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wclog[sizeof(wostream)]; ios_base::Init __start_std_streams; @@ -54,13 +54,13 @@ ios_base::Init::Init() ios_base::Init::~Init() { - ostream* cout_ptr = (ostream*)cout; - ostream* clog_ptr = (ostream*)clog; + ostream* cout_ptr = reinterpret_cast<ostream*>(cout); + ostream* clog_ptr = reinterpret_cast<ostream*>(clog); cout_ptr->flush(); clog_ptr->flush(); - wostream* wcout_ptr = (wostream*)wcout; - wostream* wclog_ptr = (wostream*)wclog; + wostream* wcout_ptr = reinterpret_cast<wostream*>(wcout); + wostream* wclog_ptr = reinterpret_cast<wostream*>(wclog); wcout_ptr->flush(); wclog_ptr->flush(); } diff --git a/system/lib/libcxx/locale.cpp b/system/lib/libcxx/locale.cpp index d9bc6f9a..8e7fdb43 100644 --- a/system/lib/libcxx/locale.cpp +++ b/system/lib/libcxx/locale.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; + // On Solaris, we need to define something to make the C99 parts of localeconv // visible. #ifdef __sun__ @@ -18,23 +20,27 @@ #include "codecvt" #include "vector" #include "algorithm" -#include "algorithm" #include "typeinfo" -#include "type_traits" +#ifndef _LIBCPP_NO_EXCEPTIONS +# include "type_traits" +#endif #include "clocale" #include "cstring" #include "cwctype" #include "__sso_allocator" -#ifdef _WIN32 +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) #include <support/win32/locale_win32.h> -#else // _WIN32 +#else // _LIBCPP_MSVCRT #include <langinfo.h> -#endif // _!WIN32 +#endif // !_LIBCPP_MSVCRT #include <stdlib.h> +#include <stdio.h> // On Linux, wint_t and wchar_t have different signed-ness, and this causes // lots of noise in the build log, but no bugs that I know of. +#if defined(__clang__) #pragma clang diagnostic ignored "-Wsign-conversion" +#endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -105,6 +111,11 @@ countof(const T * const begin, const T * const end) } +#if defined(_AIX) +// Set priority to INT_MIN + 256 + 150 +# pragma priority ( -2147483242 ) +#endif + const locale::category locale::none; const locale::category locale::collate; const locale::category locale::ctype; @@ -114,14 +125,23 @@ const locale::category locale::time; const locale::category locale::messages; const locale::category locale::all; +#if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpadded" +#endif class _LIBCPP_HIDDEN locale::__imp : public facet { enum {N = 28}; +#if defined(_LIBCPP_MSVC) +// FIXME: MSVC doesn't support aligned parameters by value. +// I can't get the __sso_allocator to work here +// for MSVC I think for this reason. + vector<facet*> facets_; +#else vector<facet*, __sso_allocator<facet*, N> > facets_; +#endif string name_; public: explicit __imp(size_t refs = 0); @@ -145,7 +165,9 @@ private: template <class F> void install_from(const __imp& other); }; +#if defined(__clang__) #pragma clang diagnostic pop +#endif locale::__imp::__imp(size_t refs) : facet(refs), @@ -230,8 +252,10 @@ locale::__imp::__imp(const string& name, size_t refs) // NOTE avoid the `base class should be explicitly initialized in the // copy constructor` warning emitted by GCC +#if defined(__clang__) || _GNUC_VER >= 406 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wextra" +#endif locale::__imp::__imp(const __imp& other) : facets_(max<size_t>(N, other.facets_.size())), @@ -243,7 +267,9 @@ locale::__imp::__imp(const __imp& other) facets_[i]->__add_shared(); } +#if defined(__clang__) || _GNUC_VER >= 406 #pragma GCC diagnostic pop +#endif locale::__imp::__imp(const __imp& other, const string& name, locale::category c) : facets_(N), @@ -751,7 +777,7 @@ ctype<wchar_t>::~ctype() bool ctype<wchar_t>::do_is(mask m, char_type c) const { - return isascii(c) ? ctype<char>::classic_table()[c] & m : false; + return isascii(c) ? (ctype<char>::classic_table()[c] & m) != 0 : false; } const wchar_t* @@ -786,7 +812,7 @@ ctype<wchar_t>::do_toupper(char_type c) const { #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c; -#elif defined(__GLIBC__) || defined(EMSCRIPTEN) +#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) return isascii(c) ? ctype<char>::__classic_upper_table()[c] : c; #else return (isascii(c) && iswlower_l(c, __cloc())) ? c-L'a'+L'A' : c; @@ -799,7 +825,7 @@ ctype<wchar_t>::do_toupper(char_type* low, const char_type* high) const for (; low != high; ++low) #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE *low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low; -#elif defined(__GLIBC__) || defined(EMSCRIPTEN) +#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) *low = isascii(*low) ? ctype<char>::__classic_upper_table()[*low] |