Skip to content

Commit f5e3c6c

Browse files
eli-schwartzgitster
authored andcommitted
meson: do a full usage-based compile check for sysinfo
On Solaris, sys/sysinfo.h is a completely different file and doesn't resemble the linux file at all. There is also a sysinfo() function, but it takes a totally different call signature, which asks for: - the field you wish to receive - a `char *buf` to copy the data to and is very useful IFF you want to know, say, the hardware provider. Or, get *specific* fields from uname(2). https://docs.oracle.com/cd/E86824_01/html/E54765/sysinfo-2.html It is surely possible to do this manually via `sysconf(3)` without the nice API. I can't find anything more direct. Either way, I'm not very attached to Solaris, so someone who cares can add it. Either way, it's wrong to assume that sysinfo.h contains what we are looking for. Check that sysinfo.h defines the struct we actually utilize in builtins/gc.c, which will correctly fail on systems that don't have it. Signed-off-by: Eli Schwartz <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 945090d commit f5e3c6c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

meson.build

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,10 +1058,6 @@ if compiler.has_header('alloca.h')
10581058
libgit_c_args += '-DHAVE_ALLOCA_H'
10591059
endif
10601060

1061-
if compiler.has_header('sys/sysinfo.h')
1062-
libgit_c_args += '-DHAVE_SYSINFO'
1063-
endif
1064-
10651061
# Windows has libgen.h and a basename implementation, but we still need our own
10661062
# implementation to threat things like drive prefixes specially.
10671063
if host_machine.system() == 'windows' or not compiler.has_header('libgen.h')
@@ -1267,6 +1263,10 @@ if host_machine.system() != 'windows'
12671263
endif
12681264
endif
12691265

1266+
if compiler.has_member('struct sysinfo', 'totalram', prefix: '#include <sys/sysinfo.h>')
1267+
libgit_c_args += '-DHAVE_SYSINFO'
1268+
endif
1269+
12701270
if compiler.has_member('struct stat', 'st_mtimespec.tv_nsec', prefix: '#include <sys/stat.h>')
12711271
libgit_c_args += '-DUSE_ST_TIMESPEC'
12721272
elif not compiler.has_member('struct stat', 'st_mtim.tv_nsec', prefix: '#include <sys/stat.h>')

0 commit comments

Comments
 (0)