ntdll: Add check for totalram, mem_unit in struct sysinfo.

Signed-off-by: Evgeny Litvinenko <evgeny.v.litvinenko@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Evgeny Litvinenko 2020-07-09 03:09:41 +03:00 committed by Alexandre Julliard
parent 124cd264fa
commit 69f1b12a30
4 changed files with 54 additions and 9 deletions

26
configure vendored
View File

@ -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 <sys/sysinfo.h>
#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 <sys/sysinfo.h>
#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

View File

@ -2658,6 +2658,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"

View File

@ -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
@ -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;

View File

@ -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