Skip to content

Commit

Permalink
Add static_assert verifing page size is constexpr.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cferris1000 committed Sep 9, 2024
1 parent 9d05ab3 commit 7befc97
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions config/custom_scudo_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ struct AndroidLowMemoryConfig {

#if defined(__ANDROID__)

#include <unistd.h>

#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
Expand Down

0 comments on commit 7befc97

Please sign in to comment.