Skip to content

Commit

Permalink
Merge (potential) fix for apple (#482)
Browse files Browse the repository at this point in the history
Bench 7571218
  • Loading branch information
cj5716 authored Nov 4, 2024
1 parent bbad907 commit 6058495
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ttable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#if defined(__linux__) && !defined(__ANDROID__)
#include <sys/mman.h>
#define USE_MADVISE
#elif defined(__APPLE__)
#define USE_POSIX_MEMALIGN
#else
#include <stdlib.h>
#endif
Expand All @@ -20,13 +22,17 @@ TTable TT;
void* AlignedMalloc(size_t size, size_t alignment) {
#if defined(USE_MADVISE)
return aligned_alloc(alignment, size);
#elif defined(USE_POSIX_MEMALIGN)
void* mem = nullptr;
posix_memalign(&mem, alignment, size);
return mem;
#else
return _aligned_malloc(size, alignment);
#endif
}

void AlignedFree(void *src) {
#if defined(USE_MADVISE)
#if defined(USE_MADVISE) || defined(USE_POSIX_MEMALIGN)
free(src);
#else
_aligned_free(src);
Expand Down

0 comments on commit 6058495

Please sign in to comment.