Use sysctl to get total ram on OpenBSD where sysinfo() is not available. Signed-off-by: Jonathan Gray <j...@jsg.id.au> --- src/intel/vulkan/anv_device.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 250f75e9936..81e3905ae99 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -25,7 +25,12 @@ #include <stdbool.h> #include <string.h> #include <sys/mman.h> +#ifdef __OpenBSD__ +#include <sys/types.h> +#include <sys/sysctl.h> +#else #include <sys/sysinfo.h> +#endif #include <unistd.h> #include <fcntl.h> #include <xf86drm.h> @@ -97,10 +102,19 @@ static uint64_t anv_compute_heap_size(int fd, uint64_t gtt_size) { /* Query the total ram from the system */ +#ifdef __OpenBSD__ + int mib[] = { CTL_HW, HW_PHYSMEM64 }; + int64_t total_ram; + size_t size = sizeof(total_ram); + + if (sysctl(mib, 2, &total_ram, &size, NULL, 0) == -1) + return 0; +#else struct sysinfo info; sysinfo(&info); uint64_t total_ram = (uint64_t)info.totalram * (uint64_t)info.mem_unit; +#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.24.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev