Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/simdjson_ffi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);

Expand Down