| 33 #include <errno.h> |
33 #include <errno.h> |
| 34 |
34 |
| 35 #ifdef _WIN32 |
35 #ifdef _WIN32 |
| 36 #include <Windows.h> |
36 #include <Windows.h> |
| 37 #include <sysinfoapi.h> |
37 #include <sysinfoapi.h> |
| 38 static unsigned long system_page_size() { |
38 static unsigned long system_page_size(void) { |
| 39 static unsigned long ps = 0; |
39 static unsigned long ps = 0; |
| 40 if (ps == 0) { |
40 if (ps == 0) { |
| 41 SYSTEM_INFO sysinfo; |
41 SYSTEM_INFO sysinfo; |
| 42 GetSystemInfo(&sysinfo); |
42 GetSystemInfo(&sysinfo); |
| 43 ps = sysinfo.dwPageSize; |
43 ps = sysinfo.dwPageSize; |
| 44 } |
44 } |
| 45 return ps; |
45 return ps; |
| 46 } |
46 } |
| 47 #else |
47 #else |
| 48 #include <unistd.h> |
48 #include <unistd.h> |
| 49 static unsigned long system_page_size() { |
49 static unsigned long system_page_size(void) { |
| 50 static unsigned long ps = 0; |
50 static unsigned long ps = 0; |
| 51 if (ps == 0) { |
51 if (ps == 0) { |
| 52 long sc = sysconf(_SC_PAGESIZE); |
52 long sc = sysconf(_SC_PAGESIZE); |
| 53 if (sc < 0) { |
53 if (sc < 0) { |
| 54 // fallback for systems which do not report a value here |
54 // fallback for systems which do not report a value here |