Skip to content

Commit

Permalink
Fix Windows Build
Browse files Browse the repository at this point in the history
Fix Align to be not a log size.
  • Loading branch information
mjp41 committed Feb 11, 2021
1 parent f132034 commit d2166fc
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/redirect/redirect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifdef WIN32
# define REDIRECT_MALLOC_SIZE(a, b) \
extern "C" void* NAME(a)(); \
__pragma(comment(linker, "/alternatename:malloc_size_##a=malloc_size_##b"))
__pragma(comment(linker, "/alternatename:##a=##b"))
#else
# define REDIRECT_MALLOC_SIZE(a, b) \
__attribute__((alias(#b))) extern "C" void* a()
Expand All @@ -27,20 +27,25 @@ extern "C" void free_local_small(void* ptr)
snmalloc::ThreadAlloc::get_noncachable()->small_local_dealloc_slow(ptr);
}

#ifdef WIN32
# define GENERATE_FREE_SIZE(a) \
extern "C" void* NAME(a)(); \
__pragma(comment(linker, "/alternatename:##a=free_local_small"))
#else
# define GENERATE_FREE_SIZE(a) \
__attribute__((alias("free_local_small"))) extern "C" void* a()
#endif

void* __stack_alloc_large(size_t size, size_t align)
{
size_t asize = snmalloc::aligned_size(1ULL << align, size);
size_t asize = snmalloc::aligned_size(align, size);
return snmalloc::ThreadAlloc::get_noncachable()->alloc(asize);
}

void __stack_free_large(void* ptr, size_t size, size_t align)
{
size_t asize = snmalloc::aligned_size(1ULL << align, size);
size_t asize = snmalloc::aligned_size(align, size);
snmalloc::ThreadAlloc::get_noncachable()->dealloc(ptr, asize);
}


#include "generated.cc"

0 comments on commit d2166fc

Please sign in to comment.