]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/asio/detail/handler_alloc_helpers.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / asio / detail / handler_alloc_helpers.hpp
index 4d713940afce96e5e23aa569b8bebbefea365508..5d127b70fa9df55e1b26a0cdcdf8298058170ec3 100644 (file)
@@ -2,7 +2,7 @@
 // detail/handler_alloc_helpers.hpp
 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 //
-// Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
 //
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -51,21 +51,24 @@ inline void error_if_hooks_are_defined(Handler& h)
 #endif // defined(BOOST_ASIO_NO_DEPRECATED)
 
 template <typename Handler>
-inline void* allocate(std::size_t s, Handler& h)
+inline void* allocate(std::size_t s, Handler& h,
+    std::size_t align = BOOST_ASIO_DEFAULT_ALIGN)
 {
 #if !defined(BOOST_ASIO_HAS_HANDLER_HOOKS)
-  return ::operator new(s);
+  return aligned_new(align, s);
 #elif defined(BOOST_ASIO_NO_DEPRECATED)
   // The asio_handler_allocate hook is no longer used to obtain memory.
   (void)&error_if_hooks_are_defined<Handler>;
   (void)h;
-#if !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
+# if !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
   return boost::asio::detail::thread_info_base::allocate(
-      boost::asio::detail::thread_context::thread_call_stack::top(), s);
-#else // !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
-  return ::operator new(size);
-#endif // !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
+      boost::asio::detail::thread_context::top_of_thread_call_stack(),
+      s, align);
+# else // !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
+  return aligned_new(align, s);
+# endif // !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
 #else
+  (void)align;
   using boost::asio::asio_handler_allocate;
   return asio_handler_allocate(s, boost::asio::detail::addressof(h));
 #endif
@@ -75,17 +78,17 @@ template <typename Handler>
 inline void deallocate(void* p, std::size_t s, Handler& h)
 {
 #if !defined(BOOST_ASIO_HAS_HANDLER_HOOKS)
-  ::operator delete(p);
+  aligned_delete(p);
 #elif defined(BOOST_ASIO_NO_DEPRECATED)
   // The asio_handler_allocate hook is no longer used to obtain memory.
   (void)&error_if_hooks_are_defined<Handler>;
   (void)h;
 #if !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
   boost::asio::detail::thread_info_base::deallocate(
-      boost::asio::detail::thread_context::thread_call_stack::top(), p, s);
+      boost::asio::detail::thread_context::top_of_thread_call_stack(), p, s);
 #else // !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
   (void)s;
-  ::operator delete(p);
+  aligned_delete(p);
 #endif // !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
 #else
   using boost::asio::asio_handler_deallocate;
@@ -125,7 +128,8 @@ public:
   T* allocate(std::size_t n)
   {
     return static_cast<T*>(
-        boost_asio_handler_alloc_helpers::allocate(sizeof(T) * n, handler_));
+        boost_asio_handler_alloc_helpers::allocate(
+          sizeof(T) * n, handler_, BOOST_ASIO_ALIGNOF(T)));
   }
 
   void deallocate(T* p, std::size_t n)