diff --git a/os/os-qnx.h b/os/os-qnx.h index 447c9957be..8ae9695ec8 100755 --- a/os/os-qnx.h +++ b/os/os-qnx.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -71,11 +71,17 @@ static inline int blockdev_invalidate_cache(struct fio_file *f) static inline unsigned long long os_phys_mem(void) { - int mib[2] = { CTL_HW, HW_PHYSMEM64 }; - uint64_t mem; - size_t len = sizeof(mem); + uint64_t mem = 0; + const char *const strings = SYSPAGE_ENTRY(strings)->data; + const struct asinfo_entry *const begin = SYSPAGE_ENTRY(asinfo); + const struct asinfo_entry *const end = begin + SYSPAGE_ENTRY_SIZE(asinfo) / SYSPAGE_ELEMENT_SIZE(asinfo); - sysctl(mib, 2, &mem, &len, NULL, 0); + assert(SYSPAGE_ELEMENT_SIZE(asinfo) == sizeof(struct asinfo_entry)); + + for (const struct asinfo_entry *e = begin; e < end; ++e) { + if (!strcmp(strings + e->name, "ram")) + mem += e->end - e->start + 1; + } return mem; }