diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-04-26 15:33:29 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-05-08 19:37:29 -0700 |
| commit | 06ee65af9ed6aa5ee4d1d7f4fab9d7acecf66e76 (patch) | |
| tree | 1316711b92a43dd5c599e425b8693fa8e1e0c0b7 /lib/libcxx/src/include/sso_allocator.h | |
| parent | bc6ebc6f2597fda1f98842c6f545751fef2a5334 (diff) | |
| download | zig-06ee65af9ed6aa5ee4d1d7f4fab9d7acecf66e76.tar.gz zig-06ee65af9ed6aa5ee4d1d7f4fab9d7acecf66e76.zip | |
libcxx: update to LLVM 18
release/18.x branch, commit 78b99c73ee4b96fe9ce0e294d4632326afb2db42
This adds the flag `-D_LIBCPP_HARDENING_MODE` which is determined based
on the Zig optimization mode.
This commit also fixes libunwind, libcxx, and libcxxabi to properly
report sub compilation errors.
Diffstat (limited to 'lib/libcxx/src/include/sso_allocator.h')
| -rw-r--r-- | lib/libcxx/src/include/sso_allocator.h | 82 |
1 files changed, 40 insertions, 42 deletions
diff --git a/lib/libcxx/src/include/sso_allocator.h b/lib/libcxx/src/include/sso_allocator.h index 6a682fc43f..4e6761c580 100644 --- a/lib/libcxx/src/include/sso_allocator.h +++ b/lib/libcxx/src/include/sso_allocator.h @@ -11,70 +11,68 @@ #define _LIBCPP_SSO_ALLOCATOR_H #include <__config> +#include <cstddef> #include <memory> #include <new> #include <type_traits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header +# pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -template <class _Tp, size_t _Np> class _LIBCPP_HIDDEN __sso_allocator; +template <class _Tp, size_t _Np> +class _LIBCPP_HIDDEN __sso_allocator; template <size_t _Np> -class _LIBCPP_HIDDEN __sso_allocator<void, _Np> -{ +class _LIBCPP_HIDDEN __sso_allocator<void, _Np> { public: - typedef const void* const_pointer; - typedef void value_type; + typedef const void* const_pointer; + typedef void value_type; }; template <class _Tp, size_t _Np> -class _LIBCPP_HIDDEN __sso_allocator -{ - typename aligned_storage<sizeof(_Tp) * _Np>::type buf_; - bool __allocated_; +class _LIBCPP_HIDDEN __sso_allocator { + alignas(_Tp) std::byte buf_[sizeof(_Tp) * _Np]; + bool __allocated_; + public: - typedef size_t size_type; - typedef _Tp* pointer; - typedef _Tp value_type; + typedef size_t size_type; + typedef _Tp* pointer; + typedef _Tp value_type; + + template <class U> + struct rebind { + using other = __sso_allocator<U, _Np>; + }; - template <class U> - struct rebind { - using other = __sso_allocator<U, _Np>; - }; + _LIBCPP_HIDE_FROM_ABI __sso_allocator() throw() : __allocated_(false) {} + _LIBCPP_HIDE_FROM_ABI __sso_allocator(const __sso_allocator&) throw() : __allocated_(false) {} + template <class _Up> + _LIBCPP_HIDE_FROM_ABI __sso_allocator(const __sso_allocator<_Up, _Np>&) throw() : __allocated_(false) {} - _LIBCPP_INLINE_VISIBILITY __sso_allocator() throw() : __allocated_(false) {} - _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator&) throw() : __allocated_(false) {} - template <class _Up> _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator<_Up, _Np>&) throw() - : __allocated_(false) {} private: - __sso_allocator& operator=(const __sso_allocator&); + __sso_allocator& operator=(const __sso_allocator&); + public: - _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, typename __sso_allocator<void, _Np>::const_pointer = nullptr) - { - if (!__allocated_ && __n <= _Np) - { - __allocated_ = true; - return (pointer)&buf_; - } - return allocator<_Tp>().allocate(__n); - } - _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type __n) - { - if (__p == (pointer)&buf_) - __allocated_ = false; - else - allocator<_Tp>().deallocate(__p, __n); + _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n, typename __sso_allocator<void, _Np>::const_pointer = nullptr) { + if (!__allocated_ && __n <= _Np) { + __allocated_ = true; + return (pointer)&buf_; } - _LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);} + return allocator<_Tp>().allocate(__n); + } + _LIBCPP_HIDE_FROM_ABI void deallocate(pointer __p, size_type __n) { + if (__p == (pointer)&buf_) + __allocated_ = false; + else + allocator<_Tp>().deallocate(__p, __n); + } + _LIBCPP_HIDE_FROM_ABI size_type max_size() const throw() { return size_type(~0) / sizeof(_Tp); } - _LIBCPP_INLINE_VISIBILITY - bool operator==(const __sso_allocator& __a) const {return &buf_ == &__a.buf_;} - _LIBCPP_INLINE_VISIBILITY - bool operator!=(const __sso_allocator& __a) const {return &buf_ != &__a.buf_;} + _LIBCPP_HIDE_FROM_ABI bool operator==(const __sso_allocator& __a) const { return &buf_ == &__a.buf_; } + _LIBCPP_HIDE_FROM_ABI bool operator!=(const __sso_allocator& __a) const { return &buf_ != &__a.buf_; } }; _LIBCPP_END_NAMESPACE_STD |
