]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: avoid using std::aligned_storage_t 64042/head
authorKefu Chai <tchaikov@gmail.com>
Thu, 19 Jun 2025 10:04:05 +0000 (18:04 +0800)
committerKefu Chai <tchaikov@gmail.com>
Thu, 19 Jun 2025 10:09:50 +0000 (18:09 +0800)
std::aligned_storage_t was deprecated in C++23, to be prepared for it,
let's use alignas for the same behavior. because the 3 * 8 (with LP64
data model) is not power-of-2, while `alignas()` requires an alignment
of power of 2. so we use `std::bit_ceil()` to calculate the minimum
alignment greater or equal to this number.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/rgw/rgw_aio.h

index 0b4ce71ca3f664eb13c1ccfeb33cd0960664110f..4f6301c8f84f968e350585e42e209d9f71129a83 100644 (file)
@@ -15,9 +15,9 @@
 
 #pragma once
 
+#include <bit>
 #include <cstdint>
 #include <memory>
-#include <type_traits>
 
 #include <boost/intrusive/list.hpp>
 #include "include/rados/librados_fwd.hpp"
@@ -40,7 +40,10 @@ struct AioResult {
   uint64_t id = 0; // id allows caller to associate a result with its request
   bufferlist data; // result buffer for reads
   int result = 0;
-  std::aligned_storage_t<3 * sizeof(void*)> user_data;
+  static constexpr size_t user_data_alignment = std::bit_ceil(3 * sizeof(void*));
+  struct alignas(user_data_alignment) {
+      unsigned char data[user_data_alignment];
+  } user_data;
 
   AioResult() = default;
   AioResult(const AioResult&) = delete;