Skip to content

Commit

Permalink
Small tweaks to make the sandbox mode happy.
Browse files Browse the repository at this point in the history
Allow replacing the type of GlobalVirtual at compile time.
Make that type a friend of Pool so that it can allocate things.
  • Loading branch information
davidchisnall committed Jan 13, 2021
1 parent c33f355 commit db3580a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/mem/largealloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/mem/pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit db3580a

Please sign in to comment.