From 7befc9758b4a8cae28a0c1f99febe484a94f1d04 Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Mon, 9 Sep 2024 16:05:52 -0700 Subject: [PATCH] Add static_assert verifing page size is constexpr. Whenever PAGE_SIZE is defined, make sure that the getPageSizeCached() function is constexpr using a static_assert. If it isn't this won't compile. Test: treehugger Change-Id: I4f7374cc6d9d7b538d7bf33a0748ba17b13b6218 --- config/custom_scudo_config.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/config/custom_scudo_config.h b/config/custom_scudo_config.h index 8fe8cbc68ca..b1b1d9a1dc0 100644 --- a/config/custom_scudo_config.h +++ b/config/custom_scudo_config.h @@ -220,6 +220,13 @@ struct AndroidLowMemoryConfig { #if defined(__ANDROID__) +#include + +#if defined(PAGE_SIZE) +// This is to guarantee that the getPageSizeCached() function is constexpr. +static_assert(getPageSizeCached() != 0, "getPageSizeCached() is zero"); +#endif + #if defined(SCUDO_LOW_MEMORY) typedef AndroidLowMemoryConfig Config; #else