Add a portable getpagesize() implementation

This commit is contained in:
Victor Zverovich
2014-09-12 13:53:52 -07:00
parent 1e9ca17b9d
commit 74169e4b5d
4 changed files with 42 additions and 1 deletions
+13
View File
@@ -222,3 +222,16 @@ fmt::BufferedFile fmt::File::fdopen(const char *mode) {
fd_ = -1;
return file;
}
long fmt::getpagesize() {
#ifdef _WIN32
SYSTEM_INFO si = {};
GetSystemInfo(&si);
return si.dwPageSize;
#else
long size = FMT_POSIX_CALL(sysconf(_SC_PAGESIZE));
if (size < 0)
throw SystemError(errno, "cannot get memory page size");
return size;
#endif
}