This is the set of changes required for snmalloc2 to be usable by the process sandboxing code and incorporates some API changes that reduce the amount of code required to embed snmalloc. Highlights: - Merge the config and back-end classes. - Everything in config is now global (all methods are static) - The GlobalState class is gone (all global state is managed by global methods on the config class) - LocalState is now a member of the config class, all methods are instance methods. - Not every configuration needs to use the lazy initialisation hooks. They now need to be provided only if they are used. If the configuration does not provide an `ensure_init` method, it is not called. If it does not provide an `is_initialised` method then the global initialisation state is not checked. - There is now an `snmalloc::Options` class that default initialises itself to the default behaviour. Every configuration must provide a `constexpr` instance of this class. Each flag can be separately overridden and new flags can be added without breaking any existing API consumers. The config classes are moved into the backend directory.
23 lines
694 B
C++
23 lines
694 B
C++
#pragma once
|
|
|
|
// Core implementation of snmalloc independent of the configuration mode
|
|
#include "snmalloc_core.h"
|
|
|
|
// If you define SNMALLOC_PROVIDE_OWN_CONFIG then you must provide your own
|
|
// definition of `snmalloc::Alloc` and include `snmalloc_front.h` before
|
|
// including any files that include `snmalloc.h` and consume the global
|
|
// allocation APIs.
|
|
#ifndef SNMALLOC_PROVIDE_OWN_CONFIG
|
|
// Default implementation of global state
|
|
# include "backend/globalconfig.h"
|
|
|
|
// The default configuration for snmalloc
|
|
namespace snmalloc
|
|
{
|
|
using Alloc = snmalloc::LocalAllocator<snmalloc::Globals>;
|
|
}
|
|
|
|
// User facing API surface, needs to know what `Alloc` is.
|
|
# include "snmalloc_front.h"
|
|
#endif
|