Mesa (master): swrast: Build fix for darwin

Brian Paul brianp at kemper.freedesktop.org
Wed May 6 16:03:08 UTC 2015


Module: Mesa
Branch: master
Commit: 5b2d3480f57168d50ad24cf0b8c9244414bd3701
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5b2d3480f57168d50ad24cf0b8c9244414bd3701

Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Thu Jan  1 19:48:40 2015 -0800

swrast: Build fix for darwin

Fixes regression from commit 64b1dc44495890cbc2c7c5509cb830264020998c

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90147
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Reviewed-by: Brian Paul <brianp at vmware.com>
CC: Emil Velikov <emil.l.velikov at gmail.com>
CC: jon.turney at dronecode.org.uk
CC: ionic at macports.org

---

 src/mesa/drivers/dri/swrast/swrast.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c
index d1bb721..2ddb474 100644
--- a/src/mesa/drivers/dri/swrast/swrast.c
+++ b/src/mesa/drivers/dri/swrast/swrast.c
@@ -61,6 +61,9 @@
 #include "swrast_priv.h"
 #include "swrast/s_context.h"
 
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
 const __DRIextension **__driDriverGetExtensions_swrast(void);
 
 const char * const swrast_vendor_string = "Mesa Project";
@@ -137,6 +140,16 @@ swrast_query_renderer_integer(__DRIscreen *psp, int param,
       value[0] = 0;
       return 0;
    case __DRI2_RENDERER_VIDEO_MEMORY: {
+      /* This should probably share code with os_get_total_physical_memory()
+       * from src/gallium/auxiliary/os/os_misc.c
+       */
+#if defined(CTL_HW) && defined(HW_MEMSIZE)
+        int mib[2] = { CTL_HW, HW_MEMSIZE };
+        unsigned long system_memory_bytes;
+        size_t len = sizeof(system_memory_bytes);
+        if (sysctl(mib, 2, &system_memory_bytes, &len, NULL, 0) != 0)
+            return -1;
+#elif defined(_SC_PHYS_PAGES) && defined(_SC_PAGE_SIZE)
       /* XXX: Do we want to return the full amount of system memory ? */
       const long system_memory_pages = sysconf(_SC_PHYS_PAGES);
       const long system_page_size = sysconf(_SC_PAGE_SIZE);
@@ -146,6 +159,9 @@ swrast_query_renderer_integer(__DRIscreen *psp, int param,
 
       const uint64_t system_memory_bytes = (uint64_t) system_memory_pages
          * (uint64_t) system_page_size;
+#else
+#error "Unsupported platform"
+#endif
 
       const unsigned system_memory_megabytes =
          (unsigned) (system_memory_bytes / (1024 * 1024));




More information about the mesa-commit mailing list