diff --git a/src/aal/aal.h b/src/aal/aal.h index 7e2af37..821d8a3 100644 --- a/src/aal/aal.h +++ b/src/aal/aal.h @@ -197,7 +197,7 @@ namespace snmalloc { // Impose constraints on bounds annotations. static_assert(BIn::spatial >= capptr::dimension::Spatial::Chunk); - static_assert(capptr_is_spatial_refinement()); + static_assert(capptr::is_spatial_refinement()); UNUSED(size); return CapPtr(a.template as_static().unsafe_capptr); diff --git a/src/ds/ptrwrap.h b/src/ds/ptrwrap.h index 6a0b024..9ee2cf2 100644 --- a/src/ds/ptrwrap.h +++ b/src/ds/ptrwrap.h @@ -48,7 +48,7 @@ namespace snmalloc /** * On some platforms (e.g., CHERI), pointers can be checked to see whether * they authorize control of the address space. See the PAL's - * capptr_export(). + * capptr_to_user_address_control(). */ enum class AddressSpaceControl { @@ -188,38 +188,48 @@ namespace snmalloc */ using AllocWild = Alloc::with_wildness; } // namespace bounds + + /** + * Compute the AddressSpaceControl::User variant of a capptr::bound + * annotation. This is used by the PAL's capptr_to_user_address_control + * function to compute its return value's annotation. + */ + template + using user_address_control_type = + typename B::template with_address_space_control< + dimension::AddressSpaceControl::User>; + + /** + * Determine whether BI is a spatial refinement of BO. + * Chunk and ChunkD are considered eqivalent here. + */ + template< + SNMALLOC_CONCEPT(capptr::ConceptBound) BI, + SNMALLOC_CONCEPT(capptr::ConceptBound) BO> + SNMALLOC_CONSTEVAL bool is_spatial_refinement() + { + if (BI::address_space_control != BO::address_space_control) + { + return false; + } + + if (BI::wildness != BO::wildness) + { + return false; + } + + switch (BI::spatial) + { + using namespace capptr::dimension; + case Spatial::Chunk: + return true; + + case Spatial::Alloc: + return BO::spatial == Spatial::Alloc; + } + } } // namespace capptr - /** - * Determine whether BI is a spatial refinement of BO. - * Chunk and ChunkD are considered eqivalent here. - */ - template< - SNMALLOC_CONCEPT(capptr::ConceptBound) BI, - SNMALLOC_CONCEPT(capptr::ConceptBound) BO> - SNMALLOC_CONSTEVAL bool capptr_is_spatial_refinement() - { - if (BI::address_space_control != BO::address_space_control) - { - return false; - } - - if (BI::wildness != BO::wildness) - { - return false; - } - - switch (BI::spatial) - { - using namespace capptr::dimension; - case Spatial::Chunk: - return true; - - case Spatial::Alloc: - return BO::spatial == Spatial::Alloc; - } - } - /** * A pointer annotated with a "phantom type parameter" carrying a static * summary of its StrictProvenance metadata. diff --git a/src/pal/pal.h b/src/pal/pal.h index a2ad115..6e2ef2a 100644 --- a/src/pal/pal.h +++ b/src/pal/pal.h @@ -69,16 +69,6 @@ namespace snmalloc // Used to keep Superslab metadata committed. static constexpr size_t OS_PAGE_SIZE = Pal::page_size; - /** - * Compute the AddressSpaceControl::User variant of a capptr::bound - * annotation. This is used by the PAL's capptr_export function to compute - * its return value's annotation. - */ - template - using capptr_user_address_control_type = - typename B::template with_address_space_control< - capptr::dimension::AddressSpaceControl::User>; - /** * Perform platform-specific adjustment of return pointers. * @@ -92,10 +82,10 @@ namespace snmalloc SNMALLOC_CONCEPT(capptr::ConceptBound) B> static inline typename std::enable_if_t< !aal_supports, - CapPtr>> + CapPtr>> capptr_to_user_address_control(CapPtr p) { - return CapPtr>(p.unsafe_capptr); + return CapPtr>(p.unsafe_capptr); } template< @@ -105,7 +95,7 @@ namespace snmalloc SNMALLOC_CONCEPT(capptr::ConceptBound) B> static SNMALLOC_FAST_PATH typename std::enable_if_t< aal_supports, - CapPtr>> + CapPtr>> capptr_to_user_address_control(CapPtr p) { return PAL::capptr_to_user_address_control(p);