1
0
Fork 0
mirror of https://git.tukaani.org/xz.git synced 2024-04-04 12:36:23 +02:00

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.
This commit is contained in:
Lasse Collin 2015-03-29 22:13:48 +03:00
parent 4c544d2410
commit 25263fd9e7
2 changed files with 16 additions and 4 deletions

View file

@ -10,8 +10,8 @@
# #
# Supported methods: # Supported methods:
# #
# - Windows (including Cygwin), OS/2, DJGPP (DOS), and OpenVMS have # - Windows (including Cygwin), OS/2, DJGPP (DOS), OpenVMS, AROS,
# operating-system specific functions. # and QNX have operating-system specific functions.
# #
# - AIX has _system_configuration.physmem. # - AIX has _system_configuration.physmem.
# #
@ -54,7 +54,7 @@ AC_CACHE_CHECK([how to detect the amount of physical memory],
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__OS2__) \ #if defined(_WIN32) || defined(__CYGWIN__) || defined(__OS2__) \
|| defined(__DJGPP__) || defined(__VMS) \ || defined(__DJGPP__) || defined(__VMS) \
|| defined(AMIGA) || defined(__AROS__) || defined(AMIGA) || defined(__AROS__) || defined(__QNX__)
int main(void) { return 0; } int main(void) { return 0; }
#else #else
compile error compile error

View file

@ -37,7 +37,10 @@
# define __USE_INLINE__ # define __USE_INLINE__
# include <proto/exec.h> # include <proto/exec.h>
// AIX #elif defined(__QNX__)
# include <sys/syspage.h>
# include <string.h>
#elif defined(TUKLIB_PHYSMEM_AIX) #elif defined(TUKLIB_PHYSMEM_AIX)
# include <sys/systemcfg.h> # include <sys/systemcfg.h>
@ -126,6 +129,15 @@ tuklib_physmem(void)
#elif defined(AMIGA) || defined(__AROS__) #elif defined(AMIGA) || defined(__AROS__)
ret = AvailMem(MEMF_TOTAL); 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) #elif defined(TUKLIB_PHYSMEM_AIX)
ret = _system_configuration.physmem; ret = _system_configuration.physmem;