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 /lib/intel_drm.c | |
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>
Diffstat (limited to 'lib/intel_drm.c')
-rw-r--r-- | lib/intel_drm.c | 18 |
1 files changed, 17 insertions, 1 deletions
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); } |