Compare commits

..

13 Commits

Author SHA1 Message Date
Howard Hinnant
474be15134 Correct spelling _LIBCPP_STABLE_APPLE_ABI
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/branches/apple25@136614 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-01 13:39:41 +00:00
Howard Hinnant
fbb2b54c17 branch off of libcpp-25
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/branches/apple25@136613 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-01 13:34:00 +00:00
Howard Hinnant
0e1f6f5856 Tagging 25
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/tags/libcpp-25@135270 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 13:52:54 +00:00
Howard Hinnant
912012e949 http://llvm.org/bugs/show_bug.cgi?id=10353
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@135125 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-14 01:34:46 +00:00
Howard Hinnant
22ba71b8ef http://llvm.org/bugs/show_bug.cgi?id=10346
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@135045 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 16:00:50 +00:00
Howard Hinnant
8d75632ad0 Reverted to 134947. Once I got into it, I discovered there were too many problems to fix in 135035.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@135044 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 15:48:16 +00:00
Sean Hunt
c97da3a590 Implement the __nolocale functions properly so that they will work on
all platforms. Unfortunately a lot of this remains conditionally
compiled so as not to break Apple's ABI.

The new _LIBCPP_LOCALE__L_EXTENSIONS macro can be defined on other
platforms that support _l suffixes for all functions in order to use
them.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@135035 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 06:40:50 +00:00
Sean Hunt
0389c53f44 Make sure that __time_put constructors properly on non-Apple platforms.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@134947 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-12 00:55:04 +00:00
Howard Hinnant
66f2641ac9 Toralf Niebuhr: This is just a tiny patch fixing some small (probably copy & paste) errors.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@134843 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-09 19:47:01 +00:00
Howard Hinnant
2bf1c08510 Make vector<bool>::reference and const_reference public
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@134815 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-09 15:50:42 +00:00
Sean Hunt
6f0342cf2e Don't assume that wctype produces a nice mask on all platforms. On
glibc, for instance, it's a const char *.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@134787 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-09 03:40:04 +00:00
Sean Hunt
e59f724f79 Conditionally wrap the changes from r134781.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@134783 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-09 01:09:31 +00:00
Sean Hunt
62a6ac33a2 Implement generalized table lookups for upper, lower, and character
traits.

To the best of my knowledge, this will not break the ABI for Apple.
However, it does introduce three publicly visible (although with
reserved name) functions that will fail to link against the just-shipped
Apple version of libc++. Since they are not used in any inline
functions, no actual breakage should occur.

If Howard doesn't want to put undefined functions (even internal ones)
into a header, they could be surrounded by additional conditional
compilation.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@134781 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-09 00:56:23 +00:00
8 changed files with 218 additions and 59 deletions

View File

@@ -285,4 +285,12 @@ template <unsigned> struct __static_assert_check {};
#define __has_feature(__x) 0
#endif
#ifdef __APPLE__
#define _LIBCPP_STABLE_APPLE_ABI
#endif
#ifdef __APPLE__
#define _LIBCPP_WCTYPE_IS_MASK
#endif
#endif // _LIBCPP_CONFIG

View File

@@ -302,7 +302,11 @@ locale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x,
class _LIBCPP_VISIBLE ctype_base
{
public:
#ifdef __GLIBC__
typedef unsigned short mask;
#else
typedef __uint32_t mask;
#endif
#if __APPLE__
static const mask space = _CTYPE_S;
@@ -537,6 +541,10 @@ public:
#endif
_LIBCPP_ALWAYS_INLINE const mask* table() const _NOEXCEPT {return __tab_;}
static const mask* classic_table() _NOEXCEPT;
#ifndef _LIBCPP_STABLE_APPLE_ABI
static const int* __classic_upper_table() _NOEXCEPT;
static const int* __classic_lower_table() _NOEXCEPT;
#endif
protected:
~ctype();

View File

@@ -585,8 +585,10 @@ __assoc_state<_R>::set_value(_Arg& __arg)
#endif
{
unique_lock<mutex> __lk(this->__mut_);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (this->__has_value())
throw future_error(make_error_code(future_errc::promise_already_satisfied));
#endif
::new(&__value_) _R(_VSTD::forward<_Arg>(__arg));
this->__state_ |= base::__constructed | base::ready;
__lk.unlock();
@@ -603,8 +605,10 @@ __assoc_state<_R>::set_value_at_thread_exit(_Arg& __arg)
#endif
{
unique_lock<mutex> __lk(this->__mut_);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (this->__has_value())
throw future_error(make_error_code(future_errc::promise_already_satisfied));
#endif
::new(&__value_) _R(_VSTD::forward<_Arg>(__arg));
this->__state_ |= base::__constructed;
__thread_local_data()->__make_ready_at_thread_exit(this);
@@ -663,8 +667,10 @@ void
__assoc_state<_R&>::set_value(_R& __arg)
{
unique_lock<mutex> __lk(this->__mut_);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (this->__has_value())
throw future_error(make_error_code(future_errc::promise_already_satisfied));
#endif
__value_ = &__arg;
this->__state_ |= base::__constructed | base::ready;
__lk.unlock();
@@ -676,8 +682,10 @@ void
__assoc_state<_R&>::set_value_at_thread_exit(_R& __arg)
{
unique_lock<mutex> __lk(this->__mut_);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (this->__has_value())
throw future_error(make_error_code(future_errc::promise_already_satisfied));
#endif
__value_ = &__arg;
this->__state_ |= base::__constructed;
__thread_local_data()->__make_ready_at_thread_exit(this);
@@ -1066,8 +1074,10 @@ template <class _R>
future<_R>::future(__assoc_state<_R>* __state)
: __state_(__state)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__state_->__has_future_attached())
throw future_error(make_error_code(future_errc::future_already_retrieved));
#endif
__state_->__add_shared();
__state_->__set_future_attached();
}
@@ -1168,8 +1178,10 @@ template <class _R>
future<_R&>::future(__assoc_state<_R&>* __state)
: __state_(__state)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__state_->__has_future_attached())
throw future_error(make_error_code(future_errc::future_already_retrieved));
#endif
__state_->__add_shared();
__state_->__set_future_attached();
}
@@ -1368,8 +1380,10 @@ template <class _R>
future<_R>
promise<_R>::get_future()
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__state_ == nullptr)
throw future_error(make_error_code(future_errc::no_state));
#endif
return future<_R>(__state_);
}
@@ -1377,8 +1391,10 @@ template <class _R>
void
promise<_R>::set_value(const _R& __r)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__state_ == nullptr)
throw future_error(make_error_code(future_errc::no_state));
#endif
__state_->set_value(__r);
}
@@ -1388,8 +1404,10 @@ template <class _R>
void
promise<_R>::set_value(_R&& __r)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__state_ == nullptr)
throw future_error(make_error_code(future_errc::no_state));
#endif
__state_->set_value(_VSTD::move(__r));
}
@@ -1399,8 +1417,10 @@ template <class _R>
void
promise<_R>::set_exception(exception_ptr __p)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__state_ == nullptr)
throw future_error(make_error_code(future_errc::no_state));
#endif
__state_->set_exception(__p);
}
@@ -1408,8 +1428,10 @@ template <class _R>
void
promise<_R>::set_value_at_thread_exit(const _R& __r)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__state_ == nullptr)
throw future_error(make_error_code(future_errc::no_state));
#endif
__state_->set_value_at_thread_exit(__r);
}
@@ -1419,8 +1441,10 @@ template <class _R>
void
promise<_R>::set_value_at_thread_exit(_R&& __r)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__state_ == nullptr)
throw future_error(make_error_code(future_errc::no_state));
#endif
__state_->set_value_at_thread_exit(_VSTD::move(__r));
}
@@ -1430,8 +1454,10 @@ template <class _R>
void
promise<_R>::set_exception_at_thread_exit(exception_ptr __p)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__state_ == nullptr)
throw future_error(make_error_code(future_errc::no_state));
#endif
__state_->set_exception_at_thread_exit(__p);
}
@@ -1527,8 +1553,10 @@ template <class _R>
future<_R&>
promise<_R&>::get_future()
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__state_ == nullptr)
throw future_error(make_error_code(future_errc::no_state));
#endif
return future<_R&>(__state_);
}
@@ -1536,8 +1564,10 @@ template <class _R>
void
promise<_R&>::set_value(_R& __r)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__state_ == nullptr)
throw future_error(make_error_code(future_errc::no_state));
#endif
__state_->set_value(__r);
}
@@ -1545,8 +1575,10 @@ template <class _R>
void
promise<_R&>::set_exception(exception_ptr __p)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__state_ == nullptr)
throw future_error(make_error_code(future_errc::no_state));
#endif
__state_->set_exception(__p);
}
@@ -1554,8 +1586,10 @@ template <class _R>
void
promise<_R&>::set_value_at_thread_exit(_R& __r)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__state_ == nullptr)
throw future_error(make_error_code(future_errc::no_state));
#endif
__state_->set_value_at_thread_exit(__r);
}
@@ -1563,8 +1597,10 @@ template <class _R>
void
promise<_R&>::set_exception_at_thread_exit(exception_ptr __p)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__state_ == nullptr)
throw future_error(make_error_code(future_errc::no_state));
#endif
__state_->set_exception_at_thread_exit(__p);
}

View File

@@ -192,6 +192,11 @@ template <class charT> class messages_byname;
_LIBCPP_BEGIN_NAMESPACE_STD
#ifndef _LIBCPP_STABLE_APPLE_ABI
// Get the C locale object
locale_t __cloc();
#endif
// OSX has nice foo_l() functions that let you turn off use of the global
// locale. Linux, not so much. The following functions avoid the locale when
// that's possible and otherwise do the wrong thing. FIXME.
@@ -2511,7 +2516,11 @@ class __time_put
{
locale_t __loc_;
protected:
#ifdef _LIBCPP_STABLE_APPLE_ABI
_LIBCPP_ALWAYS_INLINE __time_put() : __loc_(0) {}
#else // _LIBCPP_STABLE_APPLE_ABI
_LIBCPP_ALWAYS_INLINE __time_put() : __loc_(__cloc()) {}
#endif // _LIBCPP_STABLE_APPLE_ABI
__time_put(const char* __nm);
__time_put(const string& __nm);
~__time_put();

View File

@@ -1801,10 +1801,10 @@ private:
__storage_pointer __begin_;
size_type __size_;
__compressed_pair<size_type, __storage_allocator> __cap_alloc_;
public:
typedef __bit_reference<vector> reference;
typedef __bit_const_reference<vector> const_reference;
private:
_LIBCPP_INLINE_VISIBILITY
size_type& __cap() _NOEXCEPT
{return __cap_alloc_.first();}

View File

@@ -73,8 +73,10 @@ void
__assoc_sub_state::set_value()
{
unique_lock<mutex> __lk(__mut_);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__has_value())
throw future_error(make_error_code(future_errc::promise_already_satisfied));
#endif
__state_ |= __constructed | ready;
__lk.unlock();
__cv_.notify_all();
@@ -84,8 +86,10 @@ void
__assoc_sub_state::set_value_at_thread_exit()
{
unique_lock<mutex> __lk(__mut_);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__has_value())
throw future_error(make_error_code(future_errc::promise_already_satisfied));
#endif
__state_ |= __constructed;
__thread_local_data()->__make_ready_at_thread_exit(this);
__lk.unlock();
@@ -95,8 +99,10 @@ void
__assoc_sub_state::set_exception(exception_ptr __p)
{
unique_lock<mutex> __lk(__mut_);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__has_value())
throw future_error(make_error_code(future_errc::promise_already_satisfied));
#endif
__exception_ = __p;
__state_ |= ready;
__lk.unlock();
@@ -107,8 +113,10 @@ void
__assoc_sub_state::set_exception_at_thread_exit(exception_ptr __p)
{
unique_lock<mutex> __lk(__mut_);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__has_value())
throw future_error(make_error_code(future_errc::promise_already_satisfied));
#endif
__exception_ = __p;
__thread_local_data()->__make_ready_at_thread_exit(this);
__lk.unlock();
@@ -159,14 +167,18 @@ __assoc_sub_state::__sub_wait(unique_lock<mutex>& __lk)
void
__assoc_sub_state::__execute()
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw future_error(make_error_code(future_errc::no_state));
#endif
}
future<void>::future(__assoc_sub_state* __state)
: __state_(__state)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__state_->__has_future_attached())
throw future_error(make_error_code(future_errc::future_already_retrieved));
#endif
__state_->__add_shared();
__state_->__set_future_attached();
}
@@ -206,40 +218,50 @@ promise<void>::~promise()
future<void>
promise<void>::get_future()
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__state_ == nullptr)
throw future_error(make_error_code(future_errc::no_state));
#endif
return future<void>(__state_);
}
void
promise<void>::set_value()
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__state_ == nullptr)
throw future_error(make_error_code(future_errc::no_state));
#endif
__state_->set_value();
}
void
promise<void>::set_exception(exception_ptr __p)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__state_ == nullptr)
throw future_error(make_error_code(future_errc::no_state));
#endif
__state_->set_exception(__p);
}
void
promise<void>::set_value_at_thread_exit()
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__state_ == nullptr)
throw future_error(make_error_code(future_errc::no_state));
#endif
__state_->set_value_at_thread_exit();
}
void
promise<void>::set_exception_at_thread_exit(exception_ptr __p)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__state_ == nullptr)
throw future_error(make_error_code(future_errc::no_state));
#endif
__state_->set_exception_at_thread_exit(__p);
}

View File

@@ -116,6 +116,20 @@ namespace with_locale { namespace {
_LIBCPP_BEGIN_NAMESPACE_STD
#ifndef _LIBCPP_STABLE_APPLE_ABI
locale_t __cloc() {
// In theory this could create a race condition. In practice
// the race condition is non-fatal since it will just create
// a little resource leak. Better approach would be appreciated.
#ifdef __APPLE__
return 0;
#else
static locale_t result = newlocale(LC_ALL_MASK, "C", 0);
return result;
#endif
}
#endif // _LIBCPP_STABLE_APPLE_ABI
namespace {
struct release
@@ -767,93 +781,80 @@ ctype<wchar_t>::~ctype()
bool
ctype<wchar_t>::do_is(mask m, char_type c) const
{
#ifdef __APPLE__
return isascii(c) ? _DefaultRuneLocale.__runetype[c] & m : false;
#else
return false;
#endif
return isascii(c) ? ctype<char>::classic_table()[c] & m : false;
}
const wchar_t*
ctype<wchar_t>::do_is(const char_type* low, const char_type* high, mask* vec) const
{
#ifdef __APPLE__
for (; low != high; ++low, ++vec)
*vec = static_cast<mask>(isascii(*low) ? _DefaultRuneLocale.__runetype[*low] : 0);
*vec = static_cast<mask>(isascii(*low) ?
ctype<char>::classic_table()[*low] : 0);
return low;
#else
return NULL;
#endif
}
const wchar_t*
ctype<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const
{
#ifdef __APPLE__
for (; low != high; ++low)
if (isascii(*low) && (_DefaultRuneLocale.__runetype[*low] & m))
if (isascii(*low) && (ctype<char>::classic_table()[*low] & m))
break;
return low;
#else
return NULL;
#endif
}
const wchar_t*
ctype<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const
{
#ifdef __APPLE__
for (; low != high; ++low)
if (!(isascii(*low) && (_DefaultRuneLocale.__runetype[*low] & m)))
if (!(isascii(*low) && (ctype<char>::classic_table()[*low] & m)))
break;
return low;
#else
return NULL;
#endif
}
wchar_t
ctype<wchar_t>::do_toupper(char_type c) const
{
#ifdef __APPLE__
return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c;
#ifndef _LIBCPP_STABLE_APPLE_ABI
return isascii(c) ? ctype<char>::__classic_upper_table()[c] : c;
#else
return 0;
return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c;
#endif
}
const wchar_t*
ctype<wchar_t>::do_toupper(char_type* low, const char_type* high) const
{
#ifdef __APPLE__
for (; low != high; ++low)
*low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low;
return low;
#ifndef _LIBCPP_STABLE_APPLE_ABI
*low = isascii(*low) ? ctype<char>::__classic_upper_table()[*low]
: *low;
#else
return NULL;
*low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low;
#endif
return low;
}
wchar_t
ctype<wchar_t>::do_tolower(char_type c) const
{
#ifdef __APPLE__
return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c;
#ifndef _LIBCPP_STABLE_APPLE_ABI
return isascii(c) ? ctype<char>::__classic_lower_table()[c] : c;
#else
return 0;
return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c;
#endif
}
const wchar_t*
ctype<wchar_t>::do_tolower(char_type* low, const char_type* high) const
{
#ifdef __APPLE__
for (; low != high; ++low)
*low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low;
return low;
#ifndef _LIBCPP_STABLE_APPLE_ABI
*low = isascii(*low) ? ctype<char>::__classic_lower_table()[*low]
: *low;
#else
return NULL;
*low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low;
#endif
return low;
}
wchar_t
@@ -898,10 +899,8 @@ ctype<char>::ctype(const mask* tab, bool del, size_t refs)
__tab_(tab),
__del_(del)
{
#ifdef __APPLE__
if (__tab_ == 0)
__tab_ = _DefaultRuneLocale.__runetype;
#endif
if (__tab_ == 0)
__tab_ = classic_table();
}
ctype<char>::~ctype()
@@ -913,45 +912,45 @@ ctype<char>::~ctype()
char
ctype<char>::do_toupper(char_type c) const
{
#ifdef __APPLE__
return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c;
#ifndef _LIBCPP_STABLE_APPLE_ABI
return isascii(c) ? __classic_upper_table()[c] : c;
#else
return 0;
return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c;
#endif
}
const char*
ctype<char>::do_toupper(char_type* low, const char_type* high) const
{
#ifdef __APPLE__
for (; low != high; ++low)
*low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low;
return low;
#ifndef _LIBCPP_STABLE_APPLE_ABI
*low = isascii(*low) ? __classic_upper_table()[*low] : *low;
#else
return NULL;
*low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low;
#endif
return low;
}
char
ctype<char>::do_tolower(char_type c) const
{
#ifdef __APPLE__
return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c;
#ifndef _LIBCPP_STABLE_APPLE_ABI
return isascii(c) ? __classic_lower_table()[c] : c;
#else
return 0;
return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c;
#endif
}
const char*
ctype<char>::do_tolower(char_type* low, const char_type* high) const
{
#ifdef __APPLE__
for (; low != high; ++low)
*low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low;
return low;
#ifndef _LIBCPP_STABLE_APPLE_ABI
*low = isascii(*low) ? __classic_lower_table()[*low] : *low;
#else
return NULL;
*low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low;
#endif
return low;
}
char
@@ -992,11 +991,40 @@ ctype<char>::classic_table() _NOEXCEPT
{
#ifdef __APPLE__
return _DefaultRuneLocale.__runetype;
#elif defined(__GLIBC__)
return __cloc()->__ctype_b;
// This is assumed to be safe.
#else
return NULL;
#endif
}
#ifndef _LIBCPP_STABLE_APPLE_ABI
const int*
ctype<char>::__classic_lower_table() _NOEXCEPT
{
#ifdef __APPLE__
return _DefaultRuneLocale.__maplower;
#elif defined(__GLIBC__)
return __cloc()->__ctype_tolower;
#else
return NULL;
#endif
}
const int*
ctype<char>::__classic_upper_table() _NOEXCEPT
{
#ifdef __APPLE__
return _DefaultRuneLocale.__mapupper;
#elif defined(__GLIBC__)
return __cloc()->__ctype_toupper;
#else
return NULL;
#endif
}
#endif // _LIBCPP_STABLE_APPLE_ABI
// template <> class ctype_byname<char>
ctype_byname<char>::ctype_byname(const char* name, size_t refs)
@@ -1086,17 +1114,30 @@ ctype_byname<wchar_t>::~ctype_byname()
bool
ctype_byname<wchar_t>::do_is(mask m, char_type c) const
{
#ifdef _LIBCPP_WCTYPE_IS_MASK
return static_cast<bool>(iswctype_l(c, m, __l));
#else
if (m & space && !iswspace_l(c, __l)) return false;
if (m & print && !iswprint_l(c, __l)) return false;
if (m & cntrl && !iswcntrl_l(c, __l)) return false;
if (m & upper && !iswupper_l(c, __l)) return false;
if (m & lower && !iswlower_l(c, __l)) return false;
if (m & alpha && !iswalpha_l(c, __l)) return false;
if (m & digit && !iswdigit_l(c, __l)) return false;
if (m & punct && !iswpunct_l(c, __l)) return false;
if (m & xdigit && !iswxdigit_l(c, __l)) return false;
if (m & blank && !iswblank_l(c, __l)) return false;
return true;
#endif
}
const wchar_t*
ctype_byname<wchar_t>::do_is(const char_type* low, const char_type* high, mask* vec) const
{
#ifdef __APPLE__
for (; low != high; ++low, ++vec)
{
if (isascii(*low))
*vec = static_cast<mask>(_DefaultRuneLocale.__runetype[*low]);
*vec = static_cast<mask>(ctype<char>::classic_table()[*low]);
else
{
*vec = 0;
@@ -1121,17 +1162,30 @@ ctype_byname<wchar_t>::do_is(const char_type* low, const char_type* high, mask*
}
}
return low;
#else
return NULL;
#endif
}
const wchar_t*
ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const
{
for (; low != high; ++low)
{
#ifdef _LIBCPP_WCTYPE_IS_MASK
if (iswctype_l(*low, m, __l))
break;
#else
if (m & space && !iswspace_l(*low, __l)) continue;
if (m & print && !iswprint_l(*low, __l)) continue;
if (m & cntrl && !iswcntrl_l(*low, __l)) continue;
if (m & upper && !iswupper_l(*low, __l)) continue;
if (m & lower && !iswlower_l(*low, __l)) continue;
if (m & alpha && !iswalpha_l(*low, __l)) continue;
if (m & digit && !iswdigit_l(*low, __l)) continue;
if (m & punct && !iswpunct_l(*low, __l)) continue;
if (m & xdigit && !iswxdigit_l(*low, __l)) continue;
if (m & blank && !iswblank_l(*low, __l)) continue;
break;
#endif
}
return low;
}
@@ -1139,8 +1193,24 @@ const wchar_t*
ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const
{
for (; low != high; ++low)
{
#ifdef _LIBCPP_WCTYPE_IS_MASK
if (!iswctype_l(*low, m, __l))
break;
#else
if (m & space && iswspace_l(*low, __l)) continue;
if (m & print && iswprint_l(*low, __l)) continue;
if (m & cntrl && iswcntrl_l(*low, __l)) continue;
if (m & upper && iswupper_l(*low, __l)) continue;
if (m & lower && iswlower_l(*low, __l)) continue;
if (m & alpha && iswalpha_l(*low, __l)) continue;
if (m & digit && iswdigit_l(*low, __l)) continue;
if (m & punct && iswpunct_l(*low, __l)) continue;
if (m & xdigit && iswxdigit_l(*low, __l)) continue;
if (m & blank && iswblank_l(*low, __l)) continue;
break;
#endif
}
return low;
}

View File

@@ -28,6 +28,9 @@
__attribute__((__weak__, __visibility__("default")))
void *
operator new(std::size_t size)
#if !__has_feature(cxx_noexcept)
throw(std::bad_alloc)
#endif
{
if (size == 0)
size = 1;
@@ -71,6 +74,9 @@ operator new(size_t size, const std::nothrow_t&) _NOEXCEPT
__attribute__((__weak__, __visibility__("default")))
void*
operator new[](size_t size)
#if !__has_feature(cxx_noexcept)
throw(std::bad_alloc)
#endif
{
return ::operator new(size);
}