summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@openbsd.org>2013-03-26 20:50:53 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-03-26 20:18:10 +0000
commit3dddb01005274376c8cdc5eecad36d4e0723004a (patch)
tree842c0af39d7c819cd682bfa5d8589ecc2facb700
parente63390df52117e1d3ca9d23a736e9995bc734765 (diff)
sna: Use a more portable way to determine total RAM size
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@openbsd.org>
-rw-r--r--configure.ac2
-rw-r--r--src/sna/kgem.c4
2 files changed, 5 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index de3990d1..8b12d01a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -200,12 +200,12 @@ 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
if test "x$SNA" != "xno"; then
AC_DEFINE(USE_SNA, 1, [Enable SNA support])
+ AC_CHECK_HEADERS([sys/sysinfo.h])
fi
AC_MSG_CHECKING([whether to include SNA support])
AM_CONDITIONAL(SNA, test x$SNA != xno)
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index c6ed1143..231dc8e7 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -647,6 +647,10 @@ total_ram_size(void)
return info.totalram * info.mem_unit;
#endif
+#ifdef _SC_PHYS_PAGES
+ return sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGE_SIZE);
+#endif
+
return 0;
}