diff --git a/src/mem/largealloc.h b/src/mem/largealloc.h index 1be0662..d2a8c5e 100644 --- a/src/mem/largealloc.h +++ b/src/mem/largealloc.h @@ -116,21 +116,24 @@ namespace snmalloc lazy_decommit_guard.clear(); } - public: - template + private: + /** + * Query whether the PAL given by `P` supports a specific feature. This is + * used internally in templated functions where PAL can't be referenced in + * an `enable_if` context. + */ + template constexpr static bool pal_supports() { return (P::pal_features & F) == F; } - - private: /** * Wrapper that is instantiated only if the memory provider supports low * memory notifications and forwards the call to the memory provider. */ template ALWAYSINLINE uint64_t low_mem_epoch( - std::enable_if_t(), int> = 0) + std::enable_if_t(), int> = 0) { return PAL::low_memory_epoch(); } @@ -142,7 +145,7 @@ namespace snmalloc */ template ALWAYSINLINE uint64_t low_memory_epoch( - std::enable_if_t(), int> = 0) + std::enable_if_t(), int> = 0) { return 0; } @@ -198,6 +201,15 @@ namespace snmalloc return p; } + /** + * Query whether the PAL supports a specific feature. + */ + template + constexpr static bool pal_supports() + { + return pal_supports(); + } + /** * Returns the number of low memory notifications that have been received * (over the lifetime of this process). If the underlying system does not