[Mesa-dev] [PATCH 05/14] anv: use POSIX sysconf to get memory info on non-glibc systems
Greg V
greg at unrelenting.technology
Sun Dec 31 16:55:19 UTC 2017
---
src/intel/vulkan/anv_device.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 6f77d33f93..2d3062d103 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -25,7 +25,9 @@
#include <stdbool.h>
#include <string.h>
#include <sys/mman.h>
+#ifdef __GLIBC__
#include <sys/sysinfo.h>
+#endif
#include <unistd.h>
#include <fcntl.h>
#include <xf86drm.h>
@@ -79,10 +81,15 @@ anv_compute_heap_size(int fd, uint64_t *heap_size)
}
/* Query the total ram from the system */
+#ifdef __GLIBC__
struct sysinfo info;
sysinfo(&info);
uint64_t total_ram = (uint64_t)info.totalram * (uint64_t)info.mem_unit;
+#else
+ uint64_t total_ram = sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGE_SIZE);
+#endif
+
/* We don't want to burn too much ram with the GPU. If the user has 4GiB
* or less, we use at most half. If they have more than 4GiB, we use 3/4.
--
2.15.1
More information about the mesa-dev
mailing list