Skip to content

Commit 187ce02

Browse files
ramsay-jonesgitster
authored andcommitted
configure.ac: upgrade to a compilation check for sysinfo
Commit f5e3c6c ("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 '<sys/sysinfo.h>' 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 50dec7c ("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 c9a5177 ("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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 837f637 commit 187ce02

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

configure.ac

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,9 +1069,28 @@ GIT_CONF_SUBST([CHARSET_LIB])
10691069

10701070
#
10711071
# Define HAVE_SYSINFO=YesPlease if sysinfo is available.
1072-
GIT_CHECK_FUNC(sysinfo,
1073-
[HAVE_SYSINFO=YesPlease],
1074-
[HAVE_SYSINFO=])
1072+
#
1073+
AC_DEFUN([HAVE_SYSINFO_SRC], [
1074+
AC_LANG_PROGRAM([[
1075+
#include <stdint.h>
1076+
#include <sys/sysinfo.h>
1077+
]], [[
1078+
struct sysinfo si;
1079+
uint64_t t = 0;
1080+
if (!sysinfo(&si)) {
1081+
t = si.totalram;
1082+
if (si.mem_unit > 1)
1083+
t *= (uint64_t)si.mem_unit;
1084+
}
1085+
return t;
1086+
]])])
1087+
1088+
AC_MSG_CHECKING([for sysinfo])
1089+
AC_COMPILE_IFELSE([HAVE_SYSINFO_SRC],
1090+
[AC_MSG_RESULT([yes])
1091+
HAVE_SYSINFO=YesPlease],
1092+
[AC_MSG_RESULT([no])
1093+
HAVE_SYSINFO=])
10751094
GIT_CONF_SUBST([HAVE_SYSINFO])
10761095

10771096
#

0 commit comments

Comments
 (0)