diff options
author | Patrick Wildt <patrick@cvs.openbsd.org> | 2021-01-02 21:18:30 +0000 |
---|---|---|
committer | Patrick Wildt <patrick@cvs.openbsd.org> | 2021-01-02 21:18:30 +0000 |
commit | 56b1434af462e273419ba9d9e1c193ec19eb08a2 (patch) | |
tree | c2d57d922a632cf47af02235f148c3777ea30c1c /gnu | |
parent | b9651be46dbe82d518c8394f8676b32711527d1b (diff) |
Re-apply our libc++ 8.0.0 patches to libc++ 10.0.1.
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/llvm/libcxx/include/__config | 22 | ||||
-rw-r--r-- | gnu/llvm/libcxx/include/__locale | 2 | ||||
-rw-r--r-- | gnu/llvm/libcxx/include/locale | 6 | ||||
-rw-r--r-- | gnu/llvm/libcxx/include/stdio.h | 2 | ||||
-rw-r--r-- | gnu/llvm/libcxx/include/support/newlib/xlocale.h | 6 | ||||
-rw-r--r-- | gnu/llvm/libcxx/src/random.cpp | 5 | ||||
-rw-r--r-- | gnu/llvm/libcxx/src/thread.cpp | 4 |
7 files changed, 35 insertions, 12 deletions
diff --git a/gnu/llvm/libcxx/include/__config b/gnu/llvm/libcxx/include/__config index ccce227f4d6..f683a4bbfb8 100644 --- a/gnu/llvm/libcxx/include/__config +++ b/gnu/llvm/libcxx/include/__config @@ -262,6 +262,15 @@ # endif // _BYTE_ORDER == _LITTLE_ENDIAN #endif // __NetBSD__ +#ifdef __OpenBSD__ +# include <sys/_endian.h> +# if _BYTE_ORDER == _LITTLE_ENDIAN +# define _LIBCPP_LITTLE_ENDIAN +# else // _BYTE_ORDER == _LITTLE_ENDIAN +# define _LIBCPP_BIG_ENDIAN +# endif // _BYTE_ORDER == _LITTLE_ENDIAN +#endif // __OpenBSD__ + #if defined(_WIN32) # define _LIBCPP_WIN32API # define _LIBCPP_LITTLE_ENDIAN @@ -301,7 +310,7 @@ # endif #endif // __sun__ -#if defined(__CloudABI__) +#if defined(__CloudABI__) || defined(__OpenBSD__) // Certain architectures provide arc4random(). Prefer using // arc4random() over /dev/{u,}random to make it possible to obtain // random data even when using sandboxing mechanisms such as chroots, @@ -357,6 +366,10 @@ # if __ANDROID_API__ >= 29 # define _LIBCPP_HAS_TIMESPEC_GET # endif +# elif defined(__OpenBSD__) +# define _LIBCPP_HAS_ALIGNED_ALLOC +# define _LIBCPP_HAS_TIMESPEC_GET +# define _LIBCPP_HAS_C11_FEATURES # elif defined(__Fuchsia__) || defined(__wasi__) || defined(__NetBSD__) # define _LIBCPP_HAS_ALIGNED_ALLOC # define _LIBCPP_HAS_QUICK_EXIT @@ -1122,7 +1135,8 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( defined(__APPLE__) || \ defined(__CloudABI__) || \ defined(__sun__) || \ - (defined(__MINGW32__) && __has_include(<pthread.h>)) + (defined(__MINGW32__) && __has_include(<pthread.h>)) || \ + defined(__OpenBSD__) # define _LIBCPP_HAS_THREAD_API_PTHREAD # elif defined(__Fuchsia__) # define _LIBCPP_HAS_THREAD_API_C11 @@ -1212,13 +1226,13 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( // Some systems do not provide gets() in their C library, for security reasons. #ifndef _LIBCPP_C_HAS_NO_GETS -# if defined(_LIBCPP_MSVCRT) || \ +# if defined(_LIBCPP_MSVCRT) || defined(__OpenBSD__) || \ (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) # define _LIBCPP_C_HAS_NO_GETS # endif #endif -#if defined(__BIONIC__) || defined(__CloudABI__) || \ +#if defined(__BIONIC__) || defined(__CloudABI__) || defined(__OpenBSD__) || \ defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC) #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE #endif diff --git a/gnu/llvm/libcxx/include/__locale b/gnu/llvm/libcxx/include/__locale index 2b6982fc681..02ffbb1d1e9 100644 --- a/gnu/llvm/libcxx/include/__locale +++ b/gnu/llvm/libcxx/include/__locale @@ -28,7 +28,7 @@ #elif defined(__sun__) # include <xlocale.h> # include <support/solaris/xlocale.h> -#elif defined(_NEWLIB_VERSION) +#elif defined(_NEWLIB_VERSION) || defined(__OpenBSD__) # include <support/newlib/xlocale.h> #elif (defined(__APPLE__) || defined(__FreeBSD__) \ || defined(__EMSCRIPTEN__) || defined(__IBMCPP__)) diff --git a/gnu/llvm/libcxx/include/locale b/gnu/llvm/libcxx/include/locale index 3fe44300227..f004ae3ddcf 100644 --- a/gnu/llvm/libcxx/include/locale +++ b/gnu/llvm/libcxx/include/locale @@ -1571,7 +1571,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); else __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v); - if (__nb == 0) + if (__nc == -1) __throw_bad_alloc(); __nbh.reset(__nb); } @@ -1622,7 +1622,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); else __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v); - if (__nb == 0) + if (__nc == -1) __throw_bad_alloc(); __nbh.reset(__nb); } @@ -3403,7 +3403,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl, if (__n > __bs-1) { __n = static_cast<size_t>(__libcpp_asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units)); - if (__bb == 0) + if (__n == -1) __throw_bad_alloc(); __hn.reset(__bb); __hd.reset((char_type*)malloc(__n * sizeof(char_type))); diff --git a/gnu/llvm/libcxx/include/stdio.h b/gnu/llvm/libcxx/include/stdio.h index e08e6bc9b69..2790c4b6bcc 100644 --- a/gnu/llvm/libcxx/include/stdio.h +++ b/gnu/llvm/libcxx/include/stdio.h @@ -113,6 +113,8 @@ void perror(const char* s); #undef clearerr #undef feof #undef ferror +#undef putchar +#undef getchar #endif diff --git a/gnu/llvm/libcxx/include/support/newlib/xlocale.h b/gnu/llvm/libcxx/include/support/newlib/xlocale.h index 25fa798b6d0..9975eb6eb7e 100644 --- a/gnu/llvm/libcxx/include/support/newlib/xlocale.h +++ b/gnu/llvm/libcxx/include/support/newlib/xlocale.h @@ -9,18 +9,20 @@ #ifndef _LIBCPP_SUPPORT_NEWLIB_XLOCALE_H #define _LIBCPP_SUPPORT_NEWLIB_XLOCALE_H -#if defined(_NEWLIB_VERSION) +#if defined(_NEWLIB_VERSION) || defined(__OpenBSD__) #include <cstdlib> #include <clocale> #include <cwctype> #include <ctype.h> +#if !defined(__OpenBSD__) #if !defined(__NEWLIB__) || __NEWLIB__ < 2 || \ __NEWLIB__ == 2 && __NEWLIB_MINOR__ < 5 #include <support/xlocale/__nop_locale_mgmt.h> #include <support/xlocale/__posix_l_fallback.h> -#include <support/xlocale/__strtonum_fallback.h> #endif +#endif +#include <support/xlocale/__strtonum_fallback.h> #endif // _NEWLIB_VERSION diff --git a/gnu/llvm/libcxx/src/random.cpp b/gnu/llvm/libcxx/src/random.cpp index 04adc59f9bc..29f6428a65e 100644 --- a/gnu/llvm/libcxx/src/random.cpp +++ b/gnu/llvm/libcxx/src/random.cpp @@ -33,6 +33,7 @@ #include <nacl/nacl_random.h> #endif +#include <limits> _LIBCPP_BEGIN_NAMESPACE_STD @@ -172,7 +173,11 @@ random_device::operator()() double random_device::entropy() const _NOEXCEPT { +#ifdef __OpenBSD__ + return std::numeric_limits<unsigned int>::digits; +#else return 0; +#endif } _LIBCPP_END_NAMESPACE_STD diff --git a/gnu/llvm/libcxx/src/thread.cpp b/gnu/llvm/libcxx/src/thread.cpp index c0bc1cbbbbc..1f4ad71042b 100644 --- a/gnu/llvm/libcxx/src/thread.cpp +++ b/gnu/llvm/libcxx/src/thread.cpp @@ -80,9 +80,9 @@ thread::detach() unsigned thread::hardware_concurrency() _NOEXCEPT { -#if defined(CTL_HW) && defined(HW_NCPU) +#if defined(CTL_HW) && defined(HW_NCPUONLINE) unsigned n; - int mib[2] = {CTL_HW, HW_NCPU}; + int mib[2] = {CTL_HW, HW_NCPUONLINE}; std::size_t s = sizeof(n); sysctl(mib, 2, &n, &s, 0, 0); return n; |