From 41c7e47efd879e31504dbe9b2a46426f4551ac60 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sun, 5 Jan 2020 21:00:00 -0500 Subject: [PATCH] Set a default page size to 64K (wasm/linux large pages) --- src/libsodium/sodium/utils.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/libsodium/sodium/utils.c b/src/libsodium/sodium/utils.c index 92560939..cd88e2f6 100644 --- a/src/libsodium/sodium/utils.c +++ b/src/libsodium/sodium/utils.c @@ -90,7 +90,15 @@ void *alloca (size_t); # define MADV_DONTDUMP MADV_NOCORE #endif -static size_t page_size; +#ifndef DEFAULT_PAGE_SIZE +# ifdef PAGE_SIZE +# define DEFAULT_PAGE_SIZE PAGE_SIZE +# else +# define DEFAULT_PAGE_SIZE 0x10000 +# endif +#endif + +static size_t page_size = DEFAULT_PAGE_SIZE; static unsigned char canary[CANARY_SIZE]; static unsigned char shielding_prekey[SHIELDING_PREKEY_SIZE]; @@ -403,6 +411,8 @@ _sodium_alloc_init(void) SYSTEM_INFO si; GetSystemInfo(&si); page_size = (size_t) si.dwPageSize; +# else +# warning Unknown page size # endif if (page_size < CANARY_SIZE || page_size < sizeof(size_t)) { sodium_misuse(); /* LCOV_EXCL_LINE */