diff options
Diffstat (limited to 'system/lib')
46 files changed, 2391 insertions, 1229 deletions
diff --git a/system/lib/dlmalloc.c b/system/lib/dlmalloc.c index 7e04a726..9a84d48f 100644 --- a/system/lib/dlmalloc.c +++ b/system/lib/dlmalloc.c @@ -532,6 +532,10 @@ #define DLMALLOC_VERSION 20806 #endif /* DLMALLOC_VERSION */ +#if EMSCRIPTEN +#define DLMALLOC_EXPORT __attribute__((__weak__, __visibility__("default"))) +#endif + #ifndef DLMALLOC_EXPORT #define DLMALLOC_EXPORT extern #endif @@ -6291,4 +6295,4 @@ int mspace_mallopt(int param_number, int value) { * Based loosely on libg++-1.2X malloc. (It retains some of the overall structure of old version, but most details differ.) - */
\ No newline at end of file + */ diff --git a/system/lib/libc.symbols b/system/lib/libc.symbols index 1342d938..96e995cf 100644 --- a/system/lib/libc.symbols +++ b/system/lib/libc.symbols @@ -1,75 +1,81 @@ -getopt -getopt_long -getopt_long_only -malloc -free -calloc -memalign -realloc -valloc -pvalloc -mallinfo -mallopt -malloc_trim -malloc_stats -malloc_usable_size -malloc_footprint -malloc_max_footprint -independent_calloc -independent_comalloc -_Znwj -_Znaj -_Znam -_Znwm -_ZdaPv -_ZdaPvRKSt9nothrow_t -_ZdlPv -_ZdlPvRKSt9nothrow_t -_Znaj -_ZnajRKSt9nothrow_t -_Znwj -_ZnwjRKSt9nothrow_t -_ZL13__new_handler -_ZSt15get_new_handlerv -_ZSt15set_new_handlerPFvvE -_ZTVSt9bad_alloc -_ZTSSt9bad_alloc +_ZNKSt20bad_array_new_length4whatEv _ZNKSt9bad_alloc4whatEv +_ZNSt20bad_array_new_lengthC1Ev +_ZNSt20bad_array_new_lengthC2Ev +_ZNSt20bad_array_new_lengthD0Ev +_ZNSt20bad_array_new_lengthD1Ev +_ZNSt20bad_array_new_lengthD2Ev _ZNSt9bad_allocC1Ev _ZNSt9bad_allocC2Ev _ZNSt9bad_allocD0Ev _ZNSt9bad_allocD1Ev _ZNSt9bad_allocD2Ev +_ZSt15get_new_handlerv +_ZSt15set_new_handlerPFvvE _ZSt17__throw_bad_allocv +_ZSt7nothrow +_ZTISt20bad_array_new_length _ZTISt9bad_alloc -_ZTVSt20bad_array_new_length _ZTSSt20bad_array_new_length -_ZTISt20bad_array_new_length -_ZNKSt20bad_array_new_length4whatEv -_ZNSt20bad_array_new_lengthC1Ev -_ZNSt20bad_array_new_lengthC2Ev -_ZNSt20bad_array_new_lengthD0Ev -_ZNSt20bad_array_new_lengthD1Ev -_ZNSt20bad_array_new_lengthD2Ev -warn -warnx -err -errx -_warn -_warnx +_ZTSSt9bad_alloc +_ZTVSt20bad_array_new_length +_ZTVSt9bad_alloc +_ZdaPv +_ZdaPvRKSt9nothrow_t +_ZdlPv +_ZdlPvRKSt9nothrow_t +_Znaj +_ZnajRKSt9nothrow_t +_Znwj +_ZnwjRKSt9nothrow_t _err _errx -vwarn -vwarnx -verr -verrx -_vwarn -_vwarnx _verr _verrx +_vwarn +_vwarnx +_warn +_warnx +atof +bulk_free +calloc +err +errx +free +getopt +getopt_long +getopt_long_only +independent_calloc +independent_comalloc +mallinfo +malloc +malloc_footprint +malloc_footprint_limit +malloc_max_footprint +malloc_set_footprint_limit +malloc_stats +malloc_trim +malloc_usable_size +mallopt +memalign +optarg +opterr +optind +optopt +optreset +posix_memalign +pvalloc +realloc +realloc_in_place strtod -strtold -strtof strtod_l +strtof +strtold strtold_l -atof +valloc +verr +verrx +vwarn +vwarnx +warn1 +warnx diff --git a/system/lib/libc/stdlib/strtod.c b/system/lib/libc/stdlib/strtod.c index 53191337..7c441247 100644 --- a/system/lib/libc/stdlib/strtod.c +++ b/system/lib/libc/stdlib/strtod.c @@ -284,7 +284,7 @@ strtold(const char* nptr, char **endptr) float strtof(const char* nptr, char **endptr) { - return (float) strtof(nptr, endptr); + return (float) strtod(nptr, endptr); } // XXX no locale support yet diff --git a/system/lib/libcxx/CREDITS.TXT b/system/lib/libcxx/CREDITS.TXT new file mode 100644 index 00000000..52948510 --- /dev/null +++ b/system/lib/libcxx/CREDITS.TXT @@ -0,0 +1,91 @@ +This file is a partial list of people who have contributed to the LLVM/libc++ +project. If you have contributed a patch or made some other contribution to +LLVM/libc++, please submit a patch to this file to add yourself, and it will be +done! + +The list is sorted by surname and formatted to allow easy grepping and +beautification by scripts. The fields are: name (N), email (E), web-address +(W), PGP key ID and fingerprint (P), description (D), and snail-mail address +(S). + +N: Saleem Abdulrasool +E: compnerd@compnerd.org +D: Minor patches and Linux fixes. + +N: Dimitry Andric +E: dimitry@andric.com +D: Visibility fixes, minor FreeBSD portability patches. + +N: Holger Arnold +E: holgerar@gmail.com +D: Minor fix. + +N: Ruben Van Boxem +E: vanboxem dot ruben at gmail dot com +D: Initial Windows patches. + +N: David Chisnall +E: theraven at theravensnest dot org +D: FreeBSD and Solaris ports, libcxxrt support, some atomics work. + +N: Marshall Clow +E: mclow.lists@gmail.com +E: marshall@idio.com +D: Minor patches and bug fixes. + +N: Google Inc. +D: Copyright owner and contributor of the CityHash algorithm + +N: Howard Hinnant +E: hhinnant@apple.com +D: Architect and primary author of libc++ + +N: Hyeon-bin Jeong +E: tuhertz@gmail.com +D: Minor patches and bug fixes. + +N: Argyrios Kyrtzidis +E: kyrtzidis@apple.com +D: Bug fixes. + +N: Michel Morin +E: mimomorin@gmail.com +D: Minor patches to is_convertible. + +N: Andrew Morrow +E: andrew.c.morrow@gmail.com +D: Minor patches and Linux fixes. + +N: Arvid Picciani +E: aep at exys dot org +D: Minor patches and musl port. + +N: Bjorn Reese +E: breese@users.sourceforge.net +D: Initial regex prototype + +N: Jonathan Sauer +D: Minor patches, mostly related to constexpr + +N: Craig Silverstein +E: csilvers@google.com +D: Implemented Cityhash as the string hash function on 64-bit machines + +N: Richard Smith +D: Minor patches. + +N: Michael van der Westhuizen +E: r1mikey at gmail dot com + +N: Klaas de Vries +E: klaas at klaasgaaf dot nl +D: Minor bug fix. + +N: Zhang Xiongpang +E: zhangxiongpang@gmail.com +D: Minor patches and bug fixes. + +N: Jeffrey Yasskin +E: jyasskin@gmail.com +E: jyasskin@google.com +D: Linux fixes. diff --git a/system/lib/libcxx/LICENSE.txt b/system/lib/libcxx/LICENSE.txt index 926f0676..5ed8ec22 100644 --- a/system/lib/libcxx/LICENSE.txt +++ b/system/lib/libcxx/LICENSE.txt @@ -14,7 +14,7 @@ Full text of the relevant licenses is included below. University of Illinois/NCSA Open Source License -Copyright (c) 2009-2010 by the contributors listed in CREDITS.TXT +Copyright (c) 2009-2013 by the contributors listed in CREDITS.TXT All rights reserved. @@ -55,7 +55,7 @@ SOFTWARE. ============================================================================== -Copyright (c) 2009-2010 by the contributors listed in CREDITS.TXT +Copyright (c) 2009-2013 by the contributors listed in CREDITS.TXT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/system/lib/libcxx/Makefile b/system/lib/libcxx/Makefile deleted file mode 100644 index 814921ea..00000000 --- a/system/lib/libcxx/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -OBJECTS = \ - algorithm.bc \ - condition_variable.bc \ - future.bc \ - iostream.bc \ - memory.bc \ - random.bc \ - stdexcept.bc \ - system_error.bc \ - utility.bc \ - bind.bc \ - debug.bc \ - hash.bc \ - mutex.bc \ - string.bc \ - thread.bc \ - valarray.bc \ - chrono.bc \ - exception.bc \ - ios.bc \ - locale.bc \ - regex.bc \ - strstream.bc \ - typeinfo.bc - -all: libcxx.bc - -%.bc: %.cpp - $(CXX) $< -o $@ - -libcxx.bc: $(OBJECTS) - $(CXX) $(OBJECTS) -o libcxx.bc - diff --git a/system/lib/libcxx/chrono.cpp b/system/lib/libcxx/chrono.cpp index 416b9501..1ce2e280 100644 --- a/system/lib/libcxx/chrono.cpp +++ b/system/lib/libcxx/chrono.cpp @@ -24,6 +24,8 @@ namespace chrono // system_clock +const bool system_clock::is_steady; + system_clock::time_point system_clock::now() _NOEXCEPT { @@ -46,6 +48,8 @@ system_clock::from_time_t(time_t t) _NOEXCEPT // steady_clock +const bool steady_clock::is_steady; + #if __APPLE__ // mach_absolute_time() * MachInfo.numer / MachInfo.denom is the number of // nanoseconds since the computer booted up. MachInfo.numer and MachInfo.denom @@ -61,7 +65,7 @@ static steady_clock::rep steady_simplified() { - return mach_absolute_time(); + return static_cast<steady_clock::rep>(mach_absolute_time()); } static diff --git a/system/lib/libcxx/condition_variable.cpp b/system/lib/libcxx/condition_variable.cpp index ca1dca32..de0f6f47 100644 --- a/system/lib/libcxx/condition_variable.cpp +++ b/system/lib/libcxx/condition_variable.cpp @@ -16,18 +16,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD condition_variable::~condition_variable() { - int e = pthread_cond_destroy(&__cv_); -// assert(e == 0); + pthread_cond_destroy(&__cv_); } void -condition_variable::notify_one() +condition_variable::notify_one() _NOEXCEPT { pthread_cond_signal(&__cv_); } void -condition_variable::notify_all() +condition_variable::notify_all() _NOEXCEPT { pthread_cond_broadcast(&__cv_); } @@ -52,10 +51,22 @@ condition_variable::__do_timed_wait(unique_lock<mutex>& lk, __throw_system_error(EPERM, "condition_variable::timed wait: mutex not locked"); nanoseconds d = tp.time_since_epoch(); + if (d > nanoseconds(0x59682F000000E941)) + d = nanoseconds(0x59682F000000E941); timespec ts; seconds s = duration_cast<seconds>(d); - ts.tv_sec = static_cast<decltype(ts.tv_sec)>(s.count()); - ts.tv_nsec = static_cast<decltype(ts.tv_nsec)>((d - s).count()); + typedef decltype(ts.tv_sec) ts_sec; + _LIBCPP_CONSTEXPR ts_sec ts_sec_max = numeric_limits<ts_sec>::max(); + if (s.count() < ts_sec_max) + { + ts.tv_sec = static_cast<ts_sec>(s.count()); + ts.tv_nsec = static_cast<decltype(ts.tv_nsec)>((d - s).count()); + } + else + { + ts.tv_sec = ts_sec_max; + ts.tv_nsec = giga::num - 1; + } int ec = pthread_cond_timedwait(&__cv_, lk.mutex()->native_handle(), &ts); if (ec != 0 && ec != ETIMEDOUT) __throw_system_error(ec, "condition_variable timed_wait failed"); diff --git a/system/lib/libcxx/debug.cpp b/system/lib/libcxx/debug.cpp index 2d2d6432..f3a0262d 100644 --- a/system/lib/libcxx/debug.cpp +++ b/system/lib/libcxx/debug.cpp @@ -23,7 +23,7 @@ __get_db() { static __libcpp_db db; return &db; -}; +} _LIBCPP_VISIBLE const __libcpp_db* @@ -120,20 +120,18 @@ __libcpp_db::__insert_ic(void* __i, const void* __c) { WLock _(mut()); __i_node* i = __insert_iterator(__i); - _LIBCPP_ASSERT(__cbeg_ != __cend_, "Container constructed in a translation unit with debug mode disabled." - " But it is being used in a translation unit with debug mode enabled." - " Enable it in the other translation unit with #define _LIBCPP_DEBUG2 1"); - size_t hc = hash<const void*>()(__c) % (__cend_ - __cbeg_); + const char* errmsg = + "Container constructed in a translation unit with debug mode disabled." + " But it is being used in a translation unit with debug mode enabled." + " Enable it in the other translation unit with #define _LIBCPP_DEBUG2 1"; + _LIBCPP_ASSERT(__cbeg_ != __cend_, errmsg); + size_t hc = hash<const void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); __c_node* c = __cbeg_[hc]; - _LIBCPP_ASSERT(c != nullptr, "Container constructed in a translation unit with debug mode disabled." - " But it is being used in a translation unit with debug mode enabled." - " Enable it in the other translation unit with #define _LIBCPP_DEBUG2 1"); + _LIBCPP_ASSERT(c != nullptr, errmsg); while (c->__c_ != __c) { c = c->__next_; - _LIBCPP_ASSERT(c != nullptr, "Container constructed in a translation unit with debug mode disabled." - " But it is being used in a translation unit with debug mode enabled." - " Enable it in the other translation unit with #define _LIBCPP_DEBUG2 1"); + _LIBCPP_ASSERT(c != nullptr, errmsg); } c->__add(i); i->__c_ = c; @@ -143,12 +141,16 @@ __c_node* __libcpp_db::__insert_c(void* __c) { WLock _(mut()); - if (__csz_ + 1 > __cend_ - __cbeg_) + if (__csz_ + 1 > static_cast<size_t>(__cend_ - __cbeg_)) { - size_t nc = __next_prime(2*(__cend_ - __cbeg_) + 1); + size_t nc = __next_prime(2*static_cast<size_t>(__cend_ - __cbeg_) + 1); __c_node** cbeg = (__c_node**)calloc(nc, sizeof(void*)); if (cbeg == nullptr) +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); +#else + abort(); +#endif for (__c_node** p = __cbeg_; p != __cend_; ++p) { __c_node* q = *p; @@ -165,11 +167,15 @@ __libcpp_db::__insert_c(void* __c) __cbeg_ = cbeg; __cend_ = __cbeg_ + nc; } - size_t hc = hash<void*>()(__c) % (__cend_ - __cbeg_); + size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); __c_node* p = __cbeg_[hc]; __c_node* r = __cbeg_[hc] = (__c_node*)malloc(sizeof(__c_node)); if (__cbeg_[hc] == nullptr) +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); +#else + abort(); +#endif r->__c_ = __c; r->__next_ = p; ++__csz_; @@ -182,7 +188,7 @@ __libcpp_db::__erase_i(void* __i) WLock _(mut()); if (__ibeg_ != __iend_) { - size_t hi = hash<void*>()(__i) % (__iend_ - __ibeg_); + size_t hi = hash<void*>()(__i) % static_cast<size_t>(__iend_ - __ibeg_); __i_node* p = __ibeg_[hi]; if (p != nullptr) { @@ -211,7 +217,7 @@ void __libcpp_db::__invalidate_all(void* __c) { WLock _(mut()); - size_t hc = hash<void*>()(__c) % (__cend_ - __cbeg_); + size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); __c_node* p = __cbeg_[hc]; _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __invalidate_all A"); while (p->__c_ != __c) @@ -230,7 +236,7 @@ __c_node* __libcpp_db::__find_c_and_lock(void* __c) const { mut().lock(); - size_t hc = hash<void*>()(__c) % (__cend_ - __cbeg_); + size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); __c_node* p = __cbeg_[hc]; _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c_and_lock A"); while (p->__c_ != __c) @@ -241,6 +247,20 @@ __libcpp_db::__find_c_and_lock(void* __c) const return p; } +__c_node* +__libcpp_db::__find_c(void* __c) const +{ + size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); + __c_node* p = __cbeg_[hc]; + _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c A"); + while (p->__c_ != __c) + { + p = p->__next_; + _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c B"); + } + return p; +} + void __libcpp_db::unlock() const { @@ -251,7 +271,7 @@ void __libcpp_db::__erase_c(void* __c) { WLock _(mut()); - size_t hc = hash<void*>()(__c) % (__cend_ - __cbeg_); + size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); __c_node* p = __cbeg_[hc]; __c_node* q = nullptr; _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c A"); @@ -348,7 +368,7 @@ void __libcpp_db::swap(void* c1, void* c2) { WLock _(mut()); - size_t hc = hash<void*>()(c1) % (__cend_ - __cbeg_); + size_t hc = hash<void*>()(c1) % static_cast<size_t>(__cend_ - __cbeg_); __c_node* p1 = __cbeg_[hc]; _LIBCPP_ASSERT(p1 != nullptr, "debug mode internal logic error swap A"); while (p1->__c_ != c1) @@ -356,7 +376,7 @@ __libcpp_db::swap(void* c1, void* c2) p1 = p1->__next_; _LIBCPP_ASSERT(p1 != nullptr, "debug mode internal logic error swap B"); } - hc = hash<void*>()(c2) % (__cend_ - __cbeg_); + hc = hash<void*>()(c2) % static_cast<size_t>(__cend_ - __cbeg_); __c_node* p2 = __cbeg_[hc]; _LIBCPP_ASSERT(p2 != nullptr, "debug mode internal logic error swap C"); while (p2->__c_ != c2) @@ -380,18 +400,47 @@ __libcpp_db::__insert_i(void* __i) __insert_iterator(__i); } +void +__c_node::__add(__i_node* i) +{ + if (end_ == cap_) + { + size_t nc = 2*static_cast<size_t>(cap_ - beg_); + if (nc == 0) + nc = 1; + __i_node** beg = (__i_node**)malloc(nc * sizeof(__i_node*)); + if (beg == nullptr) +#ifndef _LIBCPP_NO_EXCEPTIONS + throw bad_alloc(); +#else + abort(); +#endif + if (nc > 1) + memcpy(beg, beg_, nc/2*sizeof(__i_node*)); + free(beg_); + beg_ = beg; + end_ = beg_ + nc/2; + cap_ = beg_ + nc; + } + *end_++ = i; +} + // private api _LIBCPP_HIDDEN __i_node* __libcpp_db::__insert_iterator(void* __i) { - if (__isz_ + 1 > __iend_ - __ibeg_) + if (__isz_ + 1 > static_cast<size_t>(__iend_ - __ibeg_)) { - size_t nc = __next_prime(2*(__iend_ - __ibeg_) + 1); + size_t nc = __next_prime(2*static_cast<size_t>(__iend_ - __ibeg_) + 1); __i_node** ibeg = (__i_node**)calloc(nc, sizeof(void*)); if (ibeg == nullptr) +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); +#else + abort(); +#endif for (__i_node** p = __ibeg_; p != __iend_; ++p) { __i_node* q = *p; @@ -408,11 +457,15 @@ __libcpp_db::__insert_iterator(void* __i) __ibeg_ = ibeg; __iend_ = __ibeg_ + nc; } - size_t hi = hash<void*>()(__i) % (__iend_ - __ibeg_); + size_t hi = hash<void*>()(__i) % static_cast<size_t>(__iend_ - __ibeg_); __i_node* p = __ibeg_[hi]; __i_node* r = __ibeg_[hi] = (__i_node*)malloc(sizeof(__i_node)); if (r == nullptr) +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); +#else + abort(); +#endif ::new(r) __i_node(__i, p, nullptr); ++__isz_; return r; @@ -425,7 +478,7 @@ __libcpp_db::__find_iterator(const void* __i) const __i_node* r = nullptr; if (__ibeg_ != __iend_) { - size_t h = hash<const void*>()(__i) % (__iend_ - __ibeg_); + size_t h = hash<const void*>()(__i) % static_cast<size_t>(__iend_ - __ibeg_); for (__i_node* nd = __ibeg_[h]; nd != nullptr; nd = nd->__next_) { if (nd->__i_ == __i) @@ -440,34 +493,12 @@ __libcpp_db::__find_iterator(const void* __i) const _LIBCPP_HIDDEN void -__c_node::__add(__i_node* i) -{ - if (end_ == cap_) - { - size_t nc = 2*(cap_ - beg_); - if (nc == 0) - nc = 1; - __i_node** beg = (__i_node**)malloc(nc * sizeof(__i_node*)); - if (beg == nullptr) - throw bad_alloc(); - if (nc > 1) - memcpy(beg, beg_, nc/2*sizeof(__i_node*)); - free(beg_); - beg_ = beg; - end_ = beg_ + nc/2; - cap_ = beg_ + nc; - } - *end_++ = i; -} - -_LIBCPP_HIDDEN -void __c_node::__remove(__i_node* p) { __i_node** r = find(beg_, end_, p); _LIBCPP_ASSERT(r != end_, "debug mode internal logic error __c_node::__remove"); if (--end_ != r) - memmove(r, r+1, (end_ - r)*sizeof(__i_node*)); + memmove(r, r+1, static_cast<size_t>(end_ - r)*sizeof(__i_node*)); } _LIBCPP_END_NAMESPACE_STD diff --git a/system/lib/libcxx/exception.cpp b/system/lib/libcxx/exception.cpp index cba355e9..8d5ded4d 100644 --- a/system/lib/libcxx/exception.cpp +++ b/system/lib/libcxx/exception.cpp @@ -10,69 +10,83 @@ #include "exception" +#ifndef __has_include +#define __has_include(inc) 0 +#endif + #if __APPLE__ #include <cxxabi.h> + using namespace __cxxabiv1; - using namespace __cxxabiapple; - // On Darwin, there are two STL shared libraries and a lower level ABI - // shared libray. The globals holding the current terminate handler and - // current unexpe |