From: Mark Kettenis <kettenis at openbsd.org> The sysinfo function is Linux-specific. sysconf(_SC_PHYS_PAGES), while not truly portable, is available on many more systems, including Linux, Solaris, NetBSD, FreeBSD and OpenBSD. So use that instead. Verified that this results in the same value as the sysinfo call on a handful of Linux systems. Signed-off-by: Mark Kettenis <kettenis at openbsd.org> --- configure.ac | 1 - src/sna/kgem.c | 14 ++++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index de3990d..88e2c80 100644 --- a/configure.ac +++ b/configure.ac @@ -200,7 +200,6 @@ AC_ARG_ENABLE(sna, [SNA="$enableval"], [SNA=auto]) -AC_CHECK_HEADERS([sys/sysinfo.h], , SNA=no) if test "x$SNA" = "xauto" && pkg-config --exists "xorg-server >= 1.10"; then SNA=yes fi diff --git a/src/sna/kgem.c b/src/sna/kgem.c index c6ed114..20f774a 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -46,10 +46,6 @@ #include <memcheck.h> #endif -#if HAVE_SYS_SYSINFO_H -#include <sys/sysinfo.h> -#endif - static struct kgem_bo * search_linear_cache(struct kgem *kgem, unsigned int num_pages, unsigned flags); @@ -641,13 +637,11 @@ agp_aperture_size(struct pci_device *dev, unsigned gen) static size_t total_ram_size(void) { -#if HAVE_SYS_SYSINFO_H - struct sysinfo info; - if (sysinfo(&info) == 0) - return info.totalram * info.mem_unit; -#endif - +#ifdef _SC_PHYS_PAGES + return sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGE_SIZE); +#else return 0; +#endif } static size_t -- 1.8.1.2