diff options
author | Bruce Mitchener <bruce.mitchener@gmail.com> | 2013-02-17 14:29:14 +0700 |
---|---|---|
committer | Bruce Mitchener <bruce.mitchener@gmail.com> | 2013-03-25 00:34:11 +0700 |
commit | 59ff5a6a3c3e1f5255c5cf29f98df633a77b89b3 (patch) | |
tree | c7660fa62600366e3479dbf6b2fd1d25709af1b5 /system/lib/libcxx | |
parent | 80fd6f0bce2b95db6ec539c9275ce24585550e7c (diff) |
Update to current libcxx.
This doesn't work yet as it needs to be customized for use with
emscripten still.
Diffstat (limited to 'system/lib/libcxx')
29 files changed, 1758 insertions, 641 deletions
diff --git a/system/lib/libcxx/CREDITS.TXT b/system/lib/libcxx/CREDITS.TXT new file mode 100644 index 00000000..52948510 --- /dev/null +++ b/system/lib/libcxx/CREDITS.TXT @@ -0,0 +1,91 @@ +This file is a partial list of people who have contributed to the LLVM/libc++ +project. If you have contributed a patch or made some other contribution to +LLVM/libc++, please submit a patch to this file to add yourself, and it will be +done! + +The list is sorted by surname and formatted to allow easy grepping and +beautification by scripts. The fields are: name (N), email (E), web-address +(W), PGP key ID and fingerprint (P), description (D), and snail-mail address +(S). + +N: Saleem Abdulrasool +E: compnerd@compnerd.org +D: Minor patches and Linux fixes. + +N: Dimitry Andric +E: dimitry@andric.com +D: Visibility fixes, minor FreeBSD portability patches. + +N: Holger Arnold +E: holgerar@gmail.com +D: Minor fix. + +N: Ruben Van Boxem +E: vanboxem dot ruben at gmail dot com +D: Initial Windows patches. + +N: David Chisnall +E: theraven at theravensnest dot org +D: FreeBSD and Solaris ports, libcxxrt support, some atomics work. + +N: Marshall Clow +E: mclow.lists@gmail.com +E: marshall@idio.com +D: Minor patches and bug fixes. + +N: Google Inc. +D: Copyright owner and contributor of the CityHash algorithm + +N: Howard Hinnant +E: hhinnant@apple.com +D: Architect and primary author of libc++ + +N: Hyeon-bin Jeong +E: tuhertz@gmail.com +D: Minor patches and bug fixes. + +N: Argyrios Kyrtzidis +E: kyrtzidis@apple.com +D: Bug fixes. + +N: Michel Morin +E: mimomorin@gmail.com +D: Minor patches to is_convertible. + +N: Andrew Morrow +E: andrew.c.morrow@gmail.com +D: Minor patches and Linux fixes. + +N: Arvid Picciani +E: aep at exys dot org +D: Minor patches and musl port. + +N: Bjorn Reese +E: breese@users.sourceforge.net +D: Initial regex prototype + +N: Jonathan Sauer +D: Minor patches, mostly related to constexpr + +N: Craig Silverstein +E: csilvers@google.com +D: Implemented Cityhash as the string hash function on 64-bit machines + +N: Richard Smith +D: Minor patches. + +N: Michael van der Westhuizen +E: r1mikey at gmail dot com + +N: Klaas de Vries +E: klaas at klaasgaaf dot nl +D: Minor bug fix. + +N: Zhang Xiongpang +E: zhangxiongpang@gmail.com +D: Minor patches and bug fixes. + +N: Jeffrey Yasskin +E: jyasskin@gmail.com +E: jyasskin@google.com +D: Linux fixes. diff --git a/system/lib/libcxx/LICENSE.txt b/system/lib/libcxx/LICENSE.txt index 926f0676..5ed8ec22 100644 --- a/system/lib/libcxx/LICENSE.txt +++ b/system/lib/libcxx/LICENSE.txt @@ -14,7 +14,7 @@ Full text of the relevant licenses is included below. University of Illinois/NCSA Open Source License -Copyright (c) 2009-2010 by the contributors listed in CREDITS.TXT +Copyright (c) 2009-2013 by the contributors listed in CREDITS.TXT All rights reserved. @@ -55,7 +55,7 @@ SOFTWARE. ============================================================================== -Copyright (c) 2009-2010 by the contributors listed in CREDITS.TXT +Copyright (c) 2009-2013 by the contributors listed in CREDITS.TXT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/system/lib/libcxx/chrono.cpp b/system/lib/libcxx/chrono.cpp index 416b9501..1ce2e280 100644 --- a/system/lib/libcxx/chrono.cpp +++ b/system/lib/libcxx/chrono.cpp @@ -24,6 +24,8 @@ namespace chrono // system_clock +const bool system_clock::is_steady; + system_clock::time_point system_clock::now() _NOEXCEPT { @@ -46,6 +48,8 @@ system_clock::from_time_t(time_t t) _NOEXCEPT // steady_clock +const bool steady_clock::is_steady; + #if __APPLE__ // mach_absolute_time() * MachInfo.numer / MachInfo.denom is the number of // nanoseconds since the computer booted up. MachInfo.numer and MachInfo.denom @@ -61,7 +65,7 @@ static steady_clock::rep steady_simplified() { - return mach_absolute_time(); + return static_cast<steady_clock::rep>(mach_absolute_time()); } static diff --git a/system/lib/libcxx/condition_variable.cpp b/system/lib/libcxx/condition_variable.cpp index ca1dca32..de0f6f47 100644 --- a/system/lib/libcxx/condition_variable.cpp +++ b/system/lib/libcxx/condition_variable.cpp @@ -16,18 +16,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD condition_variable::~condition_variable() { - int e = pthread_cond_destroy(&__cv_); -// assert(e == 0); + pthread_cond_destroy(&__cv_); } void -condition_variable::notify_one() +condition_variable::notify_one() _NOEXCEPT { pthread_cond_signal(&__cv_); } void -condition_variable::notify_all() +condition_variable::notify_all() _NOEXCEPT { pthread_cond_broadcast(&__cv_); } @@ -52,10 +51,22 @@ condition_variable::__do_timed_wait(unique_lock<mutex>& lk, __throw_system_error(EPERM, "condition_variable::timed wait: mutex not locked"); nanoseconds d = tp.time_since_epoch(); + if (d > nanoseconds(0x59682F000000E941)) + d = nanoseconds(0x59682F000000E941); timespec ts; seconds s = duration_cast<seconds>(d); - ts.tv_sec = static_cast<decltype(ts.tv_sec)>(s.count()); - ts.tv_nsec = static_cast<decltype(ts.tv_nsec)>((d - s).count()); + typedef decltype(ts.tv_sec) ts_sec; + _LIBCPP_CONSTEXPR ts_sec ts_sec_max = numeric_limits<ts_sec>::max(); + if (s.count() < ts_sec_max) + { + ts.tv_sec = static_cast<ts_sec>(s.count()); + ts.tv_nsec = static_cast<decltype(ts.tv_nsec)>((d - s).count()); + } + else + { + ts.tv_sec = ts_sec_max; + ts.tv_nsec = giga::num - 1; + } int ec = pthread_cond_timedwait(&__cv_, lk.mutex()->native_handle(), &ts); if (ec != 0 && ec != ETIMEDOUT) __throw_system_error(ec, "condition_variable timed_wait failed"); diff --git a/system/lib/libcxx/debug.cpp b/system/lib/libcxx/debug.cpp index 2d2d6432..f3a0262d 100644 --- a/system/lib/libcxx/debug.cpp +++ b/system/lib/libcxx/debug.cpp @@ -23,7 +23,7 @@ __get_db() { static __libcpp_db db; return &db; -}; +} _LIBCPP_VISIBLE const __libcpp_db* @@ -120,20 +120,18 @@ __libcpp_db::__insert_ic(void* __i, const void* __c) { WLock _(mut()); __i_node* i = __insert_iterator(__i); - _LIBCPP_ASSERT(__cbeg_ != __cend_, "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"); - size_t hc = hash<const void*>()(__c) % (__cend_ - __cbeg_); + 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); + size_t hc = hash<const void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); __c_node* c = __cbeg_[hc]; - _LIBCPP_ASSERT(c != nullptr, "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(c != nullptr, errmsg); while (c->__c_ != __c) { c = c->__next_; - _LIBCPP_ASSERT(c != nullptr, "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(c != nullptr, errmsg); } c->__add(i); i->__c_ = c; @@ -143,12 +141,16 @@ __c_node* __libcpp_db::__insert_c(void* __c) { WLock _(mut()); - if (__csz_ + 1 > __cend_ - __cbeg_) + if (__csz_ + 1 > static_cast<size_t>(__cend_ - __cbeg_)) { - size_t nc = __next_prime(2*(__cend_ - __cbeg_) + 1); + size_t nc = __next_prime(2*static_cast<size_t>(__cend_ - __cbeg_) + 1); __c_node** cbeg = (__c_node**)calloc(nc, sizeof(void*)); if (cbeg == nullptr) +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); +#else + abort(); +#endif for (__c_node** p = __cbeg_; p != __cend_; ++p) { __c_node* q = *p; @@ -165,11 +167,15 @@ __libcpp_db::__insert_c(void* __c) __cbeg_ = cbeg; __cend_ = __cbeg_ + nc; } - size_t hc = hash<void*>()(__c) % (__cend_ - __cbeg_); + 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)); if (__cbeg_[hc] == nullptr) +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); +#else + abort(); +#endif r->__c_ = __c; r->__next_ = p; ++__csz_; @@ -182,7 +188,7 @@ __libcpp_db::__erase_i(void* __i) WLock _(mut()); if (__ibeg_ != __iend_) { - size_t hi = hash<void*>()(__i) % (__iend_ - __ibeg_); + size_t hi = hash<void*>()(__i) % static_cast<size_t>(__iend_ - __ibeg_); __i_node* p = __ibeg_[hi]; if (p != nullptr) { @@ -211,7 +217,7 @@ void __libcpp_db::__invalidate_all(void* __c) { WLock _(mut()); - size_t hc = hash<void*>()(__c) % (__cend_ - __cbeg_); + 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) @@ -230,7 +236,7 @@ __c_node* __libcpp_db::__find_c_and_lock(void* __c) const { mut().lock(); - size_t hc = hash<void*>()(__c) % (__cend_ - __cbeg_); + 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"); while (p->__c_ != __c) @@ -241,6 +247,20 @@ __libcpp_db::__find_c_and_lock(void* __c) const return p; } +__c_node* +__libcpp_db::__find_c(void* __c) const +{ + 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 A"); + while (p->__c_ != __c) + { + p = p->__next_; + _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c B"); + } + return p; +} + void __libcpp_db::unlock() const { @@ -251,7 +271,7 @@ void __libcpp_db::__erase_c(void* __c) { WLock _(mut()); - size_t hc = hash<void*>()(__c) % (__cend_ - __cbeg_); + 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"); @@ -348,7 +368,7 @@ void __libcpp_db::swap(void* c1, void* c2) { WLock _(mut()); - size_t hc = hash<void*>()(c1) % (__cend_ - __cbeg_); + size_t hc = hash<void*>()(c1) % static_cast<size_t>(__cend_ - __cbeg_); __c_node* p1 = __cbeg_[hc]; _LIBCPP_ASSERT(p1 != nullptr, "debug mode internal logic error swap A"); while (p1->__c_ != c1) @@ -356,7 +376,7 @@ __libcpp_db::swap(void* c1, void* c2) p1 = p1->__next_; _LIBCPP_ASSERT(p1 != nullptr, "debug mode internal logic error swap B"); } - hc = hash<void*>()(c2) % (__cend_ - __cbeg_); + hc = hash<void*>()(c2) % static_cast<size_t>(__cend_ - __cbeg_); __c_node* p2 = __cbeg_[hc]; _LIBCPP_ASSERT(p2 != nullptr, "debug mode internal logic error swap C"); while (p2->__c_ != c2) @@ -380,18 +400,47 @@ __libcpp_db::__insert_i(void* __i) __insert_iterator(__i); } +void +__c_node::__add(__i_node* i) +{ + if (end_ == cap_) + { + 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*)); + if (beg == nullptr) +#ifndef _LIBCPP_NO_EXCEPTIONS + throw bad_alloc(); +#else + abort(); +#endif + if (nc > 1) + memcpy(beg, beg_, nc/2*sizeof(__i_node*)); + free(beg_); + beg_ = beg; + end_ = beg_ + nc/2; + cap_ = beg_ + nc; + } + *end_++ = i; +} + // private api _LIBCPP_HIDDEN __i_node* __libcpp_db::__insert_iterator(void* __i) { - if (__isz_ + 1 > __iend_ - __ibeg_) + if (__isz_ + 1 > static_cast<size_t>(__iend_ - __ibeg_)) { - size_t nc = __next_prime(2*(__iend_ - __ibeg_) + 1); + size_t nc = __next_prime(2*static_cast<size_t>(__iend_ - __ibeg_) + 1); __i_node** ibeg = (__i_node**)calloc(nc, sizeof(void*)); if (ibeg == nullptr) +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); +#else + abort(); +#endif for (__i_node** p = __ibeg_; p != __iend_; ++p) { __i_node* q = *p; @@ -408,11 +457,15 @@ __libcpp_db::__insert_iterator(void* __i) __ibeg_ = ibeg; __iend_ = __ibeg_ + nc; } - size_t hi = hash<void*>()(__i) % (__iend_ - __ibeg_); + 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)); if (r == nullptr) +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); +#else + abort(); +#endif ::new(r) __i_node(__i, p, nullptr); ++__isz_; return r; @@ -425,7 +478,7 @@ __libcpp_db::__find_iterator(const void* __i) const __i_node* r = nullptr; if (__ibeg_ != __iend_) { - size_t h = hash<const void*>()(__i) % (__iend_ - __ibeg_); + size_t h = hash<const void*>()(__i) % static_cast<size_t>(__iend_ - __ibeg_); for (__i_node* nd = __ibeg_[h]; nd != nullptr; nd = nd->__next_) { if (nd->__i_ == __i) @@ -440,34 +493,12 @@ __libcpp_db::__find_iterator(const void* __i) const _LIBCPP_HIDDEN void -__c_node::__add(__i_node* i) -{ - if (end_ == cap_) - { - size_t nc = 2*(cap_ - beg_); - if (nc == 0) - nc = 1; - __i_node** beg = (__i_node**)malloc(nc * sizeof(__i_node*)); - if (beg == nullptr) - throw bad_alloc(); - if (nc > 1) - memcpy(beg, beg_, nc/2*sizeof(__i_node*)); - free(beg_); - beg_ = beg; - end_ = beg_ + nc/2; - cap_ = beg_ + nc; - } - *end_++ = i; -} - -_LIBCPP_HIDDEN -void __c_node::__remove(__i_node* p) { __i_node** r = find(beg_, end_, p); _LIBCPP_ASSERT(r != end_, "debug mode internal logic error __c_node::__remove"); if (--end_ != r) - memmove(r, r+1, (end_ - r)*sizeof(__i_node*)); + memmove(r, r+1, static_cast<size_t>(end_ - r)*sizeof(__i_node*)); } _LIBCPP_END_NAMESPACE_STD diff --git a/system/lib/libcxx/exception.cpp b/system/lib/libcxx/exception.cpp index cba355e9..0cd182b7 100644 --- a/system/lib/libcxx/exception.cpp +++ b/system/lib/libcxx/exception.cpp @@ -10,69 +10,82 @@ #include "exception" +#ifndef __has_include +#define __has_include(inc) 0 +#endif + #if __APPLE__ #include <cxxabi.h> + using namespace __cxxabiv1; - 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 - // current unexpected handler are in the ABI library. - #define __terminate_handler __cxxabiapple::__cxa_terminate_handler - #define __unexpected_handler __cxxabiapple::__cxa_unexpected_handler #define HAVE_DEPENDENT_EH_ABI 1 -#elif defined(LIBCXXRT) + #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 + // current unexpected handler are in the ABI library. + #define __terminate_handler __cxxabiapple::__cxa_terminate_handler + #define __unexpected_handler __cxxabiapple::__cxa_unexpected_handler + #endif // _LIBCPPABI_VERSION +#elif defined(LIBCXXRT) || __has_include(<cxxabi.h>) #include <cxxabi.h> using namespace __cxxabiv1; - #define HAVE_DEPENDENT_EH_ABI 1 -#else // __APPLE__ + #if defined(LIBCXXRT) || defined(_LIBCPPABI_VERSION) + #define HAVE_DEPENDENT_EH_ABI 1 + #endif +#elif !defined(__GLIBCXX__) // __has_include(<cxxabi.h>) static std::terminate_handler __terminate_handler; static std::unexpected_handler __unexpected_handler; -#endif // __APPLE__ +#endif // __has_include(<cxxabi.h>) + +namespace std +{ + +#if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__) -#ifndef LIBCXXRT // libcxxrt provides implementations of these functions itself. -std::unexpected_handler -std::set_unexpected(std::unexpected_handler func) _NOEXCEPT +unexpected_handler +set_unexpected(unexpected_handler func) _NOEXCEPT { return __sync_lock_test_and_set(&__unexpected_handler, func); } -std::unexpected_handler -std::get_unexpected() _NOEXCEPT +unexpected_handler +get_unexpected() _NOEXCEPT { - return __sync_fetch_and_add(&__unexpected_handler, (std::unexpected_handler)0); + return __sync_fetch_and_add(&__unexpected_handler, (unexpected_handler)0); } -_ATTRIBUTE(noreturn) +_LIBCPP_NORETURN void -std::unexpected() +unexpected() { - (*std::get_unexpected())(); + (*get_unexpected())(); // unexpected handler should not return - std::terminate(); + terminate(); } -std::terminate_handler -std::set_terminate(std::terminate_handler func) _NOEXCEPT +terminate_handler +set_terminate(terminate_handler func) _NOEXCEPT { return __sync_lock_test_and_set(&__terminate_handler, func); } -std::terminate_handler -std::get_terminate() _NOEXCEPT +terminate_handler +get_terminate() _NOEXCEPT { - return __sync_fetch_and_add(&__terminate_handler, (std::terminate_handler)0); + return __sync_fetch_and_add(&__terminate_handler, (terminate_handler)0); } -_ATTRIBUTE(noreturn) +_LIBCPP_NORETURN void -std::terminate() _NOEXCEPT +terminate() _NOEXCEPT { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS - (*std::get_terminate())(); + (*get_terminate())(); // handler should not return ::abort (); #ifndef _LIBCPP_NO_EXCEPTIONS @@ -84,38 +97,37 @@ std::terminate() _NOEXCEPT } #endif // _LIBCPP_NO_EXCEPTIONS } -#endif // LIBCXXRT +#endif // !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION) -#ifndef EMSCRIPTEN // This is implemented in Javascript for Emscripten -bool std::uncaught_exception() _NOEXCEPT +#if !defined(LIBCXXRT) && !defined(__GLIBCXX__) +bool uncaught_exception() _NOEXCEPT { -#if __APPLE__ +#if __APPLE__ || defined(_LIBCPPABI_VERSION) // on Darwin, there is a helper function so __cxa_get_globals is private - return __cxxabiapple::__cxa_uncaught_exception(); -#elif LIBCXXRT - __cxa_eh_globals * globals = __cxa_get_globals(); - return (globals->uncaughtExceptions != 0); + return __cxa_uncaught_exception(); #else // __APPLE__ #warning uncaught_exception not yet implemented ::abort(); #endif // __APPLE__ } -#endif // EMSCRIPTEN -namespace std -{ +#ifndef _LIBCPPABI_VERSION exception::~exception() _NOEXCEPT { } -bad_exception::~bad_exception() _NOEXCEPT +const char* exception::what() const _NOEXCEPT { + return "std::exception"; } -const char* exception::what() const _NOEXCEPT +#endif // _LIBCPPABI_VERSION +#endif //LIBCXXRT +#if !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__) + +bad_exception::~bad_exception() _NOEXCEPT { - return "std::exception"; } const char* bad_exception::what() const _NOEXCEPT @@ -123,6 +135,9 @@ const char* bad_exception::what() const _NOEXCEPT return "std::bad_exception"; } +#endif + + exception_ptr::~exception_ptr() _NOEXCEPT { #if HAVE_DEPENDENT_EH_ABI @@ -169,7 +184,7 @@ nested_exception::~nested_exception() _NOEXCEPT { } -_ATTRIBUTE(noreturn) +_LIBCPP_NORETURN void nested_exception::rethrow_nested() const { @@ -178,15 +193,14 @@ nested_exception::rethrow_nested() const rethrow_exception(__ptr_); } -} // std -std::exception_ptr std::current_exception() _NOEXCEPT +exception_ptr current_exception() _NOEXCEPT { #if HAVE_DEPENDENT_EH_ABI // be nicer if there was a constructor that took a ptr, then // this whole function would be just: // return exception_ptr(__cxa_current_primary_exception()); - std::exception_ptr ptr; + exception_ptr ptr; ptr.__ptr_ = __cxa_current_primary_exception(); return ptr; #else // __APPLE__ @@ -195,7 +209,8 @@ std::exception_ptr std::current_exception() _NOEXCEPT #endif // __APPLE__ } -void std::rethrow_exception(exception_ptr p) +_LIBCPP_NORETURN +void rethrow_exception(exception_ptr p) { #if HAVE_DEPENDENT_EH_ABI __cxa_rethrow_primary_exception(p.__ptr_); @@ -206,3 +221,4 @@ void std::rethrow_exception(exception_ptr p) ::abort(); #endif // __APPLE__ } +} // std diff --git a/system/lib/libcxx/future.cpp b/system/lib/libcxx/future.cpp index ff591105..7d9a5b5d 100644 --- a/system/lib/libcxx/future.cpp +++ b/system/lib/libcxx/future.cpp @@ -29,7 +29,7 @@ __future_error_category::name() const _NOEXCEPT string __future_error_category::message(int ev) const { - switch (ev) + switch (static_cast<future_errc>(ev)) { case future_errc::broken_promise: return string("The associated promise has been destructed prior " @@ -47,7 +47,7 @@ __future_error_category::message(int ev) const } const error_category& -future_category() +future_category() _NOEXCEPT { static __future_error_category __f; return __f; @@ -78,8 +78,8 @@ __assoc_sub_state::set_value() throw future_error(make_error_code(future_errc::promise_already_satisfied)); #endif __state_ |= __constructed | ready; - __lk.unlock(); __cv_.notify_all(); + __lk.unlock(); } void @@ -152,9 +152,9 @@ __assoc_sub_state::__sub_wait(unique_lock<mutex>& __lk) { if (!__is_ready()) { - if (__state_ & deferred) + if (__state_ & static_cast<unsigned>(deferred)) { - __state_ &= ~deferred; + __state_ &= ~static_cast<unsigned>(deferred); __lk.unlock(); __execute(); } diff --git a/system/lib/libcxx/hash.cpp b/system/lib/libcxx/hash.cpp index 728b9bd3..a0135002 100644 --- a/system/lib/libcxx/hash.cpp +++ b/system/lib/libcxx/hash.cpp @@ -10,6 +10,9 @@ #include "__hash_table" #include "algorithm" #include "stdexcept" +#include "type_traits" + +#pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare" _LIBCPP_BEGIN_NAMESPACE_STD @@ -144,21 +147,23 @@ const unsigned indices[] = // are fewer potential primes to search, and fewer potential primes to divide // against. +template <size_t _Sz = sizeof(size_t)> inline _LIBCPP_INLINE_VISIBILITY -void -__check_for_overflow(size_t N, integral_constant<size_t, 32>) +typename enable_if<_Sz == 4, void>::type +__check_for_overflow(size_t N) { -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_NO_EXCEPTIONS if (N > 0xFFFFFFFB) throw overflow_error("__next_prime overflow"); #endif } +template <size_t _Sz = sizeof(size_t)> inline _LIBCPP_INLINE_VISIBILITY -void -__check_for_overflow(size_t N, integral_constant<size_t, 64>) +typename enable_if<_Sz == 8, void>::type +__check_for_overflow(size_t N) { -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_NO_EXCEPTIONS if (N > 0xFFFFFFFFFFFFFFC5ull) throw overflow_error("__next_prime overflow"); #endif @@ -174,14 +179,14 @@ __next_prime(size_t n) return *std::lower_bound(small_primes, small_primes + N, n); // Else n > largest small_primes // Check for overflow - __check_for_overflow(n, integral_constant<size_t, - sizeof(n) * __CHAR_BIT__>()); + __check_for_overflow(n); // Start searching list of potential primes: L * k0 + indices[in] const size_t M = sizeof(indices) / sizeof(indices[0]); // Select first potential prime >= n // Known a-priori n >= L size_t k0 = n / L; - size_t in = std::lower_bound(indices, indices + M, n - k0 * L) - indices; + size_t in = static_cast<size_t>(std::lower_bound(indices, indices + M, n - k0 * L) + - indices); n = L * k0 + indices[in]; while (true) { diff --git a/system/lib/libcxx/ios.cpp b/system/lib/libcxx/ios.cpp index 80917a04..732a61bb 100644 --- a/system/lib/libcxx/ios.cpp +++ b/system/lib/libcxx/ios.cpp @@ -401,7 +401,7 @@ ios_base::move(ios_base& rhs) } void -ios_base::swap(ios_base& rhs) +ios_base::swap(ios_base& rhs) _NOEXCEPT { _VSTD::swap(__fmtflags_, rhs.__fmtflags_); _VSTD::swap(__precision_, rhs.__precision_); diff --git a/system/lib/libcxx/iostream.cpp b/system/lib/libcxx/iostream.cpp index 157c3977..f5b959b4 100644 --- a/system/lib/libcxx/iostream.cpp +++ b/system/lib/libcxx/iostream.cpp @@ -9,45 +9,58 @@ #include "__std_stream" #include "string" +#include "new" _LIBCPP_BEGIN_NAMESPACE_STD -static __stdinbuf<char> __cin(stdin); -static __stdoutbuf<char> __cout(stdout); |