diff options
author | Bruce Mitchener <bruce.mitchener@gmail.com> | 2013-11-07 15:49:37 +0700 |
---|---|---|
committer | Bruce Mitchener <bruce.mitchener@gmail.com> | 2013-11-07 16:07:18 +0700 |
commit | 44af976a44bc194b985fdb880f99a7feff133b5a (patch) | |
tree | 400fb651d819c41e26b417d36a4315ec947fd387 /system/lib/libcxx | |
parent | 7f870cf9c357f6a1138ba612ace7d7249f85e250 (diff) |
Update libcxx to 194185, 2013-11-07.
This brings C++14 support.
Diffstat (limited to 'system/lib/libcxx')
-rw-r--r-- | system/lib/libcxx/CREDITS.TXT | 10 | ||||
-rw-r--r-- | system/lib/libcxx/algorithm.cpp | 1 | ||||
-rw-r--r-- | system/lib/libcxx/debug.cpp | 108 | ||||
-rw-r--r-- | system/lib/libcxx/exception.cpp | 104 | ||||
-rw-r--r-- | system/lib/libcxx/future.cpp | 6 | ||||
-rw-r--r-- | system/lib/libcxx/ios.cpp | 9 | ||||
-rw-r--r-- | system/lib/libcxx/iostream.cpp | 16 | ||||
-rw-r--r-- | system/lib/libcxx/locale.cpp | 49 | ||||
-rw-r--r-- | system/lib/libcxx/mutex.cpp | 3 | ||||
-rw-r--r-- | system/lib/libcxx/new.cpp | 54 | ||||
-rw-r--r-- | system/lib/libcxx/optional.cpp | 25 | ||||
-rw-r--r-- | system/lib/libcxx/random.cpp | 26 | ||||
-rw-r--r-- | system/lib/libcxx/readme.txt | 2 | ||||
-rw-r--r-- | system/lib/libcxx/shared_mutex.cpp | 101 | ||||
-rw-r--r-- | system/lib/libcxx/stdexcept.cpp | 18 | ||||
-rw-r--r-- | system/lib/libcxx/string.cpp | 4 | ||||
-rw-r--r-- | system/lib/libcxx/strstream.cpp | 14 | ||||
-rw-r--r-- | system/lib/libcxx/support/win32/locale_win32.cpp | 25 | ||||
-rw-r--r-- | system/lib/libcxx/support/win32/support.cpp | 69 | ||||
-rw-r--r-- | system/lib/libcxx/system_error.cpp | 1 | ||||
-rw-r--r-- | system/lib/libcxx/thread.cpp | 10 | ||||
-rw-r--r-- | system/lib/libcxx/typeinfo.cpp | 15 | ||||
-rw-r--r-- | system/lib/libcxx/valarray.cpp | 2 |
23 files changed, 508 insertions, 164 deletions
diff --git a/system/lib/libcxx/CREDITS.TXT b/system/lib/libcxx/CREDITS.TXT index 5e4d14ec..368b526f 100644 --- a/system/lib/libcxx/CREDITS.TXT +++ b/system/lib/libcxx/CREDITS.TXT @@ -31,7 +31,7 @@ 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. +D: C++14 support, patches and bug fixes. N: Bill Fisher E: william.w.fisher@gmail.com @@ -76,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 @@ -105,6 +109,10 @@ 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. 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 c9b09b7a..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" @@ -118,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; } @@ -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 diff --git a/system/lib/libcxx/exception.cpp b/system/lib/libcxx/exception.cpp index 3487bd8b..83f6fd19 100644 --- a/system/lib/libcxx/exception.cpp +++ b/system/lib/libcxx/exception.cpp @@ -10,6 +10,7 @@ #include <stdio.h> #include "exception" +#include "new" #ifndef __has_include #define __has_include(inc) 0 @@ -90,14 +91,14 @@ terminate() _NOEXCEPT (*get_terminate())(); // handler should not return printf("terminate_handler unexpectedly returned\n"); - ::abort (); + ::abort(); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { // handler should not throw exception printf("terminate_handler unexpectedly threw an exception\n"); - ::abort (); + ::abort(); } #endif // _LIBCPP_NO_EXCEPTIONS } @@ -111,12 +112,17 @@ bool uncaught_exception() _NOEXCEPT // 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 @@ -143,16 +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 @@ -160,11 +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 @@ -177,11 +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 @@ -189,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 @@ -202,6 +261,7 @@ nested_exception::rethrow_nested() const rethrow_exception(__ptr_); } +#if !defined(__GLIBCXX__) exception_ptr current_exception() _NOEXCEPT { @@ -212,13 +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) { @@ -226,10 +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/ios.cpp b/system/lib/libcxx/ios.cpp index 732a61bb..bbe3c072 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) +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 f413681f..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; diff --git a/system/lib/libcxx/locale.cpp b/system/lib/libcxx/locale.cpp index ad64668f..a326323a 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__ @@ -26,7 +28,7 @@ #include "cstring" #include "cwctype" #include "__sso_allocator" -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) #include <support/win32/locale_win32.h> #else // _LIBCPP_MSVCRT #include <langinfo.h> @@ -36,7 +38,9 @@ // 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 @@ -107,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; @@ -116,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); @@ -147,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), @@ -757,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* @@ -1009,12 +1029,14 @@ ctype<char>::classic_table() _NOEXCEPT return __cloc()->__ctype_b; #elif __sun__ return __ctype_mask; -#elif defined(_LIBCPP_MSVCRT) +#elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) return _ctype+1; // internal ctype mask table defined in msvcrt.dll // This is assumed to be safe, which is a nonsense assumption because we're // going to end up dereferencing it later... #elif defined(__EMSCRIPTEN__) return *__ctype_b_loc(); +#elif defined(_AIX) + return (const unsigned long *)__lc_ctype_ptr->obj->mask; #else // Platform not supported: abort so the person doing the port knows what to // fix @@ -4350,7 +4372,7 @@ __num_put_base::__format_float(char* __fmtp, const char* __len, if (__flags & ios_base::showpoint) *__fmtp++ = '#'; ios_base::fmtflags floatfield = __flags & ios_base::floatfield; - bool uppercase = __flags & ios_base::uppercase; + bool uppercase = (__flags & ios_base::uppercase) != 0; if (floatfield == (ios_base::fixed | ios_base::scientific)) specify_precision = false; else @@ -4681,9 +4703,12 @@ __time_get::~__time_get() { freelocale(__loc_); } - +#if defined(__clang__) #pragma clang diagnostic ignored "-Wmissing-field-initializers" +#endif +#if defined(__GNUG__) #pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif template <> string @@ -4829,7 +4854,9 @@ __time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct) return result; } +#if defined(__clang__) #pragma clang diagnostic ignored "-Wmissing-braces" +#endif template <> wstring @@ -5848,7 +5875,7 @@ moneypunct_byname<char, true>::init(const char* nm) __frac_digits_ = lc->int_frac_digits; else __frac_digits_ = base::do_frac_digits(); -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) if (lc->p_sign_posn == 0) #else // _LIBCPP_MSVCRT if (lc->int_p_sign_posn == 0) @@ -5856,7 +5883,7 @@ moneypunct_byname<char, true>::init(const char* nm) __positive_sign_ = "()"; else __positive_sign_ = lc->positive_sign; -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) if(lc->n_sign_posn == 0) #else // _LIBCPP_MSVCRT if (lc->int_n_sign_posn == 0) @@ -5868,7 +5895,7 @@ moneypunct_byname<char, true>::init(const char* nm) // the same places in curr_symbol since there's no way to // represent anything else. string_type __dummy_curr_symbol = __curr_symbol_; -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) __init_pat(__pos_format_, __dummy_curr_symbol, true, lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, ' '); __init_pat(__neg_format_, __curr_symbol_, true, @@ -6007,7 +6034,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm) __frac_digits_ = lc->int_frac_digits; else __frac_digits_ = base::do_frac_digits(); -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) if (lc->p_sign_posn == 0) #else // _LIBCPP_MSVCRT if (lc->int_p_sign_posn == 0) @@ -6027,7 +6054,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm) wbe = wbuf + j; __positive_sign_.assign(wbuf, wbe); } -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) if (lc->n_sign_posn == 0) #else // _LIBCPP_MSVCRT if (lc->int_n_sign_posn == 0) @@ -6051,7 +6078,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm) // the same places in curr_symbol since there's no way to // represent anything else. string_type __dummy_curr_symbol = __curr_symbol_; -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) __init_pat(__pos_format_, __dummy_curr_symbol, true, lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, L' '); __init_pat(__neg_format_, __curr_symbol_, true, diff --git a/system/lib/libcxx/mutex.cpp b/system/lib/libcxx/mutex.cpp index 42195aa8..07678978 100644 --- a/system/lib/libcxx/mutex.cpp +++ b/system/lib/libcxx/mutex.cpp @@ -42,6 +42,7 @@ void mutex::unlock() _NOEXCEPT { int ec = pthread_mutex_unlock(&__m_); + (void)ec; assert(ec == 0); } @@ -79,6 +80,7 @@ fail: recursive_mutex::~recursive_mutex() { int e = pthread_mutex_destroy(&__m_); + (void)e; assert(e == 0); } @@ -94,6 +96,7 @@ void recursive_mutex::unlock() _NOEXCEPT { int e = pthread_mutex_unlock(&__m_); + (void)e; assert(e == 0); } diff --git a/system/lib/libcxx/new.cpp b/system/lib/libcxx/new.cpp index b23a516f..fa0331a8 100644 --- a/system/lib/libcxx/new.cpp +++ b/system/lib/libcxx/new.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_BUILDING_NEW + #include <stdlib.h> #include "new" @@ -28,16 +30,18 @@ #if defined(LIBCXXRT) || __has_include(<cxxabi.h>) #include <cxxabi.h> #endif // __has_include(<cxxabi.h>) - #ifndef _LIBCPPABI_VERSION + #if !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__) static std::new_handler __new_handler; #endif // _LIBCPPABI_VERSION #endif +#ifndef __GLIBCXX__ + // Implement all new and delete operators as weak definitions // in this shared library, so that they can be overriden by programs // that define non-weak copies of the functions. -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void * operator new(std::size_t size) #if !__has_feature(cxx_noexcept) @@ -64,7 +68,7 @@ operator new(std::size_t size) return p; } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void* operator new(size_t size, const std::nothrow_t&) _NOEXCEPT { @@ -83,7 +87,7 @@ operator new(size_t size, const std::nothrow_t&) _NOEXCEPT return p; } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void* operator new[](size_t size) #if !__has_feature(cxx_noexcept) @@ -93,7 +97,7 @@ operator new[](size_t size) return ::operator new(size); } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void* operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT { @@ -112,7 +116,7 @@ operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT return p; } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void operator delete(void* ptr) _NOEXCEPT { @@ -120,34 +124,40 @@ operator delete(void* ptr) _NOEXCEPT ::free(ptr); } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void operator delete(void* ptr, const std::nothrow_t&) _NOEXCEPT { ::operator delete(ptr); } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void operator delete[] (void* ptr) _NOEXCEPT { ::operator delete (ptr); } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void operator delete[] (void* ptr, const std::nothrow_t&) _NOEXCEPT { ::operator delete[](ptr); } +#endif // !__GLIBCXX__ + namespace std { +#ifndef __GLIBCXX__ const nothrow_t nothrow = {}; +#endif #ifndef _LIBCPPABI_VERSION +#ifndef __GLIBCXX__ + new_handler set_new_handler(new_handler handler) _NOEXCEPT { @@ -160,12 +170,16 @@ get_new_handler() _NOEXCEPT return __sync_fetch_and_add(&__new_handler, (new_handler)0); } +#endif // !__GLIBCXX__ + #ifndef LIBCXXRT bad_alloc::bad_alloc() _NOEXCEPT { } +#ifndef __GLIBCXX__ + bad_alloc::~bad_alloc() _NOEXCEPT { } @@ -176,6 +190,8 @@ bad_alloc::what() const _NOEXCEPT return "std::bad_alloc"; } +#endif // !__GLIBCXX__ + #endif //LIBCXXRT bad_array_new_length::bad_array_new_length() _NOEXCEPT @@ -187,12 +203,28 @@ bad_array_new_length::~bad_array_new_length() _NOEXCEPT } const char* +bad_array_length::what() const _NOEXCEPT +{ + return "bad_array_length"; +} + +bad_array_length::bad_array_length() _NOEXCEPT +{ +} + +bad_array_length::~bad_array_length() _NOEXCEPT +{ +} + +const char* bad_array_new_length::what() const _NOEXCEPT { return "bad_array_new_length"; } -#endif +#endif // _LIBCPPABI_VERSION + +#ifndef LIBSTDCXX void __throw_bad_alloc() @@ -202,4 +234,6 @@ __throw_bad_alloc() #endif } +#endif // !LIBSTDCXX + } // std diff --git a/system/lib/libcxx/optional.cpp b/system/lib/libcxx/optional.cpp new file mode 100644 index 00000000..fde071c9 --- /dev/null +++ b/system/lib/libcxx/optional.cpp |