From 30da31d2452e88d0b1b0d4e88ed9393571c70c51 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Mon, 28 Nov 2022 04:39:05 +0000 Subject: [PATCH] pagemap: assert that entry types match More directly ensure that a "basic" pagemap's type matches its "concrete" pagemap parameter's entry type. Absent this check, getting this wrong won't be detected until even further along in template code generation (when considering a method that sees the mismatch). --- src/snmalloc/backend_helpers/pagemap.h | 4 ++++ src/snmalloc/ds/pagemap.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/snmalloc/backend_helpers/pagemap.h b/src/snmalloc/backend_helpers/pagemap.h index 460f70e..0466913 100644 --- a/src/snmalloc/backend_helpers/pagemap.h +++ b/src/snmalloc/backend_helpers/pagemap.h @@ -28,6 +28,10 @@ namespace snmalloc */ using Entry = PagemapEntry; + static_assert( + std::is_same_v, + "BasicPagemap's PagemapEntry and ConcreteMap disagree!"); + /** * Instance of the concrete pagemap, accessible to the backend so that * it can call the init method whose type dependent on fixed_range. diff --git a/src/snmalloc/ds/pagemap.h b/src/snmalloc/ds/pagemap.h index d7115cb..a420249 100644 --- a/src/snmalloc/ds/pagemap.h +++ b/src/snmalloc/ds/pagemap.h @@ -48,6 +48,8 @@ namespace snmalloc size_t size{0}; public: + using EntryType = T; + /** * Ensure this range of pagemap is accessible */