| 4292 | } |
| 4293 | |
| 4294 | bool SystemInformationImplementation::QueryMemoryBySysconf() |
| 4295 | { |
| 4296 | #if defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE) |
| 4297 | // Assume the mmap() granularity as returned by _SC_PAGESIZE is also |
| 4298 | // the system page size. The only known system where this isn't true |
| 4299 | // is Cygwin. |
| 4300 | long p = sysconf(_SC_PHYS_PAGES); |
| 4301 | long m = sysconf(_SC_PAGESIZE); |
| 4302 | |
| 4303 | if (p < 0 || m < 0) { |
| 4304 | return false; |
| 4305 | } |
| 4306 | |
| 4307 | // assume pagesize is a power of 2 and smaller 1 MiB |
| 4308 | size_t pagediv = (1024 * 1024 / m); |
| 4309 | |
| 4310 | this->TotalPhysicalMemory = p; |
| 4311 | this->TotalPhysicalMemory /= pagediv; |
| 4312 | |
| 4313 | # if defined(_SC_AVPHYS_PAGES) |
| 4314 | p = sysconf(_SC_AVPHYS_PAGES); |
| 4315 | if (p < 0) { |
| 4316 | return false; |
| 4317 | } |
| 4318 | |
| 4319 | this->AvailablePhysicalMemory = p; |
| 4320 | this->AvailablePhysicalMemory /= pagediv; |
| 4321 | # endif |
| 4322 | |
| 4323 | return true; |
| 4324 | #else |
| 4325 | return false; |
| 4326 | #endif |
| 4327 | } |
| 4328 | |
| 4329 | /** Query for the memory status */ |
| 4330 | bool SystemInformationImplementation::QueryMemory() |
no outgoing calls
no test coverage detected