PALNoAlloc should delegate more to underlying PAL
This commit is contained in:
committed by
Nathaniel Wesley Filardo
parent
7f71f80cce
commit
1baf675adb
@@ -8,17 +8,29 @@
|
||||
|
||||
namespace snmalloc
|
||||
{
|
||||
|
||||
/*
|
||||
* These concepts enforce that these are indeed constants that fit in the
|
||||
* desired types. (This is subtly different from saying that they are the
|
||||
* required types; C++ may handle constants without much regard for their
|
||||
* claimed type.)
|
||||
*/
|
||||
|
||||
/**
|
||||
* PALs must advertize the bit vector of their supported features and the
|
||||
* platform's page size. This concept enforces that these are indeed
|
||||
* constants that fit in the desired types. (This is subtly different from
|
||||
* saying that they are the required types; C++ may handle constants without
|
||||
* much regard for their claimed type.)
|
||||
* PALs must advertize the bit vector of their supported features.
|
||||
*/
|
||||
template<typename PAL>
|
||||
concept ConceptPAL_static_members = requires()
|
||||
concept ConceptPAL_static_features = requires()
|
||||
{
|
||||
typename std::integral_constant<uint64_t, PAL::pal_features>;
|
||||
};
|
||||
|
||||
/**
|
||||
* PALs must advertise their page size
|
||||
*/
|
||||
template<typename PAL>
|
||||
concept ConceptPAL_static_sizes = requires()
|
||||
{
|
||||
typename std::integral_constant<std::size_t, PAL::page_size>;
|
||||
};
|
||||
|
||||
@@ -93,7 +105,8 @@ namespace snmalloc
|
||||
*/
|
||||
template<typename PAL>
|
||||
concept ConceptPAL =
|
||||
ConceptPAL_static_members<PAL> &&
|
||||
ConceptPAL_static_features<PAL> &&
|
||||
ConceptPAL_static_sizes<PAL> &&
|
||||
ConceptPAL_error<PAL> &&
|
||||
ConceptPAL_memops<PAL> &&
|
||||
(!pal_supports<Entropy, PAL> ||
|
||||
|
||||
@@ -4,23 +4,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "../aal/aal.h"
|
||||
#include "pal_concept.h"
|
||||
#include "pal_consts.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace snmalloc
|
||||
{
|
||||
#ifdef __cpp_concepts
|
||||
/**
|
||||
* The minimal subset of a PAL that we need for delegation
|
||||
*/
|
||||
template<typename PAL>
|
||||
concept PALNoAllocBase = ConceptPAL_static_sizes<PAL>&& ConceptPAL_error<PAL>;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Platform abstraction layer that does not allow allocation.
|
||||
*
|
||||
* This is a minimal PAL for pre-reserved memory regions, where the
|
||||
* address-space manager is initialised with all of the memory that it will
|
||||
* ever use.
|
||||
*
|
||||
* It takes an error handler delegate as a template argument. This is
|
||||
* expected to forward to the default PAL in most cases.
|
||||
*/
|
||||
template<typename ErrorHandler>
|
||||
template<SNMALLOC_CONCEPT(PALNoAllocBase) BasePAL>
|
||||
struct PALNoAlloc
|
||||
{
|
||||
/**
|
||||
@@ -29,14 +35,14 @@ namespace snmalloc
|
||||
*/
|
||||
static constexpr uint64_t pal_features = NoAllocation;
|
||||
|
||||
static constexpr size_t page_size = Aal::smallest_page_size;
|
||||
static constexpr size_t page_size = BasePAL::page_size;
|
||||
|
||||
/**
|
||||
* Print a stack trace.
|
||||
*/
|
||||
static void print_stack_trace()
|
||||
{
|
||||
ErrorHandler::print_stack_trace();
|
||||
BasePAL::print_stack_trace();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,7 +50,7 @@ namespace snmalloc
|
||||
*/
|
||||
[[noreturn]] static void error(const char* const str) noexcept
|
||||
{
|
||||
ErrorHandler::error(str);
|
||||
BasePAL::error(str);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user