Signed-off-by: Evgeny Litvinenko evgeny.v.litvinenko@gmail.com
diff --git a/configure.ac b/configure.ac index 4829648c3a..a2404aeb74 100644 --- a/configure.ac +++ b/configure.ac @@ -2215,6 +2215,7 @@ AC_CHECK_FUNCS(\ strtold \ symlink \ sysinfo \ + sysconf \ tcdrain \ thr_kill2 \ usleep @@ -2662,6 +2663,12 @@ AC_CHECK_MEMBERS([struct ifreq.ifr_hwaddr],,, # include <net/if.h> #endif])
+dnl Check for struct sysinfo members totalram and mem_unit +AC_CHECK_MEMBERS([struct sysinfo.totalram, struct sysinfo.mem_unit],,, +[#ifdef HAVE_SYS_SYSINFO_H +# include <sys/sysinfo.h> +#endif]) + dnl Check for isfinite ac_save_LIBS="$LIBS" LIBS="$LIBS -lm" diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index d16259e5ae..0dd72e445f 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -43,6 +43,9 @@ #ifdef HAVE_SYS_SYSINFO_H # include <sys/sysinfo.h> #endif +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif #ifdef HAVE_VALGRIND_VALGRIND_H # include <valgrind/valgrind.h> #endif @@ -2475,22 +2478,30 @@ ULONG_PTR get_system_affinity_mask(void) */ void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info ) { -#ifdef HAVE_SYSINFO +#if defined(HAVE_STRUCT_SYSINFO_TOTALRAM) && defined(HAVE_STRUCT_SYSINFO_MEM_UNIT) struct sysinfo sinfo; +#elif defined(HAVE_SYSCONF) && defined(_SC_PHYS_PAGES) + LONG64 phys_pages; #endif
info->unknown = 0; info->KeMaximumIncrement = 0; /* FIXME */ info->PageSize = page_size; info->MmLowestPhysicalPage = 1; - info->MmHighestPhysicalPage = 0x7fffffff / page_size; -#ifdef HAVE_SYSINFO + +#if defined(HAVE_STRUCT_SYSINFO_TOTALRAM) && defined(HAVE_STRUCT_SYSINFO_MEM_UNIT) if (!sysinfo(&sinfo)) { ULONG64 total = (ULONG64)sinfo.totalram * sinfo.mem_unit; info->MmHighestPhysicalPage = max(1, total / page_size); } +#elif defined(HAVE_SYSCONF) && defined(_SC_PHYS_PAGES) + phys_pages = sysconf( _SC_PHYS_PAGES ); + info->MmHighestPhysicalPage = max(1, phys_pages); +#else + info->MmHighestPhysicalPage = 0x7fffffff / page_size; #endif + info->MmNumberOfPhysicalPages = info->MmHighestPhysicalPage - info->MmLowestPhysicalPage; info->AllocationGranularity = granularity_mask + 1; info->LowestUserAddress = (void *)0x10000;