From: Doug Huff Date: Thu, 30 Jun 2011 00:04:44 +0000 (+0200) Subject: Make mlock() and munlock() portable to systems that require the address to be on... X-Git-Tag: v0.4.0-unstable~227^2~99^2~9 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=a48c671957e37594d8f9e0fd51b24e7a4f44300e Make mlock() and munlock() portable to systems that require the address to be on a page boundary. --- diff --git a/src/serialize.h b/src/serialize.h index 6952004..38c533d 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -38,6 +38,18 @@ typedef unsigned long long uint64; #define munlock(p, n) VirtualUnlock((p), (n)); #else #include +#include +/* This comes from limits.h if it's not defined there set a sane default */ +#ifndef PAGESIZE +#include +#define PAGESIZE sysconf(_SC_PAGESIZE) +#endif +#define mlock(a,b) \ + mlock(((void *)(((size_t)(a)) & (~((PAGESIZE)-1)))),\ + (((((size_t)(a)) + (b) - 1) | ((PAGESIZE) - 1)) + 1) - (((size_t)(a)) & (~((PAGESIZE) - 1)))) +#define munlock(a,b) \ + munlock(((void *)(((size_t)(a)) & (~((PAGESIZE)-1)))),\ + (((((size_t)(a)) + (b) - 1) | ((PAGESIZE) - 1)) + 1) - (((size_t)(a)) & (~((PAGESIZE) - 1)))) #endif class CScript;