Home | History | Annotate | Download | only in patches.android
      1 From de2427cee8c21f972a9b4df6a31a7933360b4d01 Mon Sep 17 00:00:00 2001
      2 From: Andrew Hsieh <andrewhsieh (a] google.com>
      3 Date: Tue, 3 Jun 2014 17:40:43 +0800
      4 Subject: [PATCH 13/13] [temp] collective ndk-hackathon fixes
      5 
      6 See https://github.com/awong-dev/ndk since 0a149253507bd702d042de32c2b6bb9aa58168a3
      7 for log.  Some are in the process of upstream
      8 
      9 ---
     10  include/__config                                   | 15 ++++++++
     11  include/__mutex_base                               |  9 +++++
     12  include/bitset                                     |  4 +--
     13  include/condition_variable                         |  4 +++
     14  include/future                                     |  4 +++
     15  include/mutex                                      |  4 +++
     16  include/regex                                      |  6 +++-
     17  include/shared_mutex                               |  4 +++
     18  include/thread                                     |  4 +++
     19  src/algorithm.cpp                                  |  8 +++++
     20  src/chrono.cpp                                     |  7 ++++
     21  src/condition_variable.cpp                         |  5 +++
     22  src/debug.cpp                                      | 40 +++++++++++++++++++++
     23  src/future.cpp                                     |  6 ++++
     24  src/memory.cpp                                     |  4 +--
     25  src/mutex.cpp                                      | 19 ++++++++++
     26  src/shared_mutex.cpp                               |  6 ++++
     27  src/thread.cpp                                     |  9 +++++
     28  test/re/re.alg/re.alg.match/basic.pass.cpp         | 14 ++++++++
     29  test/re/re.alg/re.alg.match/ecma.pass.cpp          | 14 ++++++++
     30  test/re/re.alg/re.alg.match/extended.pass.cpp      | 14 ++++++++
     31  test/re/re.alg/re.alg.search/awk.pass.cpp          | 14 ++++++++
     32  test/re/re.alg/re.alg.search/basic.pass.cpp        | 14 ++++++++
     33  test/re/re.alg/re.alg.search/ecma.pass.cpp         | 14 ++++++++
     34  test/re/re.alg/re.alg.search/extended.pass.cpp     | 14 ++++++++
     35  test/re/re.traits/lookup_collatename.pass.cpp      |  6 ----
     36  .../re.traits/lookup_collatename.xlocale.pass.cpp  | 41 ++++++++++++++++++++++
     37  test/re/re.traits/transform.pass.cpp               | 14 ++++++++
     38  test/re/re.traits/transform_primary.pass.cpp       | 14 ++++++++
     39  test/re/re.traits/translate_nocase.pass.cpp        | 14 ++++++++
     40  .../meta.trans.other/aligned_storage.pass.cpp      | 10 ++++--
     41  31 files changed, 341 insertions(+), 14 deletions(-)
     42  create mode 100644 test/re/re.traits/lookup_collatename.xlocale.pass.cpp
     43 
     44 diff --git a/include/__config b/include/__config
     45 index 0f443a9..d2ab7ac 100644
     46 --- a/include/__config
     47 +++ b/include/__config
     48 @@ -11,6 +11,8 @@
     49  #ifndef _LIBCPP_CONFIG
     50  #define _LIBCPP_CONFIG
     51  
     52 +#include <unistd.h>
     53 +
     54  #if !defined(_MSC_VER) || defined(__clang__)
     55  #pragma GCC system_header
     56  #endif
     57 @@ -119,6 +121,12 @@
     58  # endif
     59  #endif  // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
     60  
     61 +#if defined(_POSIX_THREADS) && _POSIX_THREADS > 0
     62 +#  define _LIBCPP_SINGLE_THREADED 0
     63 +#else
     64 +#  define _LIBCPP_SINGLE_THREADED 1
     65 +#endif
     66 +
     67  #ifdef _WIN32
     68  
     69  // only really useful for a DLL
     70 @@ -378,7 +386,14 @@ namespace std {
     71  #endif
     72  
     73  #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
     74 +
     75 +// constexpr was added to GCC in 4.6
     76 +#if _GNUC_VER < 406
     77  #define _LIBCPP_HAS_NO_CONSTEXPR
     78 +// Can only use constexpr in c++11 mode.
     79 +#elif !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
     80 +#define _LIBCPP_HAS_NO_CONSTEXPR
     81 +#endif
     82  
     83  #define _NOEXCEPT throw()
     84  #define _NOEXCEPT_(x)
     85 diff --git a/include/__mutex_base b/include/__mutex_base
     86 index 293fead..122b0b7 100644
     87 --- a/include/__mutex_base
     88 +++ b/include/__mutex_base
     89 @@ -22,12 +22,15 @@
     90  
     91  _LIBCPP_BEGIN_NAMESPACE_STD
     92  
     93 +#if !_LIBCPP_SINGLE_THREADED
     94 +
     95  class _LIBCPP_TYPE_VIS mutex
     96  {
     97      pthread_mutex_t __m_;
     98  
     99  public:
    100      _LIBCPP_INLINE_VISIBILITY
    101 +
    102  #ifndef _LIBCPP_HAS_NO_CONSTEXPR
    103       constexpr mutex() _NOEXCEPT : __m_(PTHREAD_MUTEX_INITIALIZER) {}
    104  #else
    105 @@ -47,6 +50,7 @@ public:
    106      typedef pthread_mutex_t* native_handle_type;
    107      _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__m_;}
    108  };
    109 +#endif // !_LIBCPP_SINGLE_THREADED
    110  
    111  struct _LIBCPP_TYPE_VIS defer_lock_t {};
    112  struct _LIBCPP_TYPE_VIS try_to_lock_t {};
    113 @@ -262,6 +266,7 @@ _LIBCPP_DECLARE_STRONG_ENUM(cv_status)
    114  };
    115  _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_status)
    116  
    117 +#if !_LIBCPP_SINGLE_THREADED
    118  class _LIBCPP_TYPE_VIS condition_variable
    119  {
    120      pthread_cond_t __cv_;
    121 @@ -315,6 +320,7 @@ private:
    122      void __do_timed_wait(unique_lock<mutex>& __lk,
    123         chrono::time_point<chrono::system_clock, chrono::nanoseconds>) _NOEXCEPT;
    124  };
    125 +#endif // !_LIBCPP_SINGLE_THREADED
    126  
    127  template <class _To, class _Rep, class _Period>
    128  inline _LIBCPP_INLINE_VISIBILITY
    129 @@ -332,6 +338,7 @@ __ceil(chrono::duration<_Rep, _Period> __d)
    130      return __r;
    131  }
    132  
    133 +#if !_LIBCPP_SINGLE_THREADED
    134  template <class _Predicate>
    135  void
    136  condition_variable::wait(unique_lock<mutex>& __lk, _Predicate __pred)
    137 @@ -396,6 +403,8 @@ condition_variable::wait_for(unique_lock<mutex>& __lk,
    138                        _VSTD::move(__pred));
    139  }
    140  
    141 +#endif // !_LIBCPP_SINGLE_THREADED
    142 +
    143  _LIBCPP_END_NAMESPACE_STD
    144  
    145  #endif  // _LIBCPP___MUTEX_BASE
    146 diff --git a/include/bitset b/include/bitset
    147 index 4cc7dbd..8c278cc 100644
    148 --- a/include/bitset
    149 +++ b/include/bitset
    150 @@ -249,9 +249,9 @@ inline _LIBCPP_INLINE_VISIBILITY
    151  _LIBCPP_CONSTEXPR
    152  __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
    153  #ifndef _LIBCPP_HAS_NO_CONSTEXPR
    154 -#if __SIZE_WIDTH__ == 64
    155 +#if __SIZEOF_SIZE_T__ == 8
    156      : __first_{__v}
    157 -#elif __SIZE_WIDTH__ == 32
    158 +#elif __SIZEOF_SIZE_T__ == 4
    159      : __first_{__v, __v >> __bits_per_word}
    160  #else
    161  #error This constructor has not been ported to this platform
    162 diff --git a/include/condition_variable b/include/condition_variable
    163 index dc67266..603ee8f 100644
    164 --- a/include/condition_variable
    165 +++ b/include/condition_variable
    166 @@ -115,6 +115,8 @@ public:
    167  #pragma GCC system_header
    168  #endif
    169  
    170 +#if !_LIBCPP_SINGLE_THREADED
    171 +
    172  _LIBCPP_BEGIN_NAMESPACE_STD
    173  
    174  class _LIBCPP_TYPE_VIS condition_variable_any
    175 @@ -253,4 +255,6 @@ void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk);
    176  
    177  _LIBCPP_END_NAMESPACE_STD
    178  
    179 +#endif // !_LIBCPP_SINGLE_THREADED
    180 +
    181  #endif  // _LIBCPP_CONDITION_VARIABLE
    182 diff --git a/include/future b/include/future
    183 index de00f25..c776c59 100644
    184 --- a/include/future
    185 +++ b/include/future
    186 @@ -374,6 +374,8 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
    187  #pragma GCC system_header
    188  #endif
    189  
    190 +#if !_LIBCPP_SINGLE_THREADED
    191 +
    192  _LIBCPP_BEGIN_NAMESPACE_STD
    193  
    194  //enum class future_errc
    195 @@ -2612,4 +2614,6 @@ future<void>::share()
    196  
    197  _LIBCPP_END_NAMESPACE_STD
    198  
    199 +#endif // !_LIBCPP_SINGLE_THREADED
    200 +
    201  #endif  // _LIBCPP_FUTURE
    202 diff --git a/include/mutex b/include/mutex
    203 index e0c02ad..b7a6709 100644
    204 --- a/include/mutex
    205 +++ b/include/mutex
    206 @@ -187,6 +187,8 @@ template<class Callable, class ...Args>
    207  
    208  _LIBCPP_BEGIN_NAMESPACE_STD
    209  
    210 +#if !_LIBCPP_SINGLE_THREADED
    211 +
    212  class _LIBCPP_TYPE_VIS recursive_mutex
    213  {
    214      pthread_mutex_t __m_;
    215 @@ -425,6 +427,8 @@ lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
    216  
    217  #endif  // _LIBCPP_HAS_NO_VARIADICS
    218  
    219 +#endif // !_LIBCPP_SINGLE_THREADED
    220 +
    221  struct _LIBCPP_TYPE_VIS once_flag;
    222  
    223  #ifndef _LIBCPP_HAS_NO_VARIADICS
    224 diff --git a/include/regex b/include/regex
    225 index bebbaf0..7d922cb 100644
    226 --- a/include/regex
    227 +++ b/include/regex
    228 @@ -964,7 +964,11 @@ public:
    229      typedef locale                  locale_type;
    230      typedef ctype_base::mask        char_class_type;
    231  
    232 -    static const char_class_type __regex_word = 0x80;
    233 +    // Note that Android's whitespace bit, aka. _B (see locale_android.cpp for
    234 +    // the details) was unfortunately defined as 0x80 which made the whitespace
    235 +    // character be recognized as a word.
    236 +    static const char_class_type __regex_word = 0x200;
    237 +
    238  private:
    239      locale __loc_;
    240      const ctype<char_type>* __ct_;
    241 diff --git a/include/shared_mutex b/include/shared_mutex
    242 index 7661054..fe16ee7 100644
    243 --- a/include/shared_mutex
    244 +++ b/include/shared_mutex
    245 @@ -112,6 +112,8 @@ template <class Mutex>
    246  #pragma GCC system_header
    247  #endif
    248  
    249 +#if !_LIBCPP_SINGLE_THREADED
    250 +
    251  _LIBCPP_BEGIN_NAMESPACE_STD
    252  
    253  class _LIBCPP_TYPE_VIS shared_timed_mutex
    254 @@ -414,6 +416,8 @@ swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) noexcept
    255  
    256  _LIBCPP_END_NAMESPACE_STD
    257  
    258 +#endif  // _LIBC_HAS_PTHREADS
    259 +
    260  #endif  // _LIBCPP_STD_VER > 11
    261  
    262  #endif  // _LIBCPP_SHARED_MUTEX
    263 diff --git a/include/thread b/include/thread
    264 index 1f1e4a2..0202440 100644
    265 --- a/include/thread
    266 +++ b/include/thread
    267 @@ -106,6 +106,8 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
    268  
    269  #define __STDCPP_THREADS__ __cplusplus
    270  
    271 +#if !_LIBCPP_SINGLE_THREADED
    272 +
    273  _LIBCPP_BEGIN_NAMESPACE_STD
    274  
    275  template <class _Tp>
    276 @@ -455,4 +457,6 @@ void yield() _NOEXCEPT {sched_yield();}
    277  
    278  _LIBCPP_END_NAMESPACE_STD
    279  
    280 +#endif // !_LIBCPP_SINGLE_THREADED
    281 +
    282  #endif  // _LIBCPP_THREAD
    283 diff --git a/src/algorithm.cpp b/src/algorithm.cpp
    284 index 10c4c33..2ee8b00 100644
    285 --- a/src/algorithm.cpp
    286 +++ b/src/algorithm.cpp
    287 @@ -48,12 +48,16 @@ template bool __insertion_sort_incomplete<__less<long double>&, long double*>(lo
    288  
    289  template unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&);
    290  
    291 +#if !_LIBCPP_SINGLE_THREADED
    292  static pthread_mutex_t __rs_mut = PTHREAD_MUTEX_INITIALIZER;
    293 +#endif
    294  unsigned __rs_default::__c_ = 0;
    295  
    296  __rs_default::__rs_default()
    297  {
    298 +#if !_LIBCPP_SINGLE_THREADED
    299      pthread_mutex_lock(&__rs_mut);
    300 +#endif
    301      __c_ = 1;
    302  }
    303  
    304 @@ -64,8 +68,12 @@ __rs_default::__rs_default(const __rs_default&)
    305  
    306  __rs_default::~__rs_default()
    307  {
    308 +#if !_LIBCPP_SINGLE_THREADED
    309      if (--__c_ == 0)
    310          pthread_mutex_unlock(&__rs_mut);
    311 +#else
    312 +    --__c_;
    313 +#endif
    314  }
    315  
    316  __rs_default::result_type
    317 diff --git a/src/chrono.cpp b/src/chrono.cpp
    318 index 15a6f46..331de3d 100644
    319 --- a/src/chrono.cpp
    320 +++ b/src/chrono.cpp
    321 @@ -120,10 +120,17 @@ steady_clock::now() _NOEXCEPT
    322  steady_clock::time_point
    323  steady_clock::now() _NOEXCEPT
    324  {
    325 +#if defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK > 0
    326      struct timespec tp;
    327      if (0 != clock_gettime(CLOCK_MONOTONIC, &tp))
    328          __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed");
    329      return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
    330 +#else
    331 +#warning posix doesn't have a monotonic clock on this system \
    332 +         so we're falling back to std::steady_clock (which may \
    333 +         not be monotonic, and therefore may not be conforming)
    334 +    return time_point(system_clock::now().time_since_epoch());
    335 +#endif
    336  }
    337  #endif  // __APPLE__
    338  
    339 diff --git a/src/condition_variable.cpp b/src/condition_variable.cpp
    340 index 061d138..f21142d 100644
    341 --- a/src/condition_variable.cpp
    342 +++ b/src/condition_variable.cpp
    343 @@ -12,6 +12,8 @@
    344  #include "system_error"
    345  #include "cassert"
    346  
    347 +#if !_LIBCPP_SINGLE_THREADED
    348 +
    349  _LIBCPP_BEGIN_NAMESPACE_STD
    350  
    351  condition_variable::~condition_variable()
    352 @@ -79,3 +81,6 @@ notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk)
    353  }
    354  
    355  _LIBCPP_END_NAMESPACE_STD
    356 +
    357 +#endif // !_LIBCPP_SINGLE_THREADED
    358 +
    359 diff --git a/src/debug.cpp b/src/debug.cpp
    360 index d0e8679..05ec703 100644
    361 --- a/src/debug.cpp
    362 +++ b/src/debug.cpp
    363 @@ -35,6 +35,7 @@ __get_const_db()
    364  namespace
    365  {
    366  
    367 +#if !_LIBCPP_SINGLE_THREADED
    368  typedef mutex mutex_type;
    369  typedef lock_guard<mutex_type> WLock;
    370  typedef lock_guard<mutex_type> RLock;
    371 @@ -45,6 +46,7 @@ mut()
    372      static mutex_type m;
    373      return m;
    374  }
    375 +#endif // !_LIBCPP_SINGLE_THREADED
    376  
    377  }  // unnamed namespace
    378  
    379 @@ -108,7 +110,9 @@ __libcpp_db::~__libcpp_db()
    380  void*
    381  __libcpp_db::__find_c_from_i(void* __i) const
    382  {
    383 +#if !_LIBCPP_SINGLE_THREADED
    384      RLock _(mut());
    385 +#endif
    386      __i_node* i = __find_iterator(__i);
    387      _LIBCPP_ASSERT(i != nullptr, "iterator not found in debug database.");
    388      return i->__c_ != nullptr ? i->__c_->__c_ : nullptr;
    389 @@ -117,7 +121,9 @@ __libcpp_db::__find_c_from_i(void* __i) const
    390  void
    391  __libcpp_db::__insert_ic(void* __i, const void* __c)
    392  {
    393 +#if !_LIBCPP_SINGLE_THREADED
    394      WLock _(mut());
    395 +#endif
    396      if (__cbeg_ == __cend_)
    397          return;
    398      size_t hc = hash<const void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
    399 @@ -138,7 +144,9 @@ __libcpp_db::__insert_ic(void* __i, const void* __c)
    400  __c_node*
    401  __libcpp_db::__insert_c(void* __c)
    402  {
    403 +#if !_LIBCPP_SINGLE_THREADED
    404      WLock _(mut());
    405 +#endif
    406      if (__csz_ + 1 > static_cast<size_t>(__cend_ - __cbeg_))
    407      {
    408          size_t nc = __next_prime(2*static_cast<size_t>(__cend_ - __cbeg_) + 1);
    409 @@ -184,7 +192,9 @@ __libcpp_db::__insert_c(void* __c)
    410  void
    411  __libcpp_db::__erase_i(void* __i)
    412  {
    413 +#if !_LIBCPP_SINGLE_THREADED
    414      WLock _(mut());
    415 +#endif
    416      if (__ibeg_ != __iend_)
    417      {
    418          size_t hi = hash<void*>()(__i) % static_cast<size_t>(__iend_ - __ibeg_);
    419 @@ -215,7 +225,9 @@ __libcpp_db::__erase_i(void* __i)
    420  void
    421  __libcpp_db::__invalidate_all(void* __c)
    422  {
    423 +#if !_LIBCPP_SINGLE_THREADED
    424      WLock _(mut());
    425 +#endif
    426      if (__cend_ != __cbeg_)
    427      {
    428          size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
    429 @@ -239,17 +251,23 @@ __libcpp_db::__invalidate_all(void* __c)
    430  __c_node*
    431  __libcpp_db::__find_c_and_lock(void* __c) const
    432  {
    433 +#if !_LIBCPP_SINGLE_THREADED
    434      mut().lock();
    435 +#endif
    436      if (__cend_ == __cbeg_)
    437      {
    438 +#if !_LIBCPP_SINGLE_THREADED
    439          mut().unlock();
    440 +#endif
    441          return nullptr;
    442      }
    443      size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
    444      __c_node* p = __cbeg_[hc];
    445      if (p == nullptr)
    446      {
    447 +#if !_LIBCPP_SINGLE_THREADED
    448          mut().unlock();
    449 +#endif
    450          return nullptr;
    451      }
    452      while (p->__c_ != __c)
    453 @@ -257,7 +275,9 @@ __libcpp_db::__find_c_and_lock(void* __c) const
    454          p = p->__next_;
    455          if (p == nullptr)
    456          {
    457 +#if !_LIBCPP_SINGLE_THREADED
    458              mut().unlock();
    459 +#endif
    460              return nullptr;
    461          }
    462      }
    463 @@ -281,13 +301,17 @@ __libcpp_db::__find_c(void* __c) const
    464  void
    465  __libcpp_db::unlock() const
    466  {
    467 +#if !_LIBCPP_SINGLE_THREADED
    468      mut().unlock();
    469 +#endif
    470  }
    471  
    472  void
    473  __libcpp_db::__erase_c(void* __c)
    474  {
    475 +#if !_LIBCPP_SINGLE_THREADED
    476      WLock _(mut());
    477 +#endif
    478      if (__cend_ != __cbeg_)
    479      {
    480          size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
    481 @@ -322,7 +346,9 @@ __libcpp_db::__erase_c(void* __c)
    482  void
    483  __libcpp_db::__iterator_copy(void* __i, const void* __i0)
    484  {
    485 +#if !_LIBCPP_SINGLE_THREADED
    486      WLock _(mut());
    487 +#endif
    488      __i_node* i = __find_iterator(__i);
    489      __i_node* i0 = __find_iterator(__i0);
    490      __c_node* c0 = i0 != nullptr ? i0->__c_ : nullptr;
    491 @@ -348,7 +374,9 @@ __libcpp_db::__iterator_copy(void* __i, const void* __i0)
    492  bool
    493  __libcpp_db::__dereferenceable(const void* __i) const
    494  {
    495 +#if !_LIBCPP_SINGLE_THREADED
    496      RLock _(mut());
    497 +#endif
    498      __i_node* i = __find_iterator(__i);
    499      return i != nullptr && i->__c_ != nullptr && i->__c_->__dereferenceable(__i);
    500  }
    501 @@ -356,7 +384,9 @@ __libcpp_db::__dereferenceable(const void* __i) const
    502  bool
    503  __libcpp_db::__decrementable(const void* __i) const
    504  {
    505 +#if !_LIBCPP_SINGLE_THREADED
    506      RLock _(mut());
    507 +#endif
    508      __i_node* i = __find_iterator(__i);
    509      return i != nullptr && i->__c_ != nullptr && i->__c_->__decrementable(__i);
    510  }
    511 @@ -364,7 +394,9 @@ __libcpp_db::__decrementable(const void* __i) const
    512  bool
    513  __libcpp_db::__addable(const void* __i, ptrdiff_t __n) const
    514  {
    515 +#if !_LIBCPP_SINGLE_THREADED
    516      RLock _(mut());
    517 +#endif
    518      __i_node* i = __find_iterator(__i);
    519      return i != nullptr && i->__c_ != nullptr && i->__c_->__addable(__i, __n);
    520  }
    521 @@ -372,7 +404,9 @@ __libcpp_db::__addable(const void* __i, ptrdiff_t __n) const
    522  bool
    523  __libcpp_db::__subscriptable(const void* __i, ptrdiff_t __n) const
    524  {
    525 +#if !_LIBCPP_SINGLE_THREADED
    526      RLock _(mut());
    527 +#endif
    528      __i_node* i = __find_iterator(__i);
    529      return i != nullptr && i->__c_ != nullptr && i->__c_->__subscriptable(__i, __n);
    530  }
    531 @@ -380,7 +414,9 @@ __libcpp_db::__subscriptable(const void* __i, ptrdiff_t __n) const
    532  bool
    533  __libcpp_db::__less_than_comparable(const void* __i, const void* __j) const
    534  {
    535 +#if !_LIBCPP_SINGLE_THREADED
    536      RLock _(mut());
    537 +#endif
    538      __i_node* i = __find_iterator(__i);
    539      __i_node* j = __find_iterator(__j);
    540      __c_node* ci = i != nullptr ? i->__c_ : nullptr;
    541 @@ -391,7 +427,9 @@ __libcpp_db::__less_than_comparable(const void* __i, const void* __j) const
    542  void
    543  __libcpp_db::swap(void* c1, void* c2)
    544  {
    545 +#if !_LIBCPP_SINGLE_THREADED
    546      WLock _(mut());
    547 +#endif
    548      size_t hc = hash<void*>()(c1) % static_cast<size_t>(__cend_ - __cbeg_);
    549      __c_node* p1 = __cbeg_[hc];
    550      _LIBCPP_ASSERT(p1 != nullptr, "debug mode internal logic error swap A");
    551 @@ -420,7 +458,9 @@ __libcpp_db::swap(void* c1, void* c2)
    552  void
    553  __libcpp_db::__insert_i(void* __i)
    554  {
    555 +#if !_LIBCPP_SINGLE_THREADED
    556      WLock _(mut());
    557 +#endif
    558      __insert_iterator(__i);
    559  }
    560  
    561 diff --git a/src/future.cpp b/src/future.cpp
    562 index c67dc58..91756e1 100644
    563 --- a/src/future.cpp
    564 +++ b/src/future.cpp
    565 @@ -10,6 +10,8 @@
    566  #include "future"
    567  #include "string"
    568  
    569 +#if !_LIBCPP_SINGLE_THREADED
    570 +
    571  _LIBCPP_BEGIN_NAMESPACE_STD
    572  
    573  class _LIBCPP_HIDDEN __future_error_category
    574 @@ -298,3 +300,7 @@ shared_future<void>::operator=(const shared_future& __rhs)
    575  }
    576  
    577  _LIBCPP_END_NAMESPACE_STD
    578 +
    579 +#endif // !_LIBCPP_SINGLE_THREADED
    580 +
    581 +
    582 diff --git a/src/memory.cpp b/src/memory.cpp
    583 index 666673f..2938538 100644
    584 --- a/src/memory.cpp
    585 +++ b/src/memory.cpp
    586 @@ -119,7 +119,7 @@ __shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT
    587  
    588  #endif  // _LIBCPP_NO_RTTI
    589  
    590 -#if __has_feature(cxx_atomic)
    591 +#if __has_feature(cxx_atomic) && !_LIBCPP_SINGLE_THREADED
    592  
    593  static const std::size_t __sp_mut_count = 16;
    594  static pthread_mutex_t mut_back_imp[__sp_mut_count] =
    595 @@ -172,7 +172,7 @@ __get_sp_mut(const void* p)
    596      return muts[hash<const void*>()(p) & (__sp_mut_count-1)];
    597  }
    598  
    599 -#endif // __has_feature(cxx_atomic)
    600 +#endif // __has_feature(cxx_atomic) && LIBCPP_HAS_PTHREADS
    601  
    602  void
    603  declare_reachable(void*)
    604 diff --git a/src/mutex.cpp b/src/mutex.cpp
    605 index 0767897..18a68b1 100644
    606 --- a/src/mutex.cpp
    607 +++ b/src/mutex.cpp
    608 @@ -14,6 +14,7 @@
    609  #include "cassert"
    610  
    611  _LIBCPP_BEGIN_NAMESPACE_STD
    612 +#if !_LIBCPP_SINGLE_THREADED
    613  
    614  const defer_lock_t  defer_lock = {};
    615  const try_to_lock_t try_to_lock = {};
    616 @@ -206,21 +207,27 @@ recursive_timed_mutex::unlock() _NOEXCEPT
    617      }
    618  }
    619  
    620 +#endif // !_LIBCPP_SINGLE_THREADED
    621 +
    622  // If dispatch_once_f ever handles C++ exceptions, and if one can get to it
    623  // without illegal macros (unexpected macros not beginning with _UpperCase or
    624  // __lowercase), and if it stops spinning waiting threads, then call_once should
    625  // call into dispatch_once_f instead of here. Relevant radar this code needs to
    626  // keep in sync with:  7741191.
    627  
    628 +#if !_LIBCPP_SINGLE_THREADED
    629  static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
    630  static pthread_cond_t  cv  = PTHREAD_COND_INITIALIZER;
    631 +#endif
    632  
    633  void
    634  __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
    635  {
    636 +#if !_LIBCPP_SINGLE_THREADED
    637      pthread_mutex_lock(&mut);
    638      while (flag == 1)
    639          pthread_cond_wait(&cv, &mut);
    640 +#endif // !_LIBCPP_SINGLE_THREADED
    641      if (flag == 0)
    642      {
    643  #ifndef _LIBCPP_NO_EXCEPTIONS
    644 @@ -228,26 +235,38 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
    645          {
    646  #endif  // _LIBCPP_NO_EXCEPTIONS
    647              flag = 1;
    648 +#if !_LIBCPP_SINGLE_THREADED
    649              pthread_mutex_unlock(&mut);
    650 +#endif // !_LIBCPP_SINGLE_THREADED
    651              func(arg);
    652 +#if !_LIBCPP_SINGLE_THREADED
    653              pthread_mutex_lock(&mut);
    654 +#endif // !_LIBCPP_SINGLE_THREADED
    655              flag = ~0ul;
    656 +#if !_LIBCPP_SINGLE_THREADED
    657              pthread_mutex_unlock(&mut);
    658              pthread_cond_broadcast(&cv);
    659 +#endif // !_LIBCPP_SINGLE_THREADED
    660  #ifndef _LIBCPP_NO_EXCEPTIONS
    661          }
    662          catch (...)
    663          {
    664 +#if !_LIBCPP_SINGLE_THREADED
    665              pthread_mutex_lock(&mut);
    666 +#endif // !_LIBCPP_SINGLE_THREADED
    667              flag = 0ul;
    668 +#if !_LIBCPP_SINGLE_THREADED
    669              pthread_mutex_unlock(&mut);
    670              pthread_cond_broadcast(&cv);
    671 +#endif // !_LIBCPP_SINGLE_THREADED
    672              throw;
    673          }
    674  #endif  // _LIBCPP_NO_EXCEPTIONS
    675      }
    676 +#if !_LIBCPP_SINGLE_THREADED
    677      else
    678          pthread_mutex_unlock(&mut);
    679 +#endif // !_LIBCPP_SINGLE_THREADED
    680  }
    681  
    682  _LIBCPP_END_NAMESPACE_STD
    683 diff --git a/src/shared_mutex.cpp b/src/shared_mutex.cpp
    684 index dd78a16..860e23a 100644
    685 --- a/src/shared_mutex.cpp
    686 +++ b/src/shared_mutex.cpp
    687 @@ -10,6 +10,8 @@
    688  #define _LIBCPP_BUILDING_SHARED_MUTEX
    689  #include "shared_mutex"
    690  
    691 +#if !_LIBCPP_SINGLE_THREADED
    692 +
    693  _LIBCPP_BEGIN_NAMESPACE_STD
    694  
    695  shared_timed_mutex::shared_timed_mutex()
    696 @@ -99,3 +101,7 @@ shared_timed_mutex::unlock_shared()
    697  
    698  
    699  _LIBCPP_END_NAMESPACE_STD
    700 +
    701 +#endif // !_LIBCPP_SINGLE_THREADED
    702 +
    703 +
    704 diff --git a/src/thread.cpp b/src/thread.cpp
    705 index bd2b7c3..1ffef7a 100644
    706 --- a/src/thread.cpp
    707 +++ b/src/thread.cpp
    708 @@ -27,6 +27,8 @@
    709  #include <windows.h>
    710  #endif
    711  
    712 +#if !_LIBCPP_SINGLE_THREADED
    713 +
    714  _LIBCPP_BEGIN_NAMESPACE_STD
    715  
    716  thread::~thread()
    717 @@ -121,7 +123,11 @@ sleep_for(const chrono::nanoseconds& ns)
    718              ts.tv_sec = ts_sec_max;
    719              ts.tv_nsec = giga::num - 1;
    720          }
    721 +#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309L
    722          nanosleep(&ts, 0);
    723 +#else
    724 +#warning sleep_for not yet implemented
    725 +#endif
    726      }
    727  }
    728  
    729 @@ -223,3 +229,6 @@ __thread_struct::__make_ready_at_thread_exit(__assoc_sub_state* __s)
    730  }
    731  
    732  _LIBCPP_END_NAMESPACE_STD
    733 +
    734 +#endif // !_LIBCPP_SINGLE_THREADED
    735 +
    736 diff --git a/test/re/re.alg/re.alg.match/basic.pass.cpp b/test/re/re.alg/re.alg.match/basic.pass.cpp
    737 index 55c7361..9d3f39d 100644
    738 --- a/test/re/re.alg/re.alg.match/basic.pass.cpp
    739 +++ b/test/re/re.alg/re.alg.match/basic.pass.cpp
    740 @@ -614,6 +614,12 @@ int main()
    741                                                   std::regex_constants::basic)));
    742          assert(m.size() == 0);
    743      }
    744 +/* Disable locale specific tests on Android because Android's NDK does not
    745 + * support locales other than "C" and "POSIX".
    746 + *
    747 + * https://code.google.com/p/android/issues/detail?id=57313
    748 + */
    749 +#if !defined(__ANDROID__)
    750      std::locale::global(std::locale("cs_CZ.ISO8859-2"));
    751      {
    752          std::cmatch m;
    753 @@ -648,6 +654,7 @@ int main()
    754          assert(m.str(0) == s);
    755      }
    756      std::locale::global(std::locale("C"));
    757 +#endif
    758      {
    759          std::cmatch m;
    760          const char s[] = "m";
    761 @@ -1282,6 +1289,12 @@ int main()
    762                                                   std::regex_constants::basic)));
    763          assert(m.size() == 0);
    764      }
    765 +/* Disable locale specific tests on Android because Android's NDK does not
    766 + * support locales other than "C" and "POSIX".
    767 + *
    768 + * https://code.google.com/p/android/issues/detail?id=57313
    769 + */
    770 +#if !defined(__ANDROID__)
    771      std::locale::global(std::locale("cs_CZ.ISO8859-2"));
    772      {
    773          std::wcmatch m;
    774 @@ -1316,6 +1329,7 @@ int main()
    775          assert(m.str(0) == s);
    776      }
    777      std::locale::global(std::locale("C"));
    778 +#endif
    779      {
    780          std::wcmatch m;
    781          const wchar_t s[] = L"m";
    782 diff --git a/test/re/re.alg/re.alg.match/ecma.pass.cpp b/test/re/re.alg/re.alg.match/ecma.pass.cpp
    783 index 162a6a7..bb36831 100644
    784 --- a/test/re/re.alg/re.alg.match/ecma.pass.cpp
    785 +++ b/test/re/re.alg/re.alg.match/ecma.pass.cpp
    786 @@ -576,6 +576,12 @@ int main()
    787          assert(!std::regex_match(s, m, std::regex("[a[.hyphen.]z]")));
    788          assert(m.size() == 0);
    789      }
    790 +/* Disable locale specific tests on Android because Android's NDK does not
    791 + * support locales other than "C" and "POSIX".
    792 + *
    793 + * https://code.google.com/p/android/issues/detail?id=57313
    794 + */
    795 +#if !defined(__ANDROID__)
    796      std::locale::global(std::locale("cs_CZ.ISO8859-2"));
    797      {
    798          std::cmatch m;
    799 @@ -621,6 +627,7 @@ int main()
    800          assert(m.size() == 1);
    801      }
    802      std::locale::global(std::locale("C"));
    803 +#endif
    804      {
    805          std::cmatch m;
    806          const char s[] = "m";
    807 @@ -1241,6 +1248,12 @@ int main()
    808          assert(!std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]")));
    809          assert(m.size() == 0);
    810      }
    811 +/* Disable locale specific tests on Android because Android's NDK does not
    812 + * support locales other than "C" and "POSIX".
    813 + *
    814 + * https://code.google.com/p/android/issues/detail?id=57313
    815 + */
    816 +#if !defined(__ANDROID__)
    817      std::locale::global(std::locale("cs_CZ.ISO8859-2"));
    818      {
    819          std::wcmatch m;
    820 @@ -1274,6 +1287,7 @@ int main()
    821          assert(m.str(0) == s);
    822      }
    823      std::locale::global(std::locale("C"));
    824 +#endif
    825      {
    826          std::wcmatch m;
    827          const wchar_t s[] = L"m";
    828 diff --git a/test/re/re.alg/re.alg.match/extended.pass.cpp b/test/re/re.alg/re.alg.match/extended.pass.cpp
    829 index 683f65b..5ef8695 100644
    830 --- a/test/re/re.alg/re.alg.match/extended.pass.cpp
    831 +++ b/test/re/re.alg/re.alg.match/extended.pass.cpp
    832 @@ -612,6 +612,12 @@ int main()
    833                                                   std::regex_constants::extended)));
    834          assert(m.size() == 0);
    835      }
    836 +/* Disable locale specific tests on Android because Android's NDK does not
    837 + * support locales other than "C" and "POSIX".
    838 + *
    839 + * https://code.google.com/p/android/issues/detail?id=57313
    840 + */
    841 +#if !defined(__ANDROID__)
    842      std::locale::global(std::locale("cs_CZ.ISO8859-2"));
    843      {
    844          std::cmatch m;
    845 @@ -646,6 +652,7 @@ int main()
    846          assert(m.str(0) == s);
    847      }
    848      std::locale::global(std::locale("C"));
    849 +#endif
    850      {
    851          std::cmatch m;
    852          const char s[] = "m";
    853 @@ -1278,6 +1285,12 @@ int main()
    854                                                   std::regex_constants::extended)));
    855          assert(m.size() == 0);
    856      }
    857 +/* Disable locale specific tests on Android because Android's NDK does not
    858 + * support locales other than "C" and "POSIX".
    859 + *
    860 + * https://code.google.com/p/android/issues/detail?id=57313
    861 + */
    862 +#if !defined(__ANDROID__)
    863      std::locale::global(std::locale("cs_CZ.ISO8859-2"));
    864      {
    865          std::wcmatch m;
    866 @@ -1312,6 +1325,7 @@ int main()
    867          assert(m.str(0) == s);
    868      }
    869      std::locale::global(std::locale("C"));
    870 +#endif
    871      {
    872          std::wcmatch m;
    873          const wchar_t s[] = L"m";
    874 diff --git a/test/re/re.alg/re.alg.search/awk.pass.cpp b/test/re/re.alg/re.alg.search/awk.pass.cpp
    875 index 57606c1..b03dd7b 100644
    876 --- a/test/re/re.alg/re.alg.search/awk.pass.cpp
    877 +++ b/test/re/re.alg/re.alg.search/awk.pass.cpp
    878 @@ -684,6 +684,12 @@ int main()
    879                                                   std::regex_constants::awk)));
    880          assert(m.size() == 0);
    881      }
    882 +/* Disable locale specific tests on Android because Android's NDK does not
    883 + * support locales other than "C" and "POSIX".
    884 + *
    885 + * https://code.google.com/p/android/issues/detail?id=57313
    886 + */
    887 +#if !defined(__ANDROID__)
    888      std::locale::global(std::locale("cs_CZ.ISO8859-2"));
    889      {
    890          std::cmatch m;
    891 @@ -718,6 +724,7 @@ int main()
    892          assert(m.str(0) == s);
    893      }
    894      std::locale::global(std::locale("C"));
    895 +#endif
    896      {
    897          std::cmatch m;
    898          const char s[] = "m";
    899 @@ -1455,6 +1462,12 @@ int main()
    900                                                   std::regex_constants::awk)));
    901          assert(m.size() == 0);
    902      }
    903 +/* Disable locale specific tests on Android because Android's NDK does not
    904 + * support locales other than "C" and "POSIX".
    905 + *
    906 + * https://code.google.com/p/android/issues/detail?id=57313
    907 + */
    908 +#if !defined(__ANDROID__)
    909      std::locale::global(std::locale("cs_CZ.ISO8859-2"));
    910      {
    911          std::wcmatch m;
    912 @@ -1489,6 +1502,7 @@ int main()
    913          assert(m.str(0) == s);
    914      }
    915      std::locale::global(std::locale("C"));
    916 +#endif
    917      {
    918          std::wcmatch m;
    919          const wchar_t s[] = L"m";
    920 diff --git a/test/re/re.alg/re.alg.search/basic.pass.cpp b/test/re/re.alg/re.alg.search/basic.pass.cpp
    921 index 56396f3..809f870 100644
    922 --- a/test/re/re.alg/re.alg.search/basic.pass.cpp
    923 +++ b/test/re/re.alg/re.alg.search/basic.pass.cpp
    924 @@ -686,6 +686,12 @@ int main()
    925                                                   std::regex_constants::basic)));
    926          assert(m.size() == 0);
    927      }
    928 +/* Disable locale specific tests on Android because Android's NDK does not
    929 + * support locales other than "C" and "POSIX".
    930 + *
    931 + * https://code.google.com/p/android/issues/detail?id=57313
    932 + */
    933 +#if !defined(__ANDROID__)
    934      std::locale::global(std::locale("cs_CZ.ISO8859-2"));
    935      {
    936          std::cmatch m;
    937 @@ -720,6 +726,7 @@ int main()
    938          assert(m.str(0) == s);
    939      }
    940      std::locale::global(std::locale("C"));
    941 +#endif
    942      {
    943          std::cmatch m;
    944          const char s[] = "m";
    945 @@ -1444,6 +1451,12 @@ int main()
    946                                                   std::regex_constants::basic)));
    947          assert(m.size() == 0);
    948      }
    949 +/* Disable locale specific tests on Android because Android's NDK does not
    950 + * support locales other than "C" and "POSIX".
    951 + *
    952 + * https://code.google.com/p/android/issues/detail?id=57313
    953 + */
    954 +#if !defined(__ANDROID__)
    955      std::locale::global(std::locale("cs_CZ.ISO8859-2"));
    956      {
    957          std::wcmatch m;
    958 @@ -1478,6 +1491,7 @@ int main()
    959          assert(m.str(0) == s);
    960      }
    961      std::locale::global(std::locale("C"));
    962 +#endif
    963      {
    964          std::wcmatch m;
    965          const wchar_t s[] = L"m";
    966 diff --git a/test/re/re.alg/re.alg.search/ecma.pass.cpp b/test/re/re.alg/re.alg.search/ecma.pass.cpp
    967 index 8149157..21e3efe 100644
    968 --- a/test/re/re.alg/re.alg.search/ecma.pass.cpp
    969 +++ b/test/re/re.alg/re.alg.search/ecma.pass.cpp
    970 @@ -666,6 +666,12 @@ int main()
    971          assert(!std::regex_search(s, m, std::regex("[a[.hyphen.]z]")));
    972          assert(m.size() == 0);
    973      }
    974 +/* Disable locale specific tests on Android because Android's NDK does not
    975 + * support locales other than "C" and "POSIX".
    976 + *
    977 + * https://code.google.com/p/android/issues/detail?id=57313
    978 + */
    979 +#if !defined(__ANDROID__)
    980      std::locale::global(std::locale("cs_CZ.ISO8859-2"));
    981      {
    982          std::cmatch m;
    983 @@ -699,6 +705,7 @@ int main()
    984          assert(m.str(0) == s);
    985      }
    986      std::locale::global(std::locale("C"));
    987 +#endif
    988      {
    989          std::cmatch m;
    990          const char s[] = "m";
    991 @@ -1445,6 +1452,12 @@ int main()
    992          assert(!std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]")));
    993          assert(m.size() == 0);
    994      }
    995 +/* Disable locale specific tests on Android because Android's NDK does not
    996 + * support locales other than "C" and "POSIX".
    997 + *
    998 + * https://code.google.com/p/android/issues/detail?id=57313
    999 + */
   1000 +#if !defined(__ANDROID__)
   1001      std::locale::global(std::locale("cs_CZ.ISO8859-2"));
   1002      {
   1003          std::wcmatch m;
   1004 @@ -1478,6 +1491,7 @@ int main()
   1005          assert(m.str(0) == s);
   1006      }
   1007      std::locale::global(std::locale("C"));
   1008 +#endif
   1009      {
   1010          std::wcmatch m;
   1011          const wchar_t s[] = L"m";
   1012 diff --git a/test/re/re.alg/re.alg.search/extended.pass.cpp b/test/re/re.alg/re.alg.search/extended.pass.cpp
   1013 index 8240872..9cac3b2 100644
   1014 --- a/test/re/re.alg/re.alg.search/extended.pass.cpp
   1015 +++ b/test/re/re.alg/re.alg.search/extended.pass.cpp
   1016 @@ -684,6 +684,12 @@ int main()
   1017                                                   std::regex_constants::extended)));
   1018          assert(m.size() == 0);
   1019      }
   1020 +/* Disable locale specific tests on Android because Android's NDK does not
   1021 + * support locales other than "C" and "POSIX".
   1022 + *
   1023 + * https://code.google.com/p/android/issues/detail?id=57313
   1024 + */
   1025 +#if !defined(__ANDROID__)
   1026      std::locale::global(std::locale("cs_CZ.ISO8859-2"));
   1027      {
   1028          std::cmatch m;
   1029 @@ -718,6 +724,7 @@ int main()
   1030          assert(m.str(0) == s);
   1031      }
   1032      std::locale::global(std::locale("C"));
   1033 +#endif
   1034      {
   1035          std::cmatch m;
   1036          const char s[] = "m";
   1037 @@ -1440,6 +1447,12 @@ int main()
   1038                                                   std::regex_constants::extended)));
   1039          assert(m.size() == 0);
   1040      }
   1041 +/* Disable locale specific tests on Android because Android's NDK does not
   1042 + * support locales other than "C" and "POSIX".
   1043 + *
   1044 + * https://code.google.com/p/android/issues/detail?id=57313
   1045 + */
   1046 +#if !defined(__ANDROID__)
   1047      std::locale::global(std::locale("cs_CZ.ISO8859-2"));
   1048      {
   1049          std::wcmatch m;
   1050 @@ -1474,6 +1487,7 @@ int main()
   1051          assert(m.str(0) == s);
   1052      }
   1053      std::locale::global(std::locale("C"));
   1054 +#endif
   1055      {
   1056          std::wcmatch m;
   1057          const wchar_t s[] = L"m";
   1058 diff --git a/test/re/re.traits/lookup_collatename.pass.cpp b/test/re/re.traits/lookup_collatename.pass.cpp
   1059 index 055b554..9c6f108 100644
   1060 --- a/test/re/re.traits/lookup_collatename.pass.cpp
   1061 +++ b/test/re/re.traits/lookup_collatename.pass.cpp
   1062 @@ -103,9 +103,6 @@ int main()
   1063  
   1064      test("tild", std::string(""));
   1065      test("ch", std::string(""));
   1066 -    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
   1067 -    test("ch", std::string("ch"));
   1068 -    std::locale::global(std::locale("C"));
   1069  
   1070      test(L"NUL", std::wstring(L"\x00", 1));
   1071      test(L"alert", std::wstring(L"\x07"));
   1072 @@ -179,7 +176,4 @@ int main()
   1073  
   1074      test(L"tild", std::wstring(L""));
   1075      test(L"ch", std::wstring(L""));
   1076 -    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
   1077 -    test(L"ch", std::wstring(L"ch"));
   1078 -    std::locale::global(std::locale("C"));
   1079  }
   1080 diff --git a/test/re/re.traits/lookup_collatename.xlocale.pass.cpp b/test/re/re.traits/lookup_collatename.xlocale.pass.cpp
   1081 new file mode 100644
   1082 index 0000000..b6e563c
   1083 --- /dev/null
   1084 +++ b/test/re/re.traits/lookup_collatename.xlocale.pass.cpp
   1085 @@ -0,0 +1,41 @@
   1086 +//===----------------------------------------------------------------------===//
   1087 +//
   1088 +//                     The LLVM Compiler Infrastructure
   1089 +//
   1090 +// This file is dual licensed under the MIT and the University of Illinois Open
   1091 +// Source Licenses. See LICENSE.TXT for details.
   1092 +//
   1093 +//===----------------------------------------------------------------------===//
   1094 +
   1095 +// <regex>
   1096 +
   1097 +// template <class charT> struct regex_traits;
   1098 +
   1099 +// template <class ForwardIterator>
   1100 +//   string_type
   1101 +//   lookup_collatename(ForwardIterator first, ForwardIterator last) const;
   1102 +
   1103 +#include <regex>
   1104 +#include <iterator>
   1105 +#include <cassert>
   1106 +#include "test_iterators.h"
   1107 +
   1108 +template <class char_type>
   1109 +void
   1110 +test(const char_type* A, const std::basic_string<char_type>& expected)
   1111 +{
   1112 +    std::regex_traits<char_type> t;
   1113 +    typedef forward_iterator<const char_type*> F;
   1114 +    assert(t.lookup_collatename(F(A), F(A + t.length(A))) == expected);
   1115 +}
   1116 +
   1117 +int main()
   1118 +{
   1119 +#if !defined(__ANDROID__)
   1120 +    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
   1121 +    test("ch", std::string("ch"));
   1122 +
   1123 +    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
   1124 +    test(L"ch", std::wstring(L"ch"));
   1125 +#endif
   1126 +}
   1127 diff --git a/test/re/re.traits/transform.pass.cpp b/test/re/re.traits/transform.pass.cpp
   1128 index 9b9feb1..73d6593 100644
   1129 --- a/test/re/re.traits/transform.pass.cpp
   1130 +++ b/test/re/re.traits/transform.pass.cpp
   1131 @@ -27,8 +27,15 @@ int main()
   1132          const char B[] = "B";
   1133          typedef forward_iterator<const char*> F;
   1134          assert(t.transform(F(a), F(a+1)) > t.transform(F(B), F(B+1)));
   1135 +/* Disable locale specific tests on Android because Android's NDK does not
   1136 + * support locales other than "C" and "POSIX".
   1137 + *
   1138 + * https://code.google.com/p/android/issues/detail?id=57313
   1139 + */
   1140 +#if !defined(__ANDROID__)
   1141          t.imbue(std::locale("cs_CZ.ISO8859-2"));
   1142          assert(t.transform(F(a), F(a+1)) < t.transform(F(B), F(B+1)));
   1143 +#endif
   1144      }
   1145      {
   1146          std::regex_traits<wchar_t> t;
   1147 @@ -36,7 +43,14 @@ int main()
   1148          const wchar_t B[] = L"B";
   1149          typedef forward_iterator<const wchar_t*> F;
   1150          assert(t.transform(F(a), F(a+1)) > t.transform(F(B), F(B+1)));
   1151 +/* Disable locale specific tests on Android because Android's NDK does not
   1152 + * support locales other than "C" and "POSIX".
   1153 + *
   1154 + * https://code.google.com/p/android/issues/detail?id=57313
   1155 + */
   1156 +#if !defined(__ANDROID__)
   1157          t.imbue(std::locale("cs_CZ.ISO8859-2"));
   1158          assert(t.transform(F(a), F(a+1)) < t.transform(F(B), F(B+1)));
   1159 +#endif
   1160      }
   1161  }
   1162 diff --git a/test/re/re.traits/transform_primary.pass.cpp b/test/re/re.traits/transform_primary.pass.cpp
   1163 index 1e2aca6..a22d86d 100644
   1164 --- a/test/re/re.traits/transform_primary.pass.cpp
   1165 +++ b/test/re/re.traits/transform_primary.pass.cpp
   1166 @@ -29,9 +29,16 @@ int main()
   1167          typedef forward_iterator<const char*> F;
   1168          assert(t.transform_primary(F(A), F(A+1)) !=
   1169                 t.transform_primary(F(Aacute), F(Aacute+1)));
   1170 +/* Disable locale specific tests on Android because Android's NDK does not
   1171 + * support locales other than "C" and "POSIX".
   1172 + *
   1173 + * https://code.google.com/p/android/issues/detail?id=57313
   1174 + */
   1175 +#if !defined(__ANDROID__)
   1176          t.imbue(std::locale("cs_CZ.ISO8859-2"));
   1177          assert(t.transform_primary(F(A), F(A+1)) ==
   1178                 t.transform_primary(F(Aacute), F(Aacute+1)));
   1179 +#endif
   1180      }
   1181      {
   1182          std::regex_traits<wchar_t> t;
   1183 @@ -40,8 +47,15 @@ int main()
   1184          typedef forward_iterator<const wchar_t*> F;
   1185          assert(t.transform_primary(F(A), F(A+1)) !=
   1186                 t.transform_primary(F(Aacute), F(Aacute+1)));
   1187 +/* Disable locale specific tests on Android because Android's NDK does not
   1188 + * support locales other than "C" and "POSIX".
   1189 + *
   1190 + * https://code.google.com/p/android/issues/detail?id=57313
   1191 + */
   1192 +#if !defined(__ANDROID__)
   1193          t.imbue(std::locale("cs_CZ.ISO8859-2"));
   1194          assert(t.transform_primary(F(A), F(A+1)) ==
   1195                 t.transform_primary(F(Aacute), F(Aacute+1)));
   1196 +#endif
   1197      }
   1198  }
   1199 diff --git a/test/re/re.traits/translate_nocase.pass.cpp b/test/re/re.traits/translate_nocase.pass.cpp
   1200 index 5e042ae..bd8a7f4 100644
   1201 --- a/test/re/re.traits/translate_nocase.pass.cpp
   1202 +++ b/test/re/re.traits/translate_nocase.pass.cpp
   1203 @@ -34,6 +34,12 @@ int main()
   1204          assert(t.translate_nocase('1') == '1');
   1205          assert(t.translate_nocase('\xDA') == '\xDA');
   1206          assert(t.translate_nocase('\xFA') == '\xFA');
   1207 +/* Disable locale specific tests on Android because Android's NDK does not
   1208 + * support locales other than "C" and "POSIX".
   1209 + *
   1210 + * https://code.google.com/p/android/issues/detail?id=57313
   1211 + */
   1212 +#if !defined(__ANDROID__)
   1213          t.imbue(std::locale(LOCALE_en_US_UTF_8));
   1214          assert(t.translate_nocase(' ') == ' ');
   1215          assert(t.translate_nocase('A') == 'a');
   1216 @@ -43,6 +49,7 @@ int main()
   1217          assert(t.translate_nocase('1') == '1');
   1218          assert(t.translate_nocase('\xDA') == '\xFA');
   1219          assert(t.translate_nocase('\xFA') == '\xFA');
   1220 +#endif
   1221      }
   1222      {
   1223          std::regex_traits<wchar_t> t;
   1224 @@ -54,6 +61,12 @@ int main()
   1225          assert(t.translate_nocase(L'1') == L'1');
   1226          assert(t.translate_nocase(L'\xDA') == L'\xDA');
   1227          assert(t.translate_nocase(L'\xFA') == L'\xFA');
   1228 +/* Disable locale specific tests on Android because Android's NDK does not
   1229 + * support locales other than "C" and "POSIX".
   1230 + *
   1231 + * https://code.google.com/p/android/issues/detail?id=57313
   1232 + */
   1233 +#if !defined(__ANDROID__)
   1234          t.imbue(std::locale(LOCALE_en_US_UTF_8));
   1235          assert(t.translate_nocase(L' ') == L' ');
   1236          assert(t.translate_nocase(L'A') == L'a');
   1237 @@ -63,5 +76,6 @@ int main()
   1238          assert(t.translate_nocase(L'1') == L'1');
   1239          assert(t.translate_nocase(L'\xDA') == L'\xFA');
   1240          assert(t.translate_nocase(L'\xFA') == L'\xFA');
   1241 +#endif
   1242      }
   1243  }
   1244 diff --git a/test/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp b/test/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp
   1245 index d1b7700..67ee23d 100644
   1246 --- a/test/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp
   1247 +++ b/test/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp
   1248 @@ -159,12 +159,16 @@ int main()
   1249      static_assert(std::alignment_of<T1>::value == 8, "");
   1250      static_assert(sizeof(T1) == 16, "");
   1251      }
   1252 +    // The expected values for the tests below (modulo the last one) are
   1253 +    // platform-specific which alignof deals with. In particular, the maximum
   1254 +    // alignment value on ARM is 8 bytes as opposed to 16 bytes on some other
   1255 +    // architectures that support 128 bit memory accesses.
   1256      {
   1257      typedef std::aligned_storage<16>::type T1;
   1258  #if _LIBCPP_STD_VER > 11
   1259      static_assert(std::is_same<std::aligned_storage_t<16>, T1>::value, "" );
   1260  #endif
   1261 -    static_assert(std::alignment_of<T1>::value == 16, "");
   1262 +    static_assert(std::alignment_of<T1>::value == alignof(T1), "");
   1263      static_assert(sizeof(T1) == 16, "");
   1264      }
   1265      {
   1266 @@ -172,8 +176,8 @@ int main()
   1267  #if _LIBCPP_STD_VER > 11
   1268      static_assert(std::is_same<std::aligned_storage_t<17>, T1>::value, "" );
   1269  #endif
   1270 -    static_assert(std::alignment_of<T1>::value == 16, "");
   1271 -    static_assert(sizeof(T1) == 32, "");
   1272 +    static_assert(std::alignment_of<T1>::value == alignof(T1), "");
   1273 +    static_assert(sizeof(T1) == 16 + alignof(T1), "");
   1274      }
   1275      {
   1276      typedef std::aligned_storage<10>::type T1;
   1277 -- 
   1278 1.9.1.423.g4596e3a
   1279 
   1280