Improved pal_supports

This commit is contained in:
Matthew Parkinson
2019-07-09 13:14:48 +01:00
parent 23b3e35d6e
commit 45f47499c5
4 changed files with 15 additions and 18 deletions

View File

@@ -175,15 +175,6 @@ namespace snmalloc
return new (p) T(std::forward<Args...>(args)...);
}
/**
* Query whether the PAL supports a specific feature.
*/
template<PalFeatures F>
constexpr static bool pal_supports()
{
return (PAL::pal_features & F) == F;
}
/**
* Returns the number of low memory notifications that have been received
* (over the lifetime of this process). If the underlying system does not
@@ -192,7 +183,7 @@ namespace snmalloc
SNMALLOC_FAST_PATH
uint64_t low_memory_epoch()
{
if constexpr (pal_supports<LowMemoryNotification>())
if constexpr (pal_supports<LowMemoryNotification, PAL>())
{
return PAL::low_memory_epoch();
}
@@ -205,7 +196,7 @@ namespace snmalloc
template<bool committed>
void* reserve(size_t* size, size_t align) noexcept
{
if constexpr (pal_supports<AlignedAllocation>())
if constexpr (pal_supports<AlignedAllocation, PAL>())
{
return PAL::template reserve<committed>(size, align);
}