diff options
Diffstat (limited to '')
-rw-r--r-- | src/common/page.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/common/page.cc b/src/common/page.cc new file mode 100644 index 000000000..e3dc34a43 --- /dev/null +++ b/src/common/page.cc @@ -0,0 +1,33 @@ +#include <unistd.h> + +#ifdef _WIN32 +#include <windows.h> +#endif + +namespace ceph { + + // page size crap, see page.h + int _get_bits_of(int v) { + int n = 0; + while (v) { + n++; + v = v >> 1; + } + return n; + } + + #ifdef _WIN32 + unsigned _get_page_size() { + SYSTEM_INFO system_info; + GetSystemInfo(&system_info); + return system_info.dwPageSize; + } + + unsigned _page_size = _get_page_size(); + #else + unsigned _page_size = sysconf(_SC_PAGESIZE); + #endif + unsigned long _page_mask = ~(unsigned long)(_page_size - 1); + unsigned _page_shift = _get_bits_of(_page_size - 1); + +} |