From: Ramsay Jones Date: Mon, 19 May 2025 16:25:23 +0000 (+0100) Subject: configure.ac: upgrade to a compilation check for sysinfo X-Git-Tag: v2.50.0-rc0~11^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=187ce0222f73dd5e8e8c0f5d0b764b4820cc9143;p=thirdparty%2Fgit.git configure.ac: upgrade to a compilation check for sysinfo Commit f5e3c6c57d ("meson: do a full usage-based compile check for sysinfo", 2025-04-25) updated the 'sysinfo()' check, as part of the meson build, due to the failure of the check on Solaris. Prior to that commit, the meson build only checked the availability of the '' header file. On Solaris, both the header and the 'sysinfo()' function exist, but are completely unrelated to the same function on Linux (and cygwin). Commit 50dec7c566 ("config.mak.uname: add sysinfo() configuration for cygwin", 2025-04-17) added a similar 'sysinfo()' check to the autoconf build. This check looked for the 'sysinfo()' function itself, rather than just the header, but it will fail (incorrectly set HAVE_SYSINFO) for the same reason. In order to correctly identify the 'sysinfo()' function we require as part of 'git-gc' (used in the 'total_ram() function), we also upgrade to a compilation check, in a similar way to the meson commit. Note that since commit c9a51775a3 ("builtin/gc.c: correct RAM calculation when using sysinfo", 2025-04-17) both the 'totalram' and 'mem_unit' fields of the 'struct sysinfo' are used, so the new check includes both of those fields in the compile check. Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano --- diff --git a/configure.ac b/configure.ac index d7e0503f1e..f6caab919a 100644 --- a/configure.ac +++ b/configure.ac @@ -1069,9 +1069,28 @@ GIT_CONF_SUBST([CHARSET_LIB]) # # Define HAVE_SYSINFO=YesPlease if sysinfo is available. -GIT_CHECK_FUNC(sysinfo, - [HAVE_SYSINFO=YesPlease], - [HAVE_SYSINFO=]) +# +AC_DEFUN([HAVE_SYSINFO_SRC], [ +AC_LANG_PROGRAM([[ +#include +#include +]], [[ +struct sysinfo si; +uint64_t t = 0; +if (!sysinfo(&si)) { + t = si.totalram; + if (si.mem_unit > 1) + t *= (uint64_t)si.mem_unit; +} +return t; +]])]) + +AC_MSG_CHECKING([for sysinfo]) +AC_COMPILE_IFELSE([HAVE_SYSINFO_SRC], + [AC_MSG_RESULT([yes]) + HAVE_SYSINFO=YesPlease], + [AC_MSG_RESULT([no]) + HAVE_SYSINFO=]) GIT_CONF_SUBST([HAVE_SYSINFO]) #