[libcxx-commits] [libcxx] [z/OS][libc++] Guard to be used only when they are available (PR #114396)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Oct 31 05:11:12 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Zibi Sarbinowski (zibi2)
<details>
<summary>Changes</summary>
We need to guard 2 functions to avoid errors when `small_buffer.h` is included in the modules LIT tests. For example:
```
test-suite-install/include/c++/v1/__utility/small_buffer.h:69:81: error: use of undeclared identifier 'align_val_t'
# | 69 | byte* __allocation = static_cast<byte*>(::operator new[](sizeof(_Stored), align_val_t{alignof(_Stored)}));
# | | ^
```
---
Full diff: https://github.com/llvm/llvm-project/pull/114396.diff
1 Files Affected:
- (modified) libcxx/include/__utility/small_buffer.h (+4)
``````````diff
diff --git a/libcxx/include/__utility/small_buffer.h b/libcxx/include/__utility/small_buffer.h
index 70e068f89f62ed..6071bda4513657 100644
--- a/libcxx/include/__utility/small_buffer.h
+++ b/libcxx/include/__utility/small_buffer.h
@@ -61,6 +61,7 @@ class __small_buffer {
return *std::launder(reinterpret_cast<_Stored**>(__buffer_));
}
+# ifdef _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION
template <class _Stored>
_LIBCPP_HIDE_FROM_ABI _Stored* __alloc() {
if constexpr (__fits_in_buffer<_Stored>) {
@@ -72,11 +73,14 @@ class __small_buffer {
}
}
+# endif // _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION
+# ifdef _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION
template <class _Stored>
_LIBCPP_HIDE_FROM_ABI void __dealloc() noexcept {
if constexpr (!__fits_in_buffer<_Stored>)
::operator delete[](*reinterpret_cast<void**>(__buffer_), sizeof(_Stored), align_val_t{alignof(_Stored)});
}
+# endif // _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION
template <class _Stored, class... _Args>
_LIBCPP_HIDE_FROM_ABI void __construct(_Args&&... __args) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/114396
More information about the libcxx-commits
mailing list