diff options
author | 2018-09-11 18:29:53 +0000 | |
---|---|---|
committer | 2018-09-11 18:29:53 +0000 | |
commit | e933dfd56b2b1c88c8dcf4c47d7dabd4706764dd (patch) | |
tree | cd7e74d77951b26255308bb3b085180d83504687 /lib/libcxx/src | |
parent | import of libc++ 6.0.0 (diff) | |
download | wireguard-openbsd-e933dfd56b2b1c88c8dcf4c47d7dabd4706764dd.tar.xz wireguard-openbsd-e933dfd56b2b1c88c8dcf4c47d7dabd4706764dd.zip |
merge libc++ 6.0.0 (bump lib major); ok patrick@, kettenis@
Diffstat (limited to 'lib/libcxx/src')
-rw-r--r-- | lib/libcxx/src/debug.cpp | 1 | ||||
-rw-r--r-- | lib/libcxx/src/support/solaris/xlocale.c | 66 | ||||
-rw-r--r-- | lib/libcxx/src/thread.cpp | 52 |
3 files changed, 18 insertions, 101 deletions
diff --git a/lib/libcxx/src/debug.cpp b/lib/libcxx/src/debug.cpp index f2fc1ceb495..c0739275d96 100644 --- a/lib/libcxx/src/debug.cpp +++ b/lib/libcxx/src/debug.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_DEBUG 1 #include "__config" #include "__debug" #include "functional" diff --git a/lib/libcxx/src/support/solaris/xlocale.c b/lib/libcxx/src/support/solaris/xlocale.c deleted file mode 100644 index 9125eea7377..00000000000 --- a/lib/libcxx/src/support/solaris/xlocale.c +++ /dev/null @@ -1,66 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifdef __sun__ - -#include "support/solaris/xlocale.h" -#include <stdarg.h> -#include <stdio.h> -#include <sys/localedef.h> - - -int isxdigit_l(int __c, locale_t __l) { - return isxdigit(__c); -} - -int iswxdigit_l(wchar_t __c, locale_t __l) { - return isxdigit(__c); -} - -// FIXME: This disregards the locale, which is Very Wrong -#define vsnprintf_l(__s, __n, __l, __format, __va) \ - vsnprintf(__s, __n, __format, __va) - -int snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...) -{ - va_list __va; - va_start(__va, __format); - int __res = vsnprintf_l(__s, __n , __l, __format, __va); - va_end(__va); - return __res; -} - -int asprintf_l(char **__s, locale_t __l, const char *__format, ...) { - va_list __va; - va_start(__va, __format); - // FIXME: - int __res = vasprintf(__s, __format, __va); - va_end(__va); - return __res; -} - -int sscanf_l(const char *__s, locale_t __l, const char *__format, ...) { - va_list __va; - va_start(__va, __format); - // FIXME: - int __res = vsscanf(__s, __format, __va); - va_end(__va); - return __res; -} - -size_t mbrtowc_l(wchar_t *__pwc, const char *__pmb, - size_t __max, mbstate_t *__ps, locale_t __loc) { - return mbrtowc(__pwc, __pmb, __max, __ps); -} - -struct lconv *localeconv_l(locale_t __l) { - return localeconv(); -} - -#endif // __sun__ diff --git a/lib/libcxx/src/thread.cpp b/lib/libcxx/src/thread.cpp index d4977cd9a73..62b8e9cb8b4 100644 --- a/lib/libcxx/src/thread.cpp +++ b/lib/libcxx/src/thread.cpp @@ -24,14 +24,15 @@ # endif // defined(BSD) #endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) -#if !defined(_WIN32) +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__CloudABI__) || defined(__Fuchsia__) # include <unistd.h> -#endif // !_WIN32 +#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__CloudABI__) || defined(__Fuchsia__) #if defined(__NetBSD__) #pragma weak pthread_create // Do not create libpthread dependency #endif -#if defined(_WIN32) + +#if defined(_LIBCPP_WIN32API) #include <windows.h> #endif @@ -39,7 +40,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD thread::~thread() { - if (__t_ != 0) + if (!__libcpp_thread_isnull(&__t_)) terminate(); } @@ -47,32 +48,30 @@ void thread::join() { int ec = EINVAL; - if (__t_ != 0) + if (!__libcpp_thread_isnull(&__t_)) { ec = __libcpp_thread_join(&__t_); if (ec == 0) - __t_ = 0; + __t_ = _LIBCPP_NULL_THREAD; } -#ifndef _LIBCPP_NO_EXCEPTIONS + if (ec) - throw system_error(error_code(ec, system_category()), "thread::join failed"); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_system_error(ec, "thread::join failed"); } void thread::detach() { int ec = EINVAL; - if (__t_ != 0) + if (!__libcpp_thread_isnull(&__t_)) { ec = __libcpp_thread_detach(&__t_); if (ec == 0) - __t_ = 0; + __t_ = _LIBCPP_NULL_THREAD; } -#ifndef _LIBCPP_NO_EXCEPTIONS + if (ec) - throw system_error(error_code(ec, system_category()), "thread::detach failed"); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_system_error(ec, "thread::detach failed"); } unsigned @@ -93,14 +92,14 @@ thread::hardware_concurrency() _NOEXCEPT if (result < 0) return 0; return static_cast<unsigned>(result); -#elif defined(_WIN32) +#elif defined(_LIBCPP_WIN32API) SYSTEM_INFO info; GetSystemInfo(&info); return info.dwNumberOfProcessors; #else // defined(CTL_HW) && defined(HW_NCPU) // TODO: grovel through /proc or check cpuid on x86 and similar // instructions on other architectures. -# if defined(_MSC_VER) && ! defined(__clang__) +# if defined(_LIBCPP_WARNING) _LIBCPP_WARNING("hardware_concurrency not yet implemented") # else # warning hardware_concurrency not yet implemented @@ -115,26 +114,9 @@ namespace this_thread void sleep_for(const chrono::nanoseconds& ns) { - using namespace chrono; - if (ns > nanoseconds::zero()) + if (ns > chrono::nanoseconds::zero()) { - seconds s = duration_cast<seconds>(ns); - timespec ts; - 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)>((ns-s).count()); - } - else - { - ts.tv_sec = ts_sec_max; - ts.tv_nsec = giga::num - 1; - } - - while (nanosleep(&ts, &ts) == -1 && errno == EINTR) - ; + __libcpp_thread_sleep_for(ns); } } |