1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-23 20:15:19 -07:00

Set a default page size to 64K (wasm/linux large pages)

This commit is contained in:
Frank Denis 2020-01-05 21:00:00 -05:00
parent 587ffc825d
commit 41c7e47efd

View File

@ -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 */