Make "pal_supports" not a function

But rather a template vardecl, as per C++14
This commit is contained in:
Nathaniel Filardo
2019-12-04 16:53:35 +00:00
parent 2567e8e4f3
commit 4d6759aca4
4 changed files with 5 additions and 8 deletions

View File

@@ -1120,7 +1120,7 @@ namespace snmalloc
else if constexpr (decommit_strategy == DecommitSuperLazy)
{
static_assert(
pal_supports<LowMemoryNotification, MemoryProvider>(),
pal_supports<LowMemoryNotification, MemoryProvider>,
"A lazy decommit strategy cannot be implemented on platforms "
"without low memory notifications");
}

View File

@@ -47,7 +47,7 @@ namespace snmalloc
// Use flat map is under a single node.
# define SNMALLOC_MAX_FLATPAGEMAP_SIZE PAGEMAP_NODE_SIZE
#endif
static constexpr bool USE_FLATPAGEMAP = pal_supports<LazyCommit>() ||
static constexpr bool USE_FLATPAGEMAP = pal_supports<LazyCommit> ||
(SNMALLOC_MAX_FLATPAGEMAP_SIZE >=
sizeof(FlatPagemap<SUPERSLAB_BITS, uint8_t>));

View File

@@ -190,7 +190,7 @@ namespace snmalloc
SNMALLOC_FAST_PATH
uint64_t low_memory_epoch()
{
if constexpr (pal_supports<LowMemoryNotification, PAL>())
if constexpr (pal_supports<LowMemoryNotification, PAL>)
{
return PAL::low_memory_epoch();
}
@@ -203,7 +203,7 @@ namespace snmalloc
template<bool committed>
void* reserve(size_t* size, size_t align) noexcept
{
if constexpr (pal_supports<AlignedAllocation, PAL>())
if constexpr (pal_supports<AlignedAllocation, PAL>)
{
return PAL::template reserve<committed>(size, align);
}

View File

@@ -61,8 +61,5 @@ namespace snmalloc
* Query whether the PAL supports a specific feature.
*/
template<PalFeatures F, typename PAL = Pal>
constexpr static bool pal_supports()
{
return (PAL::pal_features & F) == F;
}
constexpr static bool pal_supports = (PAL::pal_features & F) == F;
} // namespace snmalloc