Message ID | 1364327453-22572-1-git-send-email-mark.kettenis@xs4all.nl (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tue, Mar 26, 2013 at 08:50:53PM +0100, Mark Kettenis wrote: > From: Mark Kettenis <kettenis@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. I bikeshedded slightly, as I could not see a compelling reason to completely replace the current code - I know it currently works. Thanks for the patch, pushed. -Chris
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