From 64fdb508cf0f253b80634bac4f514eef38487ba3 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Mon, 11 May 2015 17:46:21 +0100 Subject: [PATCH] Fix compilation when sys/sysctl.h is not present Fix compilation since commit 5b2d3480f57168d50ad24cf0b8c9244414bd3701 "swrast: Build fix for darwin", which unconditionally includes sys/syctl.h Signed-off-by: Jon TURNEY --- src/mesa/drivers/dri/swrast/swrast.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index 2ddb474..ed6ec2f 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -61,8 +61,10 @@ #include "swrast_priv.h" #include "swrast/s_context.h" +#if !defined(_SC_PHYS_PAGES) || !defined(_SC_PAGE_SIZE) #include #include +#endif const __DRIextension **__driDriverGetExtensions_swrast(void); @@ -143,13 +145,7 @@ swrast_query_renderer_integer(__DRIscreen *psp, int param, /* 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) +#if 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); @@ -159,7 +155,12 @@ 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 +#elif 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; #error "Unsupported platform" #endif -- 2.1.4