Splitting EXPOSE_EXTERNAL_ALLOCATOR_API to EXPOSE_EXTERNAL_PAGEMAP and EXPOSE_EXTERNAL_RESERVE. Only the shim can be affected by passing the new pre-processor definitions to cmake.

This commit is contained in:
Roy Schuster
2019-04-12 12:32:37 +01:00
parent 81030a554f
commit 29e4bdd29d
3 changed files with 11 additions and 11 deletions

View File

@@ -4,7 +4,8 @@ project(snmalloc C CXX)
option(USE_SNMALLOC_STATS "Track allocation stats" OFF)
option(USE_MEASURE "Measure performance with histograms" OFF)
option(USE_SBRK "Use sbrk instead of mmap" OFF)
option(EXPOSE_EXTERNAL_ALLOCATOR_API "Expose the API that allows using external allocators and sharing pagemaps" OFF)
option(EXPOSE_EXTERNAL_PAGEMAP "Expose the global pagemap" OFF)
option(EXPOSE_EXTERNAL_RESERVE "Expose an interface to reserve memory using the default memory provider" OFF)
set(CACHE_FRIENDLY_OFFSET OFF CACHE STRING "Base offset to place linked-list nodes.")
@@ -68,10 +69,6 @@ if(USE_SBRK)
add_definitions(-DUSE_SBRK)
endif()
if(EXPOSE_EXTERNAL_ALLOCATOR_API)
add_definitions(-DSNMALLOC_EXPOSE_RESERVE -DSNMALLOC_EXPOSE_PAGEMAP)
endif()
macro(add_shim name)
add_library(${name} SHARED src/override/malloc.cc)
target_link_libraries(${name} -pthread)
@@ -82,6 +79,13 @@ macro(add_shim name)
if(CACHE_FRIENDLY_OFFSET)
target_compile_definitions(${name} PRIVATE -DCACHE_FRIENDLY_OFFSET=${CACHE_FRIENDLY_OFFSET})
endif()
if(EXPOSE_EXTERNAL_PAGEMAP)
target_compile_definitions(${name} PRIVATE -DSNMALLOC_EXPOSE_PAGEMAP)
endif()
if(EXPOSE_EXTERNAL_RESERVE)
target_compile_definitions(${name} PRIVATE -DSNMALLOC_EXPOSE_RESERVE)
endif()
endmacro()
if(NOT MSVC)

View File

@@ -4,9 +4,7 @@
#define USE_RESERVE_MULTIPLE 1
#define NO_BOOTSTRAP_ALLOCATOR
#define IS_ADDRESS_SPACE_CONSTRAINED
#ifndef SNMALLOC_EXPOSE_PAGEMAP
# define SNMALLOC_EXPOSE_PAGEMAP
#endif
#define SNMALLOC_EXPOSE_PAGEMAP
#define SNMALLOC_NAME_MANGLE(a) enclave_##a
// Redefine the namespace, so we can have two versions.
#define snmalloc snmalloc_enclave

View File

@@ -1,9 +1,7 @@
#undef IS_ADDRESS_SPACE_CONSTRAINED
#define SNMALLOC_NAME_MANGLE(a) host_##a
#define NO_BOOTSTRAP_ALLOCATOR
#ifndef SNMALLOC_EXPOSE_PAGEMAP
# define SNMALLOC_EXPOSE_PAGEMAP
#endif
#define SNMALLOC_EXPOSE_PAGEMAP
// Redefine the namespace, so we can have two versions.
#define snmalloc snmalloc_host
#include "../../../override/malloc.cc"