Skip to content

Commit

Permalink
remove aligned storage, as it's deprecated in C++23
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Jul 20, 2024
1 parent 9aada93 commit d35c283
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 70 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ set(libtorrent_extensions_include_files

set(libtorrent_aux_include_files
alert_manager.hpp
aligned_storage.hpp
aligned_union.hpp
alloca.hpp
allocating_handler.hpp
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,6 @@ HEADERS = \
xml_parse.hpp \
\
aux_/alert_manager.hpp \
aux_/aligned_storage.hpp \
aux_/aligned_union.hpp \
aux_/alloca.hpp \
aux_/allocating_handler.hpp \
Expand Down
62 changes: 0 additions & 62 deletions include/libtorrent/aux_/aligned_storage.hpp

This file was deleted.

7 changes: 3 additions & 4 deletions include/libtorrent/aux_/allocating_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ POSSIBILITY OF SUCH DAMAGE.

#include "libtorrent/config.hpp"
#include "libtorrent/error_code.hpp"
#include "libtorrent/aux_/aligned_storage.hpp"

#include "libtorrent/debug.hpp" // for TORRENT_ASSERT

Expand Down Expand Up @@ -157,7 +156,7 @@ namespace libtorrent { namespace aux {
static constexpr std::size_t size = Size;
static constexpr HandlerName name = Name;

typename aux::aligned_storage<Size, alignof(std::max_align_t)>::type bytes;
alignas(alignof(std::max_align_t)) std::array<std::uint8_t, Size> bytes;
#if TORRENT_USE_ASSERTS
bool used = false;
#endif
Expand Down Expand Up @@ -225,7 +224,7 @@ namespace libtorrent { namespace aux {
#ifdef TORRENT_ASIO_DEBUGGING
record_handler_allocation<T>(static_cast<int>(Name), Size);
#endif
return reinterpret_cast<T*>(&m_storage->bytes);
return reinterpret_cast<T*>(m_storage->bytes.data());
}

void deallocate(T* ptr, std::size_t size)
Expand All @@ -235,7 +234,7 @@ namespace libtorrent { namespace aux {

TORRENT_ASSERT_VAL(size == 1, size);
TORRENT_ASSERT_VAL(sizeof(T) <= Size, sizeof(T));
TORRENT_ASSERT(ptr == reinterpret_cast<T*>(&m_storage->bytes));
TORRENT_ASSERT(ptr == reinterpret_cast<T*>(m_storage->bytes.data()));
TORRENT_ASSERT(m_storage->used);
#if TORRENT_USE_ASSERTS
m_storage->used = false;
Expand Down
4 changes: 2 additions & 2 deletions include/libtorrent/aux_/chained_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_CHAINED_BUFFER_HPP_INCLUDED

#include "libtorrent/config.hpp"
#include "libtorrent/aux_/aligned_storage.hpp"
#include "libtorrent/debug.hpp"
#include "libtorrent/aux_/buffer.hpp"

Expand Down Expand Up @@ -113,7 +112,8 @@ namespace aux {
#if TORRENT_CPP98_DEQUE
move_construct_holder_fun move_holder;
#endif
aux::aligned_storage<32>::type holder;
alignas(alignof(std::max_align_t)) std::array<std::uint8_t, 32> holder;

char* buf = nullptr; // the first byte of the buffer
int size = 0; // the total size of the buffer
int used_size = 0; // this is the number of bytes to send/receive
Expand Down

0 comments on commit d35c283

Please sign in to comment.