-
Notifications
You must be signed in to change notification settings - Fork 124
Expand file tree
/
Copy pathredirect.cc
More file actions
51 lines (42 loc) · 1.32 KB
/
redirect.cc
File metadata and controls
51 lines (42 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "snmalloc.h"
#define NAME(a) malloc_size_##a
#define STRINGIFY(a) a
#define NAME_STRING(a) NAME(a)
#ifdef WIN32
# define REDIRECT_MALLOC_SIZE(a, b) \
extern "C" void* NAME(a)(); \
__pragma(comment(linker, "/alternatename:##a=##b"))
#else
# define REDIRECT_MALLOC_SIZE(a, b) \
__attribute__((alias(#b))) extern "C" void* a()
#endif
#define DEFINE_MALLOC_SIZE(name, s) \
extern "C" void* name() \
{ \
return snmalloc::ThreadAlloc::get_noncachable()->template alloc<s>(); \
}
extern "C" void free_local_small(void* ptr)
{
if (snmalloc::Alloc::small_local_dealloc(ptr))
return;
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(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(align, size);
snmalloc::ThreadAlloc::get_noncachable()->dealloc(ptr, asize);
}
#include "generated.cc"