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/stdexcept.cpp | |
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/stdexcept.cpp')
-rw-r--r-- | system/lib/libcxx/stdexcept.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/system/lib/libcxx/stdexcept.cpp b/system/lib/libcxx/stdexcept.cpp index 28917887..660ebfe2 100644 --- a/system/lib/libcxx/stdexcept.cpp +++ b/system/lib/libcxx/stdexcept.cpp @@ -16,6 +16,16 @@ #include <cstddef> #include "system_error" +#ifndef __has_include +#define __has_include(inc) 0 +#endif + +#if __APPLE__ +#include <cxxabi.h> +#elif defined(LIBCXXRT) || __has_include(<cxxabi.h>) +#include <cxxabi.h> +#endif + // Note: optimize for size #pragma GCC visibility push(hidden) @@ -29,7 +39,7 @@ private: const char* str_; typedef std::size_t unused_t; - typedef std::int32_t count_t; + typedef std::ptrdiff_t count_t; static const std::ptrdiff_t offset = static_cast<std::ptrdiff_t>(2*sizeof(unused_t) + sizeof(count_t)); @@ -67,7 +77,7 @@ __libcpp_nmstr::operator=(const __libcpp_nmstr& s) const char* p = str_; str_ = s.str_; __sync_add_and_fetch(&count(), 1); - if (__sync_add_and_fetch((count_t*)(p-sizeof(count_t)), -1) < 0) + if (__sync_add_and_fetch((count_t*)(p-sizeof(count_t)), count_t(-1)) < 0) delete [] (p-offset); return *this; } @@ -75,7 +85,7 @@ __libcpp_nmstr::operator=(const __libcpp_nmstr& s) inline __libcpp_nmstr::~__libcpp_nmstr() { - if (__sync_add_and_fetch(&count(), -1) < 0) + if (__sync_add_and_fetch(&count(), count_t(-1)) < 0) delete [] (str_ - offset); } @@ -113,6 +123,8 @@ logic_error::operator=(const logic_error& le) _NOEXCEPT return *this; } +#ifndef _LIBCPPABI_VERSION + logic_error::~logic_error() _NOEXCEPT { __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_; @@ -126,6 +138,8 @@ logic_error::what() const _NOEXCEPT return s.c_str(); } +#endif + runtime_error::runtime_error(const string& msg) { __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_; @@ -153,6 +167,8 @@ runtime_error::operator=(const runtime_error& le) _NOEXCEPT return *this; } +#ifndef _LIBCPPABI_VERSION + runtime_error::~runtime_error() _NOEXCEPT { __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_; @@ -175,4 +191,6 @@ range_error::~range_error() _NOEXCEPT {} overflow_error::~overflow_error() _NOEXCEPT {} underflow_error::~underflow_error() _NOEXCEPT {} +#endif + } // std |