[libcxx-commits] [libcxx] [z/OS][libc++] Guard to be used only when they are available (PR #114396)

Zibi Sarbinowski via libcxx-commits libcxx-commits at lists.llvm.org
Thu Oct 31 05:10:37 PDT 2024


https://github.com/zibi2 created https://github.com/llvm/llvm-project/pull/114396

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)}));
# |       |                                                                                 ^
```

>From a83b5caf569b1aabfe347f5d84f6a2c9f518333e Mon Sep 17 00:00:00 2001
From: Zbigniew Sarbinowski <zibi at ca.ibm.com>
Date: Thu, 31 Oct 2024 12:08:18 +0000
Subject: [PATCH] Guard  to be used only when they are available

---
 libcxx/include/__utility/small_buffer.h | 4 ++++
 1 file changed, 4 insertions(+)

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) {



More information about the libcxx-commits mailing list