diff --git a/configure b/configure index bed9eab3673..244b66545ef 100755 --- a/configure +++ b/configure @@ -19643,6 +19643,32 @@ _ACEOF fi +ac_fn_c_check_member "$LINENO" "struct sysinfo" "totalram" "ac_cv_member_struct_sysinfo_totalram" "#ifdef HAVE_SYS_SYSINFO_H +# include +#endif +" +if test "x$ac_cv_member_struct_sysinfo_totalram" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_SYSINFO_TOTALRAM 1 +_ACEOF + + +fi +ac_fn_c_check_member "$LINENO" "struct sysinfo" "mem_unit" "ac_cv_member_struct_sysinfo_mem_unit" "#ifdef HAVE_SYS_SYSINFO_H +# include +#endif +" +if test "x$ac_cv_member_struct_sysinfo_mem_unit" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_SYSINFO_MEM_UNIT 1 +_ACEOF + + +fi + + ac_save_LIBS="$LIBS" LIBS="$LIBS -lm" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for isfinite" >&5 diff --git a/configure.ac b/configure.ac index 29ff38f169b..47d0471169a 100644 --- a/configure.ac +++ b/configure.ac @@ -2658,6 +2658,12 @@ AC_CHECK_MEMBERS([struct ifreq.ifr_hwaddr],,, # include #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 +#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 9b1ca761e9b..a2fea588834 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -43,6 +43,9 @@ #ifdef HAVE_SYS_SYSINFO_H # include #endif +#ifdef HAVE_UNISTD_H +# include +#endif #ifdef HAVE_VALGRIND_VALGRIND_H # include #endif @@ -2481,22 +2484,26 @@ 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; + + if (!sysinfo(&sinfo)) + { + ULONG64 total = (ULONG64)sinfo.totalram * sinfo.mem_unit; + info->MmHighestPhysicalPage = max(1, total / page_size); + } +#elif defined(_SC_PHYS_PAGES) + LONG64 phys_pages = sysconf( _SC_PHYS_PAGES ); + + info->MmHighestPhysicalPage = max(1, phys_pages); +#else + info->MmHighestPhysicalPage = 0x7fffffff / page_size; #endif info->unknown = 0; info->KeMaximumIncrement = 0; /* FIXME */ info->PageSize = page_size; info->MmLowestPhysicalPage = 1; - info->MmHighestPhysicalPage = 0x7fffffff / page_size; -#ifdef HAVE_SYSINFO - if (!sysinfo(&sinfo)) - { - ULONG64 total = (ULONG64)sinfo.totalram * sinfo.mem_unit; - info->MmHighestPhysicalPage = max(1, total / page_size); - } -#endif info->MmNumberOfPhysicalPages = info->MmHighestPhysicalPage - info->MmLowestPhysicalPage; info->AllocationGranularity = granularity_mask + 1; info->LowestUserAddress = (void *)0x10000; diff --git a/include/config.h.in b/include/config.h.in index 4d479a6cb3d..fc9305418c6 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -950,6 +950,12 @@ /* Define to 1 if `__st_birthtime' is a member of `struct stat'. */ #undef HAVE_STRUCT_STAT___ST_BIRTHTIME +/* Define to 1 if `mem_unit' is a member of `struct sysinfo'. */ +#undef HAVE_STRUCT_SYSINFO_MEM_UNIT + +/* Define to 1 if `totalram' is a member of `struct sysinfo'. */ +#undef HAVE_STRUCT_SYSINFO_TOTALRAM + /* Define to 1 if `tcps_connattempt' is a member of `struct tcpstat'. */ #undef HAVE_STRUCT_TCPSTAT_TCPS_CONNATTEMPT