File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ #include " snmalloc.h"
2+
3+ #include < fstream>
4+ #include < iostream>
5+
6+ int main (int argc, char * argv[])
7+ {
8+ if (argc != 2 )
9+ {
10+ std::cerr << " Call with output file name" << std::endl;
11+ return 1 ;
12+ }
13+
14+ // open a file in write mode.
15+ ofstream outfile;
16+ outfile.open (argv[1 ]);
17+
18+ for (size_t size = 1024 ; size > 0 ; size -= 16 )
19+ {
20+ auto sizeclass = snmalloc::size_to_sizeclass (size);
21+ auto rsize = snmalloc::sizeclass_to_size (sizeclass);
22+ if (rsize == size)
23+ {
24+ outfile << " DEFINE_MALLOC_SIZE(malloc_size_" << size << " , " << size
25+ << " );" << std::endl;
26+ }
27+ else
28+ {
29+ outfile << " REDIRECT_MALLOC_SIZE(malloc_size_" << size << " , malloc_size_"
30+ << rsize << " );" << std::endl;
31+ }
32+ }
33+
34+ outfile.close ();
35+ }
Original file line number Diff line number Diff line change 1+
2+ #include " snmalloc.h"
3+
4+ #define NAME (a ) malloc_size_##a
5+ #define STRINGIFY (a ) a
6+ #define NAME_STRING (a ) NAME(a)
7+
8+ #ifdef WIN32
9+ # define REDIRECT_MALLOC_SIZE (a, b ) \
10+ extern " C" void * NAME (a)(); \
11+ __pragma (comment(linker, " /alternatename:malloc_size_##a=malloc_size_##b" ))
12+ #else
13+ # define REDIRECT_MALLOC_SIZE (a, b ) \
14+ __attribute__ ((alias(#b))) extern "C" void* a()
15+ #endif
16+
17+ #define DEFINE_MALLOC_SIZE (a, s ) \
18+ extern " C" void * a () \
19+ { \
20+ return snmalloc::ThreadAlloc::get_noncachable ()->template alloc <s>(); \
21+ }
22+
23+ #include " generated.cc"
You can’t perform that action at this time.
0 commit comments