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