aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2015-03-29 22:13:48 +0300
committerLasse Collin <lasse.collin@tukaani.org>2015-03-29 22:13:48 +0300
commit25263fd9e7a8a913395cb93d7c104cd48c2b4a00 (patch)
tree0c91dcc8ea5ebd2643418cf2ecdd02b5213a50e7 /src
parentFix CPU core count detection on QNX. (diff)
downloadxz-25263fd9e7a8a913395cb93d7c104cd48c2b4a00.tar.xz
Fix the detection of installed RAM on QNX.
The earlier version compiled but didn't actually work since sysconf(_SC_PHYS_PAGES) always fails (or so I was told). Thanks to Ole André Vadla Ravnås for the patch and testing.
Diffstat (limited to 'src')
-rw-r--r--src/common/tuklib_physmem.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/common/tuklib_physmem.c b/src/common/tuklib_physmem.c
index 3cc7d12a..cd2437d8 100644
--- a/src/common/tuklib_physmem.c
+++ b/src/common/tuklib_physmem.c
@@ -37,7 +37,10 @@
# define __USE_INLINE__
# include <proto/exec.h>
-// AIX
+#elif defined(__QNX__)
+# include <sys/syspage.h>
+# include <string.h>
+
#elif defined(TUKLIB_PHYSMEM_AIX)
# include <sys/systemcfg.h>
@@ -126,6 +129,15 @@ tuklib_physmem(void)
#elif defined(AMIGA) || defined(__AROS__)
ret = AvailMem(MEMF_TOTAL);
+#elif defined(__QNX__)
+ const struct asinfo_entry *entries = SYSPAGE_ENTRY(asinfo);
+ size_t count = SYSPAGE_ENTRY_SIZE(asinfo) / sizeof(struct asinfo_entry);
+ const char *strings = SYSPAGE_ENTRY(strings)->data;
+
+ for (size_t i = 0; i < count; ++i)
+ if (strcmp(strings + entries[i].name, "ram") == 0)
+ ret += entries[i].end - entries[i].start + 1;
+
#elif defined(TUKLIB_PHYSMEM_AIX)
ret = _system_configuration.physmem;