diff options
author | Howard Hinnant <hhinnant@apple.com> | 2010-08-11 17:04:31 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2010-08-11 17:04:31 +0000 |
commit | 54b409fdb9489b305bf95f4d4f52b49c7926c429 (patch) | |
tree | 4e1c893fe8a940ea767c4eef990dff879fcbbd25 /libcxx/src | |
parent | 37aab7674a74dd0224b14976e91f89abe48e9ae9 (diff) | |
download | bcm5719-llvm-54b409fdb9489b305bf95f4d4f52b49c7926c429.tar.gz bcm5719-llvm-54b409fdb9489b305bf95f4d4f52b49c7926c429.zip |
now works with -fno-exceptions and -fno-rtti
llvm-svn: 110828
Diffstat (limited to 'libcxx/src')
-rw-r--r-- | libcxx/src/exception.cpp | 10 | ||||
-rw-r--r-- | libcxx/src/ios.cpp | 14 | ||||
-rw-r--r-- | libcxx/src/locale.cpp | 62 | ||||
-rw-r--r-- | libcxx/src/memory.cpp | 4 | ||||
-rw-r--r-- | libcxx/src/mutex.cpp | 4 | ||||
-rw-r--r-- | libcxx/src/new.cpp | 14 | ||||
-rw-r--r-- | libcxx/src/string.cpp | 32 | ||||
-rw-r--r-- | libcxx/src/system_error.cpp | 2 | ||||
-rw-r--r-- | libcxx/src/thread.cpp | 4 |
9 files changed, 144 insertions, 2 deletions
diff --git a/libcxx/src/exception.cpp b/libcxx/src/exception.cpp index 9bed6f49bf2..7c5211534b4 100644 --- a/libcxx/src/exception.cpp +++ b/libcxx/src/exception.cpp @@ -54,15 +54,21 @@ std::set_terminate(std::terminate_handler func) throw() void std::terminate() { - try { +#ifndef _LIBCPP_NO_EXCEPTIONS + try + { +#endif (*__terminate_handler)(); // handler should not return ::abort (); +#ifndef _LIBCPP_NO_EXCEPTIONS } - catch (...) { + catch (...) + { // handler should not throw exception ::abort (); } +#endif } diff --git a/libcxx/src/ios.cpp b/libcxx/src/ios.cpp index eb597bfbdfd..4139cd4c912 100644 --- a/libcxx/src/ios.cpp +++ b/libcxx/src/ios.cpp @@ -260,8 +260,10 @@ ios_base::clear(iostate state) __rdstate_ = state; else __rdstate_ = state | badbit; +#ifndef _LIBCPP_NO_EXCEPTIONS if (((state | (__rdbuf_ ? goodbit : badbit)) & __exceptions_) != 0) throw failure("ios_base::clear"); +#endif } // init @@ -300,23 +302,31 @@ ios_base::copyfmt(const ios_base& rhs) if (__event_cap_ < rhs.__event_size_) { new_callbacks.reset((event_callback*)malloc(sizeof(event_callback) * rhs.__event_size_)); +#ifndef _LIBCPP_NO_EXCEPTIONS if (!new_callbacks) throw bad_alloc(); +#endif new_ints.reset((int*)malloc(sizeof(int) * rhs.__event_size_)); +#ifndef _LIBCPP_NO_EXCEPTIONS if (!new_ints) throw bad_alloc(); +#endif } if (__iarray_cap_ < rhs.__iarray_size_) { new_longs.reset((long*)malloc(sizeof(long) * rhs.__iarray_size_)); +#ifndef _LIBCPP_NO_EXCEPTIONS if (!new_longs) throw bad_alloc(); +#endif } if (__parray_cap_ < rhs.__parray_size_) { new_pointers.reset((void**)malloc(sizeof(void*) * rhs.__parray_size_)); +#ifndef _LIBCPP_NO_EXCEPTIONS if (!new_pointers) throw bad_alloc(); +#endif } // Got everything we need. Copy everything but __rdstate_, __rdbuf_ and __exceptions_ __fmtflags_ = rhs.__fmtflags_; @@ -417,16 +427,20 @@ void ios_base::__set_badbit_and_consider_rethrow() { __rdstate_ |= badbit; +#ifndef _LIBCPP_NO_EXCEPTIONS if (__exceptions_ & badbit) throw; +#endif } void ios_base::__set_failbit_and_consider_rethrow() { __rdstate_ |= failbit; +#ifndef _LIBCPP_NO_EXCEPTIONS if (__exceptions_ & failbit) throw; +#endif } bool diff --git a/libcxx/src/locale.cpp b/libcxx/src/locale.cpp index e0d97dc670d..93d881e5f9b 100644 --- a/libcxx/src/locale.cpp +++ b/libcxx/src/locale.cpp @@ -132,8 +132,10 @@ locale::__imp::__imp(const string& name, size_t refs) name_(name), facets_(N) { +#ifndef _LIBCPP_NO_EXCEPTIONS try { +#endif facets_ = locale::classic().__locale_->facets_; for (unsigned i = 0; i < facets_.size(); ++i) if (facets_[i]) @@ -158,6 +160,7 @@ locale::__imp::__imp(const string& name, size_t refs) install(new time_put_byname<wchar_t>(name_)); install(new messages_byname<char>(name_)); install(new messages_byname<wchar_t>(name_)); +#ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { @@ -166,6 +169,7 @@ locale::__imp::__imp(const string& name, size_t refs) facets_[i]->__release_shared(); throw; } +#endif } locale::__imp::__imp(const __imp& other) @@ -186,8 +190,10 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c) for (unsigned i = 0; i < facets_.size(); ++i) if (facets_[i]) facets_[i]->__add_shared(); +#ifndef _LIBCPP_NO_EXCEPTIONS try { +#endif if (c & locale::collate) { install(new collate_byname<char>(name)); @@ -226,6 +232,7 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c) install(new messages_byname<char>(name)); install(new messages_byname<wchar_t>(name)); } +#ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { @@ -234,6 +241,7 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c) facets_[i]->__release_shared(); throw; } +#endif } template<class F> @@ -253,8 +261,10 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c) for (unsigned i = 0; i < facets_.size(); ++i) if (facets_[i]) facets_[i]->__add_shared(); +#ifndef _LIBCPP_NO_EXCEPTIONS try { +#endif if (c & locale::collate) { install_from<_STD::collate<char> >(one); @@ -301,6 +311,7 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c) install_from<_STD::messages<char> >(one); install_from<_STD::messages<wchar_t> >(one); } +#ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { @@ -309,6 +320,7 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c) facets_[i]->__release_shared(); throw; } +#endif } locale::__imp::__imp(const __imp& other, facet* f, long id) @@ -346,8 +358,10 @@ locale::__imp::install(facet* f, long id) const locale::facet* locale::__imp::use_facet(long id) const { +#ifndef _LIBCPP_NO_EXCEPTIONS if (!has_facet(id)) throw bad_cast(); +#endif return facets_[id]; } @@ -414,8 +428,12 @@ locale::operator=(const locale& other) throw() } locale::locale(const char* name) +#ifndef _LIBCPP_NO_EXCEPTIONS : __locale_(name ? new __imp(name) : throw runtime_error("locale constructed with null")) +#else + : __locale_(new __imp(name)) +#endif { __locale_->__add_shared(); } @@ -427,8 +445,12 @@ locale::locale(const string& name) } locale::locale(const locale& other, const char* name, category c) +#ifndef _LIBCPP_NO_EXCEPTIONS : __locale_(name ? new __imp(*other.__locale_, name, c) : throw runtime_error("locale constructed with null")) +#else + : __locale_(new __imp(*other.__locale_, name, c)) +#endif { __locale_->__add_shared(); } @@ -545,18 +567,22 @@ collate_byname<char>::collate_byname(const char* n, size_t refs) : collate<char>(refs), __l(newlocale(LC_ALL_MASK, n, 0)) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) throw runtime_error("collate_byname<char>::collate_byname" " failed to construct for " + string(n)); +#endif } collate_byname<char>::collate_byname(const string& name, size_t refs) : collate<char>(refs), __l(newlocale(LC_ALL_MASK, name.c_str(), 0)) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) throw runtime_error("collate_byname<char>::collate_byname" " failed to construct for " + name); +#endif } collate_byname<char>::~collate_byname() @@ -593,18 +619,22 @@ collate_byname<wchar_t>::collate_byname(const char* n, size_t refs) : collate<wchar_t>(refs), __l(newlocale(LC_ALL_MASK, n, 0)) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) throw runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)" " failed to construct for " + string(n)); +#endif } collate_byname<wchar_t>::collate_byname(const string& name, size_t refs) : collate<wchar_t>(refs), __l(newlocale(LC_ALL_MASK, name.c_str(), 0)) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) throw runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)" " failed to construct for " + name); +#endif } collate_byname<wchar_t>::~collate_byname() @@ -828,18 +858,22 @@ ctype_byname<char>::ctype_byname(const char* name, size_t refs) : ctype<char>(0, false, refs), __l(newlocale(LC_ALL_MASK, name, 0)) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) throw runtime_error("ctype_byname<char>::ctype_byname" " failed to construct for " + string(name)); +#endif } ctype_byname<char>::ctype_byname(const string& name, size_t refs) : ctype<char>(0, false, refs), __l(newlocale(LC_ALL_MASK, name.c_str(), 0)) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) throw runtime_error("ctype_byname<char>::ctype_byname" " failed to construct for " + name); +#endif } ctype_byname<char>::~ctype_byname() @@ -881,18 +915,22 @@ ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs) : ctype<wchar_t>(refs), __l(newlocale(LC_ALL_MASK, name, 0)) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) throw runtime_error("ctype_byname<wchar_t>::ctype_byname" " failed to construct for " + string(name)); +#endif } ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs) : ctype<wchar_t>(refs), __l(newlocale(LC_ALL_MASK, name.c_str(), 0)) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) throw runtime_error("ctype_byname<wchar_t>::ctype_byname" " failed to construct for " + name); +#endif } ctype_byname<wchar_t>::~ctype_byname() @@ -1092,9 +1130,11 @@ codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs) : locale::facet(refs), __l(newlocale(LC_ALL_MASK, nm, 0)) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) throw runtime_error("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname" " failed to construct for " + string(nm)); +#endif } codecvt<wchar_t, char, mbstate_t>::~codecvt() @@ -3832,9 +3872,11 @@ numpunct_byname<char>::__init(const char* nm) if (strcmp(nm, "C") != 0) { unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); +#ifndef _LIBCPP_NO_EXCEPTIONS if (loc == 0) throw runtime_error("numpunct_byname<char>::numpunct_byname" " failed to construct for " + string(nm)); +#endif lconv* lc = localeconv_l(loc.get()); if (*lc->decimal_point) __decimal_point_ = *lc->decimal_point; @@ -3869,9 +3911,11 @@ numpunct_byname<wchar_t>::__init(const char* nm) if (strcmp(nm, "C") != 0) { unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); +#ifndef _LIBCPP_NO_EXCEPTIONS if (loc == 0) throw runtime_error("numpunct_byname<char>::numpunct_byname" " failed to construct for " + string(nm)); +#endif lconv* lc = localeconv_l(loc.get()); if (*lc->decimal_point) __decimal_point_ = *lc->decimal_point; @@ -4274,17 +4318,21 @@ __time_get_c_storage<wchar_t>::__r() const __time_get::__time_get(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, 0)) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (__loc_ == 0) throw runtime_error("time_get_byname" " failed to construct for " + string(nm)); +#endif } __time_get::__time_get(const string& nm) : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0)) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (__loc_ == 0) throw runtime_error("time_get_byname" " failed to construct for " + nm); +#endif } __time_get::~__time_get() @@ -4921,17 +4969,21 @@ __time_get_storage<wchar_t>::__do_date_order() const __time_put::__time_put(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, 0)) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (__loc_ == 0) throw runtime_error("time_put_byname" " failed to construct for " + string(nm)); +#endif } __time_put::__time_put(const string& nm) : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0)) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (__loc_ == 0) throw runtime_error("time_put_byname" " failed to construct for " + nm); +#endif } __time_put::~__time_put() @@ -5210,9 +5262,11 @@ moneypunct_byname<char, false>::init(const char* nm) { typedef moneypunct<char, false> base; unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); +#ifndef _LIBCPP_NO_EXCEPTIONS if (loc == 0) throw runtime_error("moneypunct_byname" " failed to construct for " + string(nm)); +#endif lconv* lc = localeconv_l(loc.get()); if (*lc->mon_decimal_point) __decimal_point_ = *lc->mon_decimal_point; @@ -5246,9 +5300,11 @@ moneypunct_byname<char, true>::init(const char* nm) { typedef moneypunct<char, true> base; unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); +#ifndef _LIBCPP_NO_EXCEPTIONS if (loc == 0) throw runtime_error("moneypunct_byname" " failed to construct for " + string(nm)); +#endif lconv* lc = localeconv_l(loc.get()); if (*lc->mon_decimal_point) __decimal_point_ = *lc->mon_decimal_point; @@ -5282,9 +5338,11 @@ moneypunct_byname<wchar_t, false>::init(const char* nm) { typedef moneypunct<wchar_t, false> base; unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); +#ifndef _LIBCPP_NO_EXCEPTIONS if (loc == 0) throw runtime_error("moneypunct_byname" " failed to construct for " + string(nm)); +#endif lconv* lc = localeconv_l(loc.get()); if (*lc->mon_decimal_point) __decimal_point_ = static_cast<wchar_t>(*lc->mon_decimal_point); @@ -5341,9 +5399,11 @@ moneypunct_byname<wchar_t, true>::init(const char* nm) { typedef moneypunct<wchar_t, true> base; unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); +#ifndef _LIBCPP_NO_EXCEPTIONS if (loc == 0) throw runtime_error("moneypunct_byname" " failed to construct for " + string(nm)); +#endif lconv* lc = localeconv_l(loc.get()); if (*lc->mon_decimal_point) __decimal_point_ = static_cast<wchar_t>(*lc->mon_decimal_point); @@ -5398,7 +5458,9 @@ void __do_nothing(void*) {} void __throw_runtime_error(const char* msg) { +#ifndef _LIBCPP_NO_EXCEPTIONS throw runtime_error(msg); +#endif } template class collate<char>; diff --git a/libcxx/src/memory.cpp b/libcxx/src/memory.cpp index f35b838b6bc..2caa12b3a99 100644 --- a/libcxx/src/memory.cpp +++ b/libcxx/src/memory.cpp @@ -107,12 +107,16 @@ __shared_weak_count::lock() return 0; } +#ifndef _LIBCPP_NO_RTTI + const void* __shared_weak_count::__get_deleter(const type_info&) const { return 0; } +#endif + void declare_reachable(void*) { diff --git a/libcxx/src/mutex.cpp b/libcxx/src/mutex.cpp index 1f8160d0a58..fa1e7a0e8ea 100644 --- a/libcxx/src/mutex.cpp +++ b/libcxx/src/mutex.cpp @@ -220,8 +220,10 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*)) pthread_cond_wait(&cv, &mut); if (flag == 0) { +#ifndef _LIBCPP_NO_EXCEPTIONS try { +#endif flag = 1; pthread_mutex_unlock(&mut); func(arg); @@ -229,6 +231,7 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*)) flag = ~0ul; pthread_mutex_unlock(&mut); pthread_cond_broadcast(&cv); +#ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { @@ -238,6 +241,7 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*)) pthread_cond_broadcast(&cv); throw; } +#endif } else pthread_mutex_unlock(&mut); diff --git a/libcxx/src/new.cpp b/libcxx/src/new.cpp index 964d87b89cc..f751f171fd4 100644 --- a/libcxx/src/new.cpp +++ b/libcxx/src/new.cpp @@ -42,7 +42,11 @@ operator new(std::size_t size) throw (std::bad_alloc) if (__new_handler) __new_handler(); else +#ifndef _LIBCPP_NO_EXCEPTIONS throw std::bad_alloc(); +#else + break; +#endif } return p; } @@ -52,13 +56,17 @@ void* operator new(size_t size, const std::nothrow_t&) throw() { void* p = 0; +#ifndef _LIBCPP_NO_EXCEPTIONS try { +#endif p = ::operator new(size); +#ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { } +#endif return p; } @@ -74,13 +82,17 @@ void* operator new[](size_t size, const std::nothrow_t& nothrow) throw() { void* p = 0; +#ifndef _LIBCPP_NO_EXCEPTIONS try { +#endif p = ::operator new[](size); +#ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { } +#endif return p; } @@ -162,7 +174,9 @@ bad_array_new_length::what() const throw() void __throw_bad_alloc() { +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); +#endif } } // std diff --git a/libcxx/src/string.cpp b/libcxx/src/string.cpp index 819935c07d0..946e915af6e 100644 --- a/libcxx/src/string.cpp +++ b/libcxx/src/string.cpp @@ -79,9 +79,11 @@ stoi(const string& str, size_t* idx, int base) ptr = const_cast<char*>(p); if (ptr == p) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (r == 0) throw invalid_argument("stoi: no conversion"); throw out_of_range("stoi: out of range"); +#endif } if (idx) *idx = static_cast<size_t>(ptr - p); @@ -98,9 +100,11 @@ stoi(const wstring& str, size_t* idx, int base) ptr = const_cast<wchar_t*>(p); if (ptr == p) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (r == 0) throw invalid_argument("stoi: no conversion"); throw out_of_range("stoi: out of range"); +#endif } if (idx) *idx = static_cast<size_t>(ptr - p); @@ -115,9 +119,11 @@ stol(const string& str, size_t* idx, int base) long r = strtol(p, &ptr, base); if (ptr == p) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (r == 0) throw invalid_argument("stol: no conversion"); throw out_of_range("stol: out of range"); +#endif } if (idx) *idx = static_cast<size_t>(ptr - p); @@ -132,9 +138,11 @@ stol(const wstring& str, size_t* idx, int base) long r = wcstol(p, &ptr, base); if (ptr == p) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (r == 0) throw invalid_argument("stol: no conversion"); throw out_of_range("stol: out of range"); +#endif } if (idx) *idx = static_cast<size_t>(ptr - p); @@ -149,9 +157,11 @@ stoul(const string& str, size_t* idx, int base) unsigned long r = strtoul(p, &ptr, base); if (ptr == p) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (r == 0) throw invalid_argument("stoul: no conversion"); throw out_of_range("stoul: out of range"); +#endif } if (idx) *idx = static_cast<size_t>(ptr - p); @@ -166,9 +176,11 @@ stoul(const wstring& str, size_t* idx, int base) unsigned long r = wcstoul(p, &ptr, base); if (ptr == p) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (r == 0) throw invalid_argument("stoul: no conversion"); throw out_of_range("stoul: out of range"); +#endif } if (idx) *idx = static_cast<size_t>(ptr - p); @@ -183,9 +195,11 @@ stoll(const string& str, size_t* idx, int base) long long r = strtoll(p, &ptr, base); if (ptr == p) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (r == 0) throw invalid_argument("stoll: no conversion"); throw out_of_range("stoll: out of range"); +#endif } if (idx) *idx = static_cast<size_t>(ptr - p); @@ -200,9 +214,11 @@ stoll(const wstring& str, size_t* idx, int base) long long r = wcstoll(p, &ptr, base); if (ptr == p) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (r == 0) throw invalid_argument("stoll: no conversion"); throw out_of_range("stoll: out of range"); +#endif } if (idx) *idx = static_cast<size_t>(ptr - p); @@ -217,9 +233,11 @@ stoull(const string& str, size_t* idx, int base) unsigned long long r = strtoull(p, &ptr, base); if (ptr == p) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (r == 0) throw invalid_argument("stoull: no conversion"); throw out_of_range("stoull: out of range"); +#endif } if (idx) *idx = static_cast<size_t>(ptr - p); @@ -234,9 +252,11 @@ stoull(const wstring& str, size_t* idx, int base) unsigned long long r = wcstoull(p, &ptr, base); if (ptr == p) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (r == 0) throw invalid_argument("stoull: no conversion"); throw out_of_range("stoull: out of range"); +#endif } if (idx) *idx = static_cast<size_t>(ptr - p); @@ -252,10 +272,12 @@ stof(const string& str, size_t* idx) errno = 0; double r = strtod(p, &ptr); swap(errno, errno_save); +#ifndef _LIBCPP_NO_EXCEPTIONS if (errno_save == ERANGE) throw out_of_range("stof: out of range"); if (ptr == p) throw invalid_argument("stof: no conversion"); +#endif if (idx) *idx = static_cast<size_t>(ptr - p); return static_cast<float>(r); @@ -270,10 +292,12 @@ stof(const wstring& str, size_t* idx) errno = 0; double r = wcstod(p, &ptr); swap(errno, errno_save); +#ifndef _LIBCPP_NO_EXCEPTIONS if (errno_save == ERANGE) throw out_of_range("stof: out of range"); if (ptr == p) throw invalid_argument("stof: no conversion"); +#endif if (idx) *idx = static_cast<size_t>(ptr - p); return static_cast<float>(r); @@ -288,10 +312,12 @@ stod(const string& str, size_t* idx) errno = 0; double r = strtod(p, &ptr); swap(errno, errno_save); +#ifndef _LIBCPP_NO_EXCEPTIONS if (errno_save == ERANGE) throw out_of_range("stod: out of range"); if (ptr == p) throw invalid_argument("stod: no conversion"); +#endif if (idx) *idx = static_cast<size_t>(ptr - p); return r; @@ -306,10 +332,12 @@ stod(const wstring& str, size_t* idx) errno = 0; double r = wcstod(p, &ptr); swap(errno, errno_save); +#ifndef _LIBCPP_NO_EXCEPTIONS if (errno_save == ERANGE) throw out_of_range("stod: out of range"); if (ptr == p) throw invalid_argument("stod: no conversion"); +#endif if (idx) *idx = static_cast<size_t>(ptr - p); return r; @@ -324,10 +352,12 @@ stold(const string& str, size_t* idx) errno = 0; long double r = strtold(p, &ptr); swap(errno, errno_save); +#ifndef _LIBCPP_NO_EXCEPTIONS if (errno_save == ERANGE) throw out_of_range("stold: out of range"); if (ptr == p) throw invalid_argument("stold: no conversion"); +#endif if (idx) *idx = static_cast<size_t>(ptr - p); return r; @@ -342,10 +372,12 @@ stold(const wstring& str, size_t* idx) errno = 0; long double r = wcstold(p, &ptr); swap(errno, errno_save); +#ifndef _LIBCPP_NO_EXCEPTIONS if (errno_save == ERANGE) throw out_of_range("stold: out of range"); if (ptr == p) throw invalid_argument("stold: no conversion"); +#endif if (idx) *idx = static_cast<size_t>(ptr - p); return r; diff --git a/libcxx/src/system_error.cpp b/libcxx/src/system_error.cpp index 3c1f0003a3c..1ca85cb2f8c 100644 --- a/libcxx/src/system_error.cpp +++ b/libcxx/src/system_error.cpp @@ -193,7 +193,9 @@ system_error::~system_error() throw() void __throw_system_error(int ev, const char* what_arg) { +#ifndef _LIBCPP_NO_EXCEPTIONS throw system_error(error_code(ev, system_category()), what_arg); +#endif } _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/src/thread.cpp b/libcxx/src/thread.cpp index f2db6d51b23..de53f78ef1f 100644 --- a/libcxx/src/thread.cpp +++ b/libcxx/src/thread.cpp @@ -24,8 +24,10 @@ void thread::join() { int ec = pthread_join(__t_, 0); +#ifndef _LIBCPP_NO_EXCEPTIONS if (ec) throw system_error(error_code(ec, system_category()), "thread::join failed"); +#endif __t_ = 0; } @@ -39,8 +41,10 @@ thread::detach() if (ec == 0) __t_ = 0; } +#ifndef _LIBCPP_NO_EXCEPTIONS if (ec) throw system_error(error_code(ec, system_category()), "thread::detach failed"); +#endif } unsigned |