diff options
| author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2012-01-06 14:37:16 -0800 |
|---|---|---|
| committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-01-08 21:49:03 +0100 |
| commit | 9ebb860e3981db78ee31859dc77f1fce3ccc3183 (patch) | |
| tree | 26ff72f058b9d2cbdd1ac6e7884c9e26c8c7f971 | |
| parent | 65db78f687e757ca40ac42e9c26ddc769bd4cfcc (diff) | |
Provide Solaris implementation of intel_get_total_ram_mb
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
| -rw-r--r-- | configure.ac | 5 | ||||
| -rw-r--r-- | lib/intel_drm.c | 18 |
2 files changed, 22 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index b415a97b..00c05eed 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 c6cf21d4..f8eca7d8 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); } |
