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>
This commit is contained in:
Alan Coopersmith 2012-01-06 14:37:16 -08:00 committed by Daniel Vetter
parent 65db78f687
commit 9ebb860e39
2 changed files with 22 additions and 1 deletions

View File

@ -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

View File

@ -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);
}