Small tweaks to make the sandbox mode happy.

Allow replacing the type of GlobalVirtual at compile time.
Make that type a friend of Pool so that it can allocate things.
This commit is contained in:
David Chisnall
2021-01-13 15:23:56 +00:00
committed by David Chisnall
parent c33f355736
commit db3580a9d8
2 changed files with 13 additions and 1 deletions

View File

@@ -368,7 +368,18 @@ namespace snmalloc
}
};
using GlobalVirtual = MemoryProviderStateMixin<Pal>;
#ifndef SNMALLOC_DEFAULT_MEMORY_PROVIDER
# define SNMALLOC_DEFAULT_MEMORY_PROVIDER MemoryProviderStateMixin<Pal>
#endif
/**
* The type of the default memory allocator. This can be changed by defining
* `SNMALLOC_DEFAULT_MEMORY_PROVIDER` before including this file. By default
* it is `MemoryProviderStateMixin<Pal>` a class that allocates directly from
* the platform abstraction layer.
*/
using GlobalVirtual = SNMALLOC_DEFAULT_MEMORY_PROVIDER;
/**
* The memory provider that will be used if no other provider is explicitly
* passed as an argument.

View File

@@ -24,6 +24,7 @@ namespace snmalloc
friend Pooled<T>;
template<SNMALLOC_CONCEPT(ConceptPAL) PAL>
friend class MemoryProviderStateMixin;
friend SNMALLOC_DEFAULT_MEMORY_PROVIDER;
std::atomic_flag lock = ATOMIC_FLAG_INIT;
MPMCStack<T, PreZeroed> stack;