Introduce header layering (#503)
See src/snmalloc/README.md for an explanation of the layers. Some other cleanups on the way: Fine-grained stats support is now gone. It's been broken for two years, it depends on iostream (which then causes linker failures with libstdc++) and it's collecting the wrong stats for the new design. After discussion with @mjp41, it's better to remove it and introduce new stats support later, rather than keep broken code in the main branch. Tracing was controlled with a preprocessor macro, now there's also a CMake option.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <snmalloc.h>
|
||||
#include <snmalloc/snmalloc.h>
|
||||
#include <test/setup.h>
|
||||
|
||||
void test_ctz()
|
||||
@@ -41,4 +41,4 @@ int main(int argc, char** argv)
|
||||
|
||||
test_clz();
|
||||
test_ctz();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ int main()
|
||||
|
||||
// # define SNMALLOC_TRACING
|
||||
|
||||
# include <backend/backend.h>
|
||||
# include <snmalloc_core.h>
|
||||
# include <snmalloc/backend/backend.h>
|
||||
# include <snmalloc/snmalloc_core.h>
|
||||
|
||||
// Specify type of allocator
|
||||
# define SNMALLOC_PROVIDE_OWN_CONFIG
|
||||
@@ -98,7 +98,7 @@ namespace snmalloc
|
||||
}
|
||||
|
||||
# define SNMALLOC_NAME_MANGLE(a) test_##a
|
||||
# include "../../../override/malloc.cc"
|
||||
# include <snmalloc/override/malloc.cc>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ int main()
|
||||
}
|
||||
#else
|
||||
# define SNMALLOC_EXPOSE_PAGEMAP 1
|
||||
# include <override/malloc.cc>
|
||||
# include <snmalloc/override/malloc.cc>
|
||||
|
||||
using ExternalChunkmap =
|
||||
ExternalGlobalPagemapTemplate<ChunkmapPagemap, snmalloc_chunkmap_global_get>;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "test/setup.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <snmalloc.h>
|
||||
#include <snmalloc/snmalloc.h>
|
||||
#include <thread>
|
||||
|
||||
void alloc1(size_t size)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "backend/fixedglobalconfig.h"
|
||||
#include "test/setup.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <snmalloc.h>
|
||||
#include <snmalloc/backend/fixedglobalconfig.h>
|
||||
#include <snmalloc/snmalloc.h>
|
||||
|
||||
#ifdef assert
|
||||
# undef assert
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#define SNMALLOC_BOOTSTRAP_ALLOCATOR
|
||||
#define SNMALLOC_JEMALLOC3_EXPERIMENTAL
|
||||
#define SNMALLOC_JEMALLOC_NONSTANDARD
|
||||
#include "../../../override/jemalloc_compat.cc"
|
||||
#include "../../../override/malloc.cc"
|
||||
#include <snmalloc/override/jemalloc_compat.cc>
|
||||
#include <snmalloc/override/malloc.cc>
|
||||
|
||||
#if __has_include(<malloc_np.h>)
|
||||
# include <malloc_np.h>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#undef SNMALLOC_NO_REALLOCARRAY
|
||||
#undef SNMALLOC_NO_REALLOCARR
|
||||
#define SNMALLOC_BOOTSTRAP_ALLOCATOR
|
||||
#include "../../../override/malloc.cc"
|
||||
#include <snmalloc/override/malloc.cc>
|
||||
|
||||
using namespace snmalloc;
|
||||
|
||||
|
||||
@@ -19,14 +19,13 @@ int main()
|
||||
# endif
|
||||
# define SNMALLOC_FAIL_FAST false
|
||||
# define SNMALLOC_STATIC_LIBRARY_PREFIX my_
|
||||
# include "ds/defines.h"
|
||||
# ifndef SNMALLOC_PASS_THROUGH
|
||||
# include "override/malloc.cc"
|
||||
# include "snmalloc/override/malloc.cc"
|
||||
# else
|
||||
# define my_malloc(x) malloc(x)
|
||||
# define my_free(x) free(x)
|
||||
# endif
|
||||
# include "override/memcpy.cc"
|
||||
# include "snmalloc/override/memcpy.cc"
|
||||
# include "test/helpers.h"
|
||||
|
||||
# include <assert.h>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <iostream>
|
||||
#include <snmalloc.h>
|
||||
#include <snmalloc/snmalloc.h>
|
||||
#include <test/opt.h>
|
||||
#include <test/setup.h>
|
||||
#include <test/xoroshiro.h>
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include <vector>
|
||||
|
||||
#define SNMALLOC_NAME_MANGLE(a) our_##a
|
||||
#include "../../../override/malloc-extensions.cc"
|
||||
#include "../../../override/malloc.cc"
|
||||
#include "../../../snmalloc/override/malloc-extensions.cc"
|
||||
#include "../../../snmalloc/override/malloc.cc"
|
||||
|
||||
using namespace snmalloc;
|
||||
|
||||
|
||||
@@ -6,10 +6,8 @@
|
||||
* but no examples were using multiple levels of pagemap.
|
||||
*/
|
||||
|
||||
#include <backend/pagemap.h>
|
||||
#include <ds/bits.h>
|
||||
#include <iostream>
|
||||
#include <snmalloc.h>
|
||||
#include <snmalloc/snmalloc.h>
|
||||
#include <test/setup.h>
|
||||
|
||||
using namespace snmalloc;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <snmalloc.h>
|
||||
#include <snmalloc/snmalloc.h>
|
||||
#include <test/opt.h>
|
||||
#include <test/setup.h>
|
||||
#include <unordered_set>
|
||||
|
||||
@@ -8,10 +8,11 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#define SNMALLOC_TRACING
|
||||
#ifndef SNMALLOC_TRACING
|
||||
# define SNMALLOC_TRACING
|
||||
#endif
|
||||
// Redblack tree needs some libraries with trace enabled.
|
||||
#include "ds/redblacktree.h"
|
||||
#include "snmalloc.h"
|
||||
#include "snmalloc/snmalloc.h"
|
||||
|
||||
struct NodeRef
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <iostream>
|
||||
#include <snmalloc.h>
|
||||
#include <snmalloc/snmalloc.h>
|
||||
#include <test/setup.h>
|
||||
using namespace snmalloc;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <iostream>
|
||||
#include <snmalloc.h>
|
||||
#include <snmalloc/snmalloc.h>
|
||||
#include <test/setup.h>
|
||||
|
||||
NOINLINE
|
||||
@@ -118,4 +118,4 @@ int main(int, char**)
|
||||
abort();
|
||||
|
||||
test_align_size();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <snmalloc.h>
|
||||
#include <snmalloc/snmalloc.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "test/setup.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <snmalloc.h>
|
||||
#include <snmalloc/snmalloc.h>
|
||||
#include <thread>
|
||||
|
||||
void trigger_teardown()
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
# undef SNMALLOC_USE_PTHREAD_DESTRUCTORS
|
||||
#endif
|
||||
|
||||
#include <snmalloc_core.h>
|
||||
#include <snmalloc/snmalloc_core.h>
|
||||
#include <test/setup.h>
|
||||
|
||||
// Specify using own
|
||||
#define SNMALLOC_EXTERNAL_THREAD_ALLOC
|
||||
|
||||
#include "backend/globalconfig.h"
|
||||
#include <snmalloc/backend/globalconfig.h>
|
||||
|
||||
namespace snmalloc
|
||||
{
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
#include <snmalloc_front.h>
|
||||
#include <snmalloc/snmalloc_front.h>
|
||||
|
||||
void allocator_thread_init(void)
|
||||
{
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#define SNMALLOC_TRACING
|
||||
#ifndef SNMALLOC_TRACING
|
||||
# define SNMALLOC_TRACING
|
||||
#endif
|
||||
|
||||
// Redefine the namespace, so we can have two versions.
|
||||
#define snmalloc snmalloc_enclave
|
||||
|
||||
#include <backend/fixedglobalconfig.h>
|
||||
#include <snmalloc_core.h>
|
||||
#include <snmalloc/backend/fixedglobalconfig.h>
|
||||
#include <snmalloc/snmalloc_core.h>
|
||||
|
||||
// Specify type of allocator
|
||||
#define SNMALLOC_PROVIDE_OWN_CONFIG
|
||||
@@ -15,7 +17,7 @@ namespace snmalloc
|
||||
}
|
||||
|
||||
#define SNMALLOC_NAME_MANGLE(a) enclave_##a
|
||||
#include "../../../override/malloc.cc"
|
||||
#include <snmalloc/override/malloc.cc>
|
||||
|
||||
extern "C" void oe_allocator_init(void* base, void* end)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#define SNMALLOC_TRACING
|
||||
#ifndef SNMALLOC_TRACING
|
||||
# define SNMALLOC_TRACING
|
||||
#endif
|
||||
|
||||
#define SNMALLOC_NAME_MANGLE(a) host_##a
|
||||
// Redefine the namespace, so we can have two versions.
|
||||
#define snmalloc snmalloc_host
|
||||
#include "../../../override/malloc.cc"
|
||||
#include <snmalloc/override/malloc.cc>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "../../../snmalloc.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <snmalloc/snmalloc.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <test/setup.h>
|
||||
|
||||
Reference in New Issue
Block a user