Skip to content

Commit

Permalink
replace posix_memalign with aligned_alloc
Browse files Browse the repository at this point in the history
We can do this now that C++17 is available.

Signed-off-by: Rosen Penev <[email protected]>
  • Loading branch information
neheb committed Jan 14, 2025
1 parent acb06f7 commit 0de2039
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
2 changes: 0 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ LIBS="$PTHREAD_LIBS $ZLIB_LIBS $LIBS"
TORRENT_ARG_OPENSSL
TORRENT_ARG_CYRUS_RC4

AC_CHECK_FUNCS(posix_memalign)

TORRENT_CHECK_MADVISE
TORRENT_CHECK_CACHELINE
TORRENT_CHECK_POPCOUNT
Expand Down
5 changes: 1 addition & 4 deletions rak/allocators.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ class cacheline_allocator {
pointer allocate(size_type num, const_void_pointer hint = 0) { return alloc_size(num*sizeof(T)); }

static pointer alloc_size(size_type size) {
pointer ptr = NULL;
[[maybe_unused]] int result = posix_memalign((void**)&ptr, LT_SMP_CACHE_BYTES, size);

return ptr;
return static_cast<pointer>(std::aligned_alloc(LT_SMP_CACHE_BYTES, size));
}

void construct (pointer p, const T& value) { new((void*)p)T(value); }
Expand Down

0 comments on commit 0de2039

Please sign in to comment.