summaryrefslogtreecommitdiffstats
path: root/contrib/libc++/src
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libc++/src')
-rw-r--r--contrib/libc++/src/algorithm.cpp1
-rw-r--r--contrib/libc++/src/debug.cpp110
-rw-r--r--contrib/libc++/src/exception.cpp121
-rw-r--r--contrib/libc++/src/future.cpp6
-rw-r--r--contrib/libc++/src/ios.cpp9
-rw-r--r--contrib/libc++/src/iostream.cpp16
-rw-r--r--contrib/libc++/src/locale.cpp127
-rw-r--r--contrib/libc++/src/mutex.cpp3
-rw-r--r--contrib/libc++/src/new.cpp56
-rw-r--r--contrib/libc++/src/optional.cpp25
-rw-r--r--contrib/libc++/src/random.cpp28
-rw-r--r--contrib/libc++/src/shared_mutex.cpp101
-rw-r--r--contrib/libc++/src/stdexcept.cpp18
-rw-r--r--contrib/libc++/src/string.cpp12
-rw-r--r--contrib/libc++/src/strstream.cpp14
-rw-r--r--contrib/libc++/src/system_error.cpp1
-rw-r--r--contrib/libc++/src/thread.cpp10
-rw-r--r--contrib/libc++/src/typeinfo.cpp15
-rw-r--r--contrib/libc++/src/valarray.cpp2
19 files changed, 525 insertions, 150 deletions
diff --git a/contrib/libc++/src/algorithm.cpp b/contrib/libc++/src/algorithm.cpp
index 6d5cf7c0..10c4c331 100644
--- a/contrib/libc++/src/algorithm.cpp
+++ b/contrib/libc++/src/algorithm.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
#include "algorithm"
#include "random"
#include "mutex"
diff --git a/contrib/libc++/src/debug.cpp b/contrib/libc++/src/debug.cpp
index 04d570e..d0e8679 100644
--- a/contrib/libc++/src/debug.cpp
+++ b/contrib/libc++/src/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
@@ -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);
diff --git a/contrib/libc++/src/exception.cpp b/contrib/libc++/src/exception.cpp
index 1d2f6b2..3ce6f2e 100644
--- a/contrib/libc++/src/exception.cpp
+++ b/contrib/libc++/src/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/contrib/libc++/src/future.cpp b/contrib/libc++/src/future.cpp
index 7d9a5b5..70919ab 100644
--- a/contrib/libc++/src/future.cpp
+++ b/contrib/libc++/src/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/contrib/libc++/src/ios.cpp b/contrib/libc++/src/ios.cpp
index 732a61b..bbe3c07 100644
--- a/contrib/libc++/src/ios.cpp
+++ b/contrib/libc++/src/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/contrib/libc++/src/iostream.cpp b/contrib/libc++/src/iostream.cpp
index f413681..7102e43 100644
--- a/contrib/libc++/src/iostream.cpp
+++ b/contrib/libc++/src/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/contrib/libc++/src/locale.cpp b/contrib/libc++/src/locale.cpp
index b15f077..a326323 100644
--- a/contrib/libc++/src/locale.cpp
+++ b/contrib/libc++/src/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),
@@ -755,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*
@@ -790,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) || defined(__NetBSD__)
+#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;
@@ -803,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) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
*low = isascii(*low) ? ctype<char>::__classic_upper_table()[*low]
: *low;
#else
@@ -817,7 +839,7 @@ ctype<wchar_t>::do_tolower(char_type c) const
{
#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c;
-#elif defined(__GLIBC__) || defined(EMSCRIPTEN) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
return isascii(c) ? ctype<char>::__classic_lower_table()[c] : c;
#else
return (isascii(c) && isupper_l(c, __cloc())) ? c-L'A'+'a' : c;
@@ -830,7 +852,7 @@ ctype<wchar_t>::do_tolower(char_type* low, const char_type* high) const
for (; low != high; ++low)
#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
*low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low;
-#elif defined(__GLIBC__) || defined(EMSCRIPTEN) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
*low = isascii(*low) ? ctype<char>::__classic_lower_table()[*low]
: *low;
#else
@@ -899,7 +921,7 @@ ctype<char>::do_toupper(char_type c) const
static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(c)]) : c;
#elif defined(__NetBSD__)
return static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]);
-#elif defined(__GLIBC__) || defined(EMSCRIPTEN)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
return isascii(c) ?
static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]) : c;
#else
@@ -916,7 +938,7 @@ ctype<char>::do_toupper(char_type* low, const char_type* high) const
static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(*low)]) : *low;
#elif defined(__NetBSD__)
*low = static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(*low)]);
-#elif defined(__GLIBC__) || defined(EMSCRIPTEN)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
*low = isascii(*low) ?
static_cast<char>(__classic_upper_table()[static_cast<size_t>(*low)]) : *low;
#else
@@ -933,7 +955,7 @@ ctype<char>::do_tolower(char_type c) const
static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(c)]) : c;
#elif defined(__NetBSD__)
return static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(c)]);
-#elif defined(__GLIBC__) || defined(EMSCRIPTEN) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
return isascii(c) ?
static_cast<char>(__classic_lower_table()[static_cast<size_t>(c)]) : c;
#else
@@ -949,7 +971,7 @@ ctype<char>::do_tolower(char_type* low, const char_type* high) const
*low = isascii(*low) ? static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(*low)]) : *low;
#elif defined(__NetBSD__)
*low = static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(*low)]);
-#elif defined(__GLIBC__) || defined(EMSCRIPTEN)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
*low = isascii(*low) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(*low)]) : *low;
#else
*low = (isascii(*low) && isupper_l(*low, __cloc())) ? *low-'A'+'a' : *low;
@@ -990,7 +1012,7 @@ ctype<char>::do_narrow(const char_type* low, const char_type* high, char dfault,
return low;
}
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
extern "C" const unsigned short ** __ctype_b_loc();
extern "C" const int ** __ctype_tolower_loc();
extern "C" const int ** __ctype_toupper_loc();
@@ -1007,16 +1029,19 @@ ctype<char>::classic_table() _NOEXCEPT
return __cloc()->__ctype_b;
#elif __sun__
return __ctype_mask;
-#elif defined(_WIN32)
+#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)
+#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
# warning ctype<char>::classic_table() is not implemented
+ printf("ctype<char>::classic_table() is not implemented\n");
abort();
return NULL;
#endif
@@ -1047,7 +1072,7 @@ ctype<char>::__classic_upper_table() _NOEXCEPT
return _C_toupper_tab_ + 1;
}
-#elif defined(EMSCRIPTEN)
+#elif defined(__EMSCRIPTEN__)
const int*
ctype<char>::__classic_lower_table() _NOEXCEPT
{
@@ -1059,7 +1084,7 @@ ctype<char>::__classic_upper_table() _NOEXCEPT
{
return *__ctype_toupper_loc();
}
-#endif // __GLIBC__ || EMSCRIPTEN || __NETBSD__
+#endif // __GLIBC__ || __EMSCRIPTEN__ || __NETBSD__
// template <> class ctype_byname<char>
@@ -3201,14 +3226,25 @@ __codecvt_utf8<wchar_t>::do_out(state_type&,
const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
{
+#if _WIN32
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+#else
const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
const uint32_t* _frm_nxt = _frm;
+#endif
uint8_t* _to = reinterpret_cast<uint8_t*>(to);
uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
uint8_t* _to_nxt = _to;
+#if _WIN32
+ result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+#else
result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
_Maxcode_, _Mode_);
+#endif
frm_nxt = frm + (_frm_nxt - _frm);
to_nxt = to + (_to_nxt - _to);
return r;
@@ -3222,11 +3258,19 @@ __codecvt_utf8<wchar_t>::do_in(state_type&,
const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
const uint8_t* _frm_nxt = _frm;
+#if _WIN32
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+ result r = utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+ _Maxcode_, _Mode_);
+#else
uint32_t* _to = reinterpret_cast<uint32_t*>(to);
uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
uint32_t* _to_nxt = _to;
result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
_Maxcode_, _Mode_);
+#endif
frm_nxt = frm + (_frm_nxt - _frm);
to_nxt = to + (_to_nxt - _to);
return r;
@@ -4328,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
@@ -4659,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
@@ -4807,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
@@ -5826,19 +5875,19 @@ moneypunct_byname<char, true>::init(const char* nm)
__frac_digits_ = lc->int_frac_digits;
else
__frac_digits_ = base::do_frac_digits();
-#ifdef _WIN32
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
if (lc->p_sign_posn == 0)
-#else // _WIN32
+#else // _LIBCPP_MSVCRT
if (lc->int_p_sign_posn == 0)
-#endif //_WIN32
+#endif // !_LIBCPP_MSVCRT
__positive_sign_ = "()";
else
__positive_sign_ = lc->positive_sign;
-#ifdef _WIN32
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
if(lc->n_sign_posn == 0)
-#else // _WIN32
+#else // _LIBCPP_MSVCRT
if (lc->int_n_sign_posn == 0)
-#endif // _WIN32
+#endif // !_LIBCPP_MSVCRT
__negative_sign_ = "()";
else
__negative_sign_ = lc->negative_sign;
@@ -5846,19 +5895,19 @@ 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 _WIN32
+#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,
lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, ' ');
-#else
+#else // _LIBCPP_MSVCRT
__init_pat(__pos_format_, __dummy_curr_symbol, true,
lc->int_p_cs_precedes, lc->int_p_sep_by_space,
lc->int_p_sign_posn, ' ');
__init_pat(__neg_format_, __curr_symbol_, true,
lc->int_n_cs_precedes, lc->int_n_sep_by_space,
lc->int_n_sign_posn, ' ');
-#endif // _WIN32
+#endif // !_LIBCPP_MSVCRT
}
template<>
@@ -5985,11 +6034,11 @@ moneypunct_byname<wchar_t, true>::init(const char* nm)
__frac_digits_ = lc->int_frac_digits;
else
__frac_digits_ = base::do_frac_digits();
-#ifdef _WIN32
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
if (lc->p_sign_posn == 0)
-#else // _WIN32
+#else // _LIBCPP_MSVCRT
if (lc->int_p_sign_posn == 0)
-#endif // _WIN32
+#endif // !_LIBCPP_MSVCRT
__positive_sign_ = L"()";
else
{
@@ -6005,11 +6054,11 @@ moneypunct_byname<wchar_t, true>::init(const char* nm)
wbe = wbuf + j;
__positive_sign_.assign(wbuf, wbe);
}
-#ifdef _WIN32
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
if (lc->n_sign_posn == 0)
-#else // _WIN32
+#else // _LIBCPP_MSVCRT
if (lc->int_n_sign_posn == 0)
-#endif // _WIN32
+#endif // !_LIBCPP_MSVCRT
__negative_sign_ = L"()";
else
{
@@ -6029,19 +6078,19 @@ 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 _WIN32
+#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,
lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, L' ');
-#else // _WIN32
+#else // _LIBCPP_MSVCRT
__init_pat(__pos_format_, __dummy_curr_symbol, true,
lc->int_p_cs_precedes, lc->int_p_sep_by_space,
lc->int_p_sign_posn, L' ');
__init_pat(__neg_format_, __curr_symbol_, true,
lc->int_n_cs_precedes, lc->int_n_sep_by_space,
lc->int_n_sign_posn, L' ');
-#endif // _WIN32
+#endif // !_LIBCPP_MSVCRT
}
void __do_nothing(void*) {}
diff --git a/contrib/libc++/src/mutex.cpp b/contrib/libc++/src/mutex.cpp
index 42195aa..0767897 100644
--- a/contrib/libc++/src/mutex.cpp
+++ b/contrib/libc++/src/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/contrib/libc++/src/new.cpp b/contrib/libc++/src/new.cpp
index b23a516..f4998cf 100644
--- a/contrib/libc++/src/new.cpp
+++ b/contrib/libc++/src/new.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+#define _LIBCPP_BUILDING_NEW
+
#include <stdlib.h>
#include "new"
@@ -20,7 +22,7 @@
#ifndef _LIBCPPABI_VERSION
// On Darwin, there are two STL shared libraries and a lower level ABI
- // shared libray. The global holding the current new handler is
+ // shared library. The global holding the current new handler is
// in the ABI library and named __cxa_new_handler.
#define __new_handler __cxxabiapple::__cxa_new_handler
#endif
@@ -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/contrib/libc++/src/optional.cpp b/contrib/libc++/src/optional.cpp
new file mode 100644
index 0000000..b614d81
--- /dev/null
+++ b/contrib/libc++/src/optional.cpp
@@ -0,0 +1,25 @@
+//===------------------------ optional.cpp --------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "experimental/optional"
+
+namespace std // purposefully not using versioning namespace
+{ namespace experimental {
+
+#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+
+bad_optional_access::~bad_optional_access() _NOEXCEPT {}
+
+#else
+
+bad_optional_access::~bad_optional_access() _NOEXCEPT = default;
+
+#endif
+
+}} // std::experimental
diff --git a/contrib/libc++/src/random.cpp b/contrib/libc++/src/random.cpp
index 97a40c5..bd24f2e 100644
--- a/contrib/libc++/src/random.cpp
+++ b/contrib/libc++/src/random.cpp
@@ -7,18 +7,45 @@
//
//===----------------------------------------------------------------------===//
+#if defined(_WIN32)
+// Must be defined before including stdlib.h to enable rand_s().
+#define _CRT_RAND_S
+#include <stdio.h>
+#endif
+
#include "random"
#include "system_error"
#ifdef __sun__
#define rename solaris_headers_are_broken
#endif
+#if !defined(_WIN32)
#include <fcntl.h>
#include <unistd.h>
+#endif // defined(_WIN32)
#include <errno.h>
_LIBCPP_BEGIN_NAMESPACE_STD
+#if defined(_WIN32)
+random_device::random_device(const string&)
+{
+}
+
+random_device::~random_device()
+{
+}
+
+unsigned
+random_device::operator()()
+{
+ unsigned r;
+ errno_t err = rand_s(&r);
+ if (err)
+ __throw_system_error(err, "random_device rand_s failed.");
+ return r;
+}
+#else
random_device::random_device(const string& __token)
: __f_(open(__token.c_str(), O_RDONLY))
{
@@ -38,6 +65,7 @@ random_device::operator()()
read(__f_, &r, sizeof(r));
return r;
}
+#endif // defined(_WIN32)
double
random_device::entropy() const _NOEXCEPT
diff --git a/contrib/libc++/src/shared_mutex.cpp b/contrib/libc++/src/shared_mutex.cpp
new file mode 100644
index 0000000..5fb22e4
--- /dev/null
+++ b/contrib/libc++/src/shared_mutex.cpp
@@ -0,0 +1,101 @@
+//===---------------------- shared_mutex.cpp ------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#define _LIBCPP_BUILDING_SHARED_MUTEX
+#include "shared_mutex"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+shared_mutex::shared_mutex()
+ : __state_(0)
+{
+}
+
+// Exclusive ownership
+
+void
+shared_mutex::lock()
+{
+ unique_lock<mutex> lk(__mut_);
+ while (__state_ & __write_entered_)
+ __gate1_.wait(lk);
+ __state_ |= __write_entered_;
+ while (__state_ & __n_readers_)
+ __gate2_.wait(lk);
+}
+
+bool
+shared_mutex::try_lock()
+{
+ unique_lock<mutex> lk(__mut_);
+ if (__state_ == 0)
+ {
+ __state_ = __write_entered_;
+ return true;
+ }
+ return false;
+}
+
+void
+shared_mutex::unlock()
+{
+ lock_guard<mutex> _(__mut_);
+ __state_ = 0;
+ __gate1_.notify_all();
+}
+
+// Shared ownership
+
+void
+shared_mutex::lock_shared()
+{
+ unique_lock<mutex> lk(__mut_);
+ while ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_)
+ __gate1_.wait(lk);
+ unsigned num_readers = (__state_ & __n_readers_) + 1;
+ __state_ &= ~__n_readers_;
+ __state_ |= num_readers;
+}
+
+bool
+shared_mutex::try_lock_shared()
+{
+ unique_lock<mutex> lk(__mut_);
+ unsigned num_readers = __state_ & __n_readers_;
+ if (!(__state_ & __write_entered_) && num_readers != __n_readers_)
+ {
+ ++num_readers;
+ __state_ &= ~__n_readers_;
+ __state_ |= num_readers;
+ return true;
+ }
+ return false;
+}
+
+void
+shared_mutex::unlock_shared()
+{
+ lock_guard<mutex> _(__mut_);
+ unsigned num_readers = (__state_ & __n_readers_) - 1;
+ __state_ &= ~__n_readers_;
+ __state_ |= num_readers;
+ if (__state_ & __write_entered_)
+ {
+ if (num_readers == 0)
+ __gate2_.notify_one();
+ }
+ else
+ {
+ if (num_readers == __n_readers_ - 1)
+ __gate1_.notify_one();
+ }
+}
+
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libc++/src/stdexcept.cpp b/contrib/libc++/src/stdexcept.cpp
index 8d25f3e..a4207d6 100644
--- a/contrib/libc++/src/stdexcept.cpp
+++ b/contrib/libc++/src/stdexcept.cpp
@@ -28,7 +28,9 @@
// Note: optimize for size
+#if ! defined(_LIBCPP_MSVC)
#pragma GCC visibility push(hidden)
+#endif
namespace
{
@@ -47,9 +49,9 @@ private:
count_t& count() const _NOEXCEPT {return (count_t&)(*(str_ - sizeof(count_t)));}
public:
explicit __libcpp_nmstr(const char* msg);
- __libcpp_nmstr(const __libcpp_nmstr& s) _LIBCPP_CANTTHROW;
- __libcpp_nmstr& operator=(const __libcpp_nmstr& s) _LIBCPP_CANTTHROW;
- ~__libcpp_nmstr() _LIBCPP_CANTTHROW;
+ __libcpp_nmstr(const __libcpp_nmstr& s) _NOEXCEPT;
+ __libcpp_nmstr& operator=(const __libcpp_nmstr& s) _NOEXCEPT;
+ ~__libcpp_nmstr();
const char* c_str() const _NOEXCEPT {return str_;}
};
@@ -65,14 +67,14 @@ __libcpp_nmstr::__libcpp_nmstr(const char* msg)
}
inline
-__libcpp_nmstr::__libcpp_nmstr(const __libcpp_nmstr& s)
+__libcpp_nmstr::__libcpp_nmstr(const __libcpp_nmstr& s) _NOEXCEPT
: str_(s.str_)
{
__sync_add_and_fetch(&count(), 1);
}
__libcpp_nmstr&
-__libcpp_nmstr::operator=(const __libcpp_nmstr& s)
+__libcpp_nmstr::operator=(const __libcpp_nmstr& s) _NOEXCEPT
{
const char* p = str_;
str_ = s.str_;
@@ -91,7 +93,9 @@ __libcpp_nmstr::~__libcpp_nmstr()
}
+#if ! defined(_LIBCPP_MSVC)
#pragma GCC visibility pop
+#endif
namespace std // purposefully not using versioning namespace
{
@@ -123,7 +127,7 @@ logic_error::operator=(const logic_error& le) _NOEXCEPT
return *this;
}
-#ifndef _LIBCPPABI_VERSION
+#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
logic_error::~logic_error() _NOEXCEPT
{
@@ -167,7 +171,7 @@ runtime_error::operator=(const runtime_error& le) _NOEXCEPT
return *this;
}
-#ifndef _LIBCPPABI_VERSION
+#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
runtime_error::~runtime_error() _NOEXCEPT
{
diff --git a/contrib/libc++/src/string.cpp b/contrib/libc++/src/string.cpp
index c6fe408..fde5212 100644
--- a/contrib/libc++/src/string.cpp
+++ b/contrib/libc++/src/string.cpp
@@ -7,15 +7,18 @@
//
//===----------------------------------------------------------------------===//
+#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
+
#include "string"
#include "cstdlib"
#include "cwchar"
#include "cerrno"
#include "limits"
#include "stdexcept"
-#ifdef _WIN32
+#ifdef _LIBCPP_MSVCRT
#include "support/win32/support.h"
-#endif // _WIN32
+#endif // _LIBCPP_MSVCRT
+#include <stdio.h>
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -38,6 +41,7 @@ void throw_helper( const string& msg )
#ifndef _LIBCPP_NO_EXCEPTIONS
throw T( msg );
#else
+ printf("%s\n", msg.c_str());
abort();
#endif
}
@@ -87,7 +91,7 @@ inline
int
as_integer(const string& func, const string& s, size_t* idx, int base )
{
- // Use long as no Stantard string to integer exists.
+ // Use long as no Standard string to integer exists.
long r = as_integer_helper<long>( func, s, idx, base, strtol );
if (r < numeric_limits<int>::min() || numeric_limits<int>::max() < r)
throw_from_string_out_of_range(func);
@@ -425,7 +429,7 @@ inline
wide_printf
get_swprintf()
{
-#ifndef _WIN32
+#ifndef _LIBCPP_MSVCRT
return swprintf;
#else
return static_cast<int (__cdecl*)(wchar_t* __restrict, size_t, const wchar_t*__restrict, ...)>(swprintf);
diff --git a/contrib/libc++/src/strstream.cpp b/contrib/libc++/src/strstream.cpp
index 518422b..c1965ea 100644
--- a/contrib/libc++/src/strstream.cpp
+++ b/contrib/libc++/src/strstream.cpp
@@ -156,13 +156,13 @@ strstreambuf::overflow(int_type __c)
{
if ((__strmode_ & __dynamic) == 0 || (__strmode_ & __frozen) != 0)
return int_type(EOF);
- streamsize old_size = (epptr() ? epptr() : egptr()) - eback();
- streamsize new_size = max<streamsize>(__alsize_, 2*old_size);
+ size_t old_size = static_cast<size_t> ((epptr() ? epptr() : egptr()) - eback());
+ size_t new_size = max<size_t>(static_cast<size_t>(__alsize_), 2*old_size);
if (new_size == 0)
new_size = __default_alsize;
char* buf = nullptr;
if (__palloc_)
- buf = static_cast<char*>(__palloc_(static_cast<size_t>(new_size)));
+ buf = static_cast<char*>(__palloc_(new_size));
else
buf = new char[new_size];
if (buf == nullptr)
@@ -229,8 +229,8 @@ strstreambuf::pos_type
strstreambuf::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which)
{
off_type __p(-1);
- bool pos_in = __which & ios::in;
- bool pos_out = __which & ios::out;
+ bool pos_in = (__which & ios::in) != 0;
+ bool pos_out = (__which & ios::out) != 0;
bool legal = false;
switch (__way)
{
@@ -287,8 +287,8 @@ strstreambuf::pos_type
strstreambuf::seekpos(pos_type __sp, ios_base::openmode __which)
{
off_type __p(-1);
- bool pos_in = __which & ios::in;
- bool pos_out = __which & ios::out;
+ bool pos_in = (__which & ios::in) != 0;
+ bool pos_out = (__which & ios::out) != 0;
if (pos_in || pos_out)
{
if (!((pos_in && gptr() == nullptr) || (pos_out && pptr() == nullptr)))
diff --git a/contrib/libc++/src/system_error.cpp b/contrib/libc++/src/system_error.cpp
index 7376b77..b40409f 100644
--- a/contrib/libc++/src/system_error.cpp
+++ b/contrib/libc++/src/system_error.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+#define _LIBCPP_BUILDING_SYSTEM_ERROR
#include "system_error"
#include "string"
#include "cstring"
diff --git a/contrib/libc++/src/thread.cpp b/contrib/libc++/src/thread.cpp
index 1fd8bb0..338a8a2 100644
--- a/contrib/libc++/src/thread.cpp
+++ b/contrib/libc++/src/thread.cpp
@@ -14,9 +14,9 @@
#include "limits"
#include <sys/types.h>
#if !defined(_WIN32)
-#if !defined(__sun__) && !defined(__linux__)
+#if !defined(__sun__) && !defined(__linux__) && !defined(_AIX)
#include <sys/sysctl.h>
-#endif // !__sun__ && !__linux__
+#endif // !__sun__ && !__linux__ && !_AIX
#include <unistd.h>
#endif // !_WIN32
@@ -89,7 +89,11 @@ thread::hardware_concurrency() _NOEXCEPT
#else // defined(CTL_HW) && defined(HW_NCPU)
// TODO: grovel through /proc or check cpuid on x86 and similar
// instructions on other architectures.
-#warning hardware_concurrency not yet implemented
+# if defined(_MSC_VER) && ! defined(__clang__)
+ _LIBCPP_WARNING("hardware_concurrency not yet implemented")
+# else
+# warning hardware_concurrency not yet implemented
+# endif
return 0; // Means not computable [thread.thread.static]
#endif // defined(CTL_HW) && defined(HW_NCPU)
}
diff --git a/contrib/libc++/src/typeinfo.cpp b/contrib/libc++/src/typeinfo.cpp
index 6082894..b428120 100644
--- a/contrib/libc++/src/typeinfo.cpp
+++ b/contrib/libc++/src/typeinfo.cpp
@@ -20,12 +20,18 @@
#include "typeinfo"
-#if !(defined(_LIBCPPABI_VERSION) || defined(LIBCXXRT))
+#if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)
std::bad_cast::bad_cast() _NOEXCEPT
{
}
+std::bad_typeid::bad_typeid() _NOEXCEPT
+{
+}
+
+#ifndef __GLIBCXX__
+
std::bad_cast::~bad_cast() _NOEXCEPT
{
}
@@ -36,10 +42,6 @@ std::bad_cast::what() const _NOEXCEPT
return "std::bad_cast";
}
-std::bad_typeid::bad_typeid() _NOEXCEPT
-{
-}
-
std::bad_typeid::~bad_typeid() _NOEXCEPT
{
}
@@ -67,4 +69,5 @@ std::bad_typeid::what() const _NOEXCEPT
}
#endif
-#endif // _LIBCPPABI_VERSION
+#endif // !__GLIBCXX__
+#endif // !LIBCXXRT && !_LIBCPPABI_VERSION
diff --git a/contrib/libc++/src/valarray.cpp b/contrib/libc++/src/valarray.cpp
index 2d8db52..e4c9ed0 100644
--- a/contrib/libc++/src/valarray.cpp
+++ b/contrib/libc++/src/valarray.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
+
#include "valarray"
_LIBCPP_BEGIN_NAMESPACE_STD
OpenPOWER on IntegriCloud