From 4d6759aca47359f21c8168d76aebbde2fcff727d Mon Sep 17 00:00:00 2001 From: Nathaniel Filardo Date: Wed, 4 Dec 2019 16:53:35 +0000 Subject: [PATCH] Make "pal_supports" not a function But rather a template vardecl, as per C++14 --- src/mem/alloc.h | 2 +- src/mem/chunkmap.h | 2 +- src/mem/largealloc.h | 4 ++-- src/pal/pal.h | 5 +---- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/mem/alloc.h b/src/mem/alloc.h index 1260e9c..d483f7a 100644 --- a/src/mem/alloc.h +++ b/src/mem/alloc.h @@ -1120,7 +1120,7 @@ namespace snmalloc else if constexpr (decommit_strategy == DecommitSuperLazy) { static_assert( - pal_supports(), + pal_supports, "A lazy decommit strategy cannot be implemented on platforms " "without low memory notifications"); } diff --git a/src/mem/chunkmap.h b/src/mem/chunkmap.h index b261293..1cb2edf 100644 --- a/src/mem/chunkmap.h +++ b/src/mem/chunkmap.h @@ -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() || + static constexpr bool USE_FLATPAGEMAP = pal_supports || (SNMALLOC_MAX_FLATPAGEMAP_SIZE >= sizeof(FlatPagemap)); diff --git a/src/mem/largealloc.h b/src/mem/largealloc.h index f7fcc92..c70a9b9 100644 --- a/src/mem/largealloc.h +++ b/src/mem/largealloc.h @@ -190,7 +190,7 @@ namespace snmalloc SNMALLOC_FAST_PATH uint64_t low_memory_epoch() { - if constexpr (pal_supports()) + if constexpr (pal_supports) { return PAL::low_memory_epoch(); } @@ -203,7 +203,7 @@ namespace snmalloc template void* reserve(size_t* size, size_t align) noexcept { - if constexpr (pal_supports()) + if constexpr (pal_supports) { return PAL::template reserve(size, align); } diff --git a/src/pal/pal.h b/src/pal/pal.h index 8b967b1..11ae017 100644 --- a/src/pal/pal.h +++ b/src/pal/pal.h @@ -61,8 +61,5 @@ namespace snmalloc * Query whether the PAL supports a specific feature. */ template - constexpr static bool pal_supports() - { - return (PAL::pal_features & F) == F; - } + constexpr static bool pal_supports = (PAL::pal_features & F) == F; } // namespace snmalloc