[PATCH:intel-gpu-tools 1/6] Provide Solaris implementation of intel_get_total_ram_mb

Alan Coopersmith alan.coopersmith at oracle.com
Fri Jan 6 14:37:16 PST 2012


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 configure.ac    |    5 +++++
 lib/intel_drm.c |   18 +++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index b415a97..00c05ee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,6 +34,11 @@ AC_CONFIG_AUX_DIR([build-aux])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE
 
+# Checks for functions, headers, structures, etc.
+AC_CHECK_MEMBERS([struct sysinfo.totalram],[],[],[AC_INCLUDES_DEFAULT
+#include <sys/sysinfo.h>
+])
+
 # Initialize libtool
 AC_DISABLE_STATIC
 AC_PROG_LIBTOOL
diff --git a/lib/intel_drm.c b/lib/intel_drm.c
index c6cf21d..f8eca7d 100644
--- a/lib/intel_drm.c
+++ b/lib/intel_drm.c
@@ -25,6 +25,8 @@
  *
  */
 
+#include "config.h"
+
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -36,7 +38,9 @@
 #include <sys/fcntl.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
+#ifdef HAVE_STRUCT_SYSINFO_TOTALRAM
 #include <sys/sysinfo.h>
+#endif
 
 #include "intel_gpu_tools.h"
 #include "i915_drm.h"
@@ -78,8 +82,10 @@ int intel_gen(uint32_t devid)
 uint64_t
 intel_get_total_ram_mb(void)
 {
-	struct sysinfo sysinf;
 	uint64_t retval;
+
+#ifdef HAVE_STRUCT_SYSINFO_TOTALRAM /* Linux */
+	struct sysinfo sysinf;
 	int ret;
 
 	ret = sysinfo(&sysinf);
@@ -87,6 +93,16 @@ intel_get_total_ram_mb(void)
 
 	retval = sysinf.totalram;
 	retval *= sysinf.mem_unit;
+#elif defined(_SC_PAGESIZE) && defined(_SC_PHYS_PAGES) /* Solaris */
+	long pagesize, npages;
+
+	pagesize = sysconf(_SC_PAGESIZE);
+        npages = sysconf(_SC_PHYS_PAGES);
+
+	retval = pagesize * npages;
+#else
+#error "Unknown how to get RAM size for this OS"
+#endif
 
 	return retval / (1024*1024);
 }
-- 
1.7.3.2



More information about the xorg-devel mailing list