NFC: Add an AAL Concept, too

While here, pull out some constants to their own header.  Eventually we'll
want to match on AalFeatures in the AAL Concept.
This commit is contained in:
Nathaniel Filardo
2020-11-20 12:56:03 +00:00
committed by Matthew Parkinson
parent a6d18f842a
commit db0ca64ff3
5 changed files with 92 additions and 34 deletions

48
src/aal/aal_concept.h Normal file
View File

@@ -0,0 +1,48 @@
#pragma once
#ifdef __cpp_concepts
# include "../ds/concept.h"
# include "aal_consts.h"
# include <cstdint>
# include <utility>
namespace snmalloc
{
/**
* AALs must advertise the bit vector of supported features, their name,
*
*/
template<typename AAL>
concept ConceptAAL_static_members = requires()
{
typename std::integral_constant<uint64_t, AAL::aal_features>;
typename std::integral_constant<int, AAL::aal_name>;
};
/**
* AALs provide a prefetch operation.
*/
template<typename AAL>
concept ConceptAAL_prefetch = requires(void *ptr)
{
{ AAL::prefetch(ptr) } noexcept -> ConceptSame<void>;
};
/**
* AALs provide a notion of high-precision timing.
*/
template<typename AAL>
concept ConceptAAL_tick = requires()
{
{ AAL::tick() } noexcept -> ConceptSame<uint64_t>;
};
template<typename AAL>
concept ConceptAAL =
ConceptAAL_static_members<AAL> &&
ConceptAAL_prefetch<AAL> &&
ConceptAAL_tick<AAL>;
} // namespace snmalloc
#endif