Skip to content

Commit d2166fc

Browse files
committed
Fix Windows Build
Fix Align to be not a log size.
1 parent f132034 commit d2166fc

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/redirect/redirect.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#ifdef WIN32
99
# define REDIRECT_MALLOC_SIZE(a, b) \
1010
extern "C" void* NAME(a)(); \
11-
__pragma(comment(linker, "/alternatename:malloc_size_##a=malloc_size_##b"))
11+
__pragma(comment(linker, "/alternatename:##a=##b"))
1212
#else
1313
# define REDIRECT_MALLOC_SIZE(a, b) \
1414
__attribute__((alias(#b))) extern "C" void* a()
@@ -27,20 +27,25 @@ extern "C" void free_local_small(void* ptr)
2727
snmalloc::ThreadAlloc::get_noncachable()->small_local_dealloc_slow(ptr);
2828
}
2929

30+
#ifdef WIN32
31+
# define GENERATE_FREE_SIZE(a) \
32+
extern "C" void* NAME(a)(); \
33+
__pragma(comment(linker, "/alternatename:##a=free_local_small"))
34+
#else
3035
# define GENERATE_FREE_SIZE(a) \
3136
__attribute__((alias("free_local_small"))) extern "C" void* a()
37+
#endif
3238

3339
void* __stack_alloc_large(size_t size, size_t align)
3440
{
35-
size_t asize = snmalloc::aligned_size(1ULL << align, size);
41+
size_t asize = snmalloc::aligned_size(align, size);
3642
return snmalloc::ThreadAlloc::get_noncachable()->alloc(asize);
3743
}
3844

3945
void __stack_free_large(void* ptr, size_t size, size_t align)
4046
{
41-
size_t asize = snmalloc::aligned_size(1ULL << align, size);
47+
size_t asize = snmalloc::aligned_size(align, size);
4248
snmalloc::ThreadAlloc::get_noncachable()->dealloc(ptr, asize);
4349
}
4450

45-
4651
#include "generated.cc"

0 commit comments

Comments
 (0)