#pragma once #ifdef __cpp_concepts # include "../ds/concept.h" # include "../ds/ptrwrap.h" # include "aal_consts.h" # include # include namespace snmalloc { /** * AALs must advertise the bit vector of supported features, their name, * */ template concept ConceptAAL_static_members = requires() { typename std::integral_constant; typename std::integral_constant; }; /** * AALs provide a prefetch operation. */ template concept ConceptAAL_prefetch = requires(void *ptr) { { AAL::prefetch(ptr) } noexcept -> ConceptSame; }; /** * AALs provide a notion of high-precision timing. */ template concept ConceptAAL_tick = requires() { { AAL::tick() } noexcept -> ConceptSame; }; template concept ConceptAAL_capptr_methods = requires(CapPtr auth, CapPtr ret, size_t sz) { /** * Produce a pointer with reduced authority from a more privilged pointer. * The resulting pointer will have base at auth's address and length of * exactly sz. auth+sz must not exceed auth's limit. */ { AAL::template capptr_bound(auth, sz) } noexcept -> ConceptSame>; /** * Construct a copy of auth with its target set to that of ret. */ { AAL::capptr_rebound(auth, ret) } noexcept -> ConceptSame>; }; template concept ConceptAAL = ConceptAAL_static_members && ConceptAAL_prefetch && ConceptAAL_tick && ConceptAAL_capptr_methods; } // namespace snmalloc #endif