From 6bc8258397cc31ea072413c0be8352220ee4787e Mon Sep 17 00:00:00 2001 From: Tim Caswell Date: Wed, 20 Aug 2025 13:04:12 -0500 Subject: [PATCH] Fix PAGESIZE to compile on systems where it's already defined. On some systems `PAGESIZE` is a macro that expands to a numeric constant. This causes a syntax error. This PR fixes this by using `ifndef` to only try to initialize and set it if the macro doesn't exist. --- src/simdjson_ffi.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/simdjson_ffi.cpp b/src/simdjson_ffi.cpp index 9644ec3..df293fa 100644 --- a/src/simdjson_ffi.cpp +++ b/src/simdjson_ffi.cpp @@ -4,9 +4,10 @@ using namespace simdjson; - +#ifndef PAGESIZE // This is defined as a macro on some systms. // we will initialize it only once static long PAGESIZE = 0; +#endif // An optimization from https://github.com/simdjson/simdjson/blob/master/doc/performance.md#free-padding @@ -16,9 +17,11 @@ static long PAGESIZE = 0; // This is because reading within the boundary of a mapped memory page is guaranteed // not to fail, even if these area might contain garbage data, simdjson will work correctly. static bool need_allocation(const char *buf, size_t len) { +#ifndef PAGESIZE if (PAGESIZE == 0) { PAGESIZE = getpagesize(); } +#endif SIMDJSON_DEVELOPMENT_ASSERT(PAGESIZE > 0);