freebsd-ports/graphics/mesa-dri/files/patch-src_intel_vulkan_anv__device.c
Jan Beich cd740e600a graphics/mesa-{libs,dri}: update to 18.3.2
Changes:	https://www.mesa3d.org/relnotes/18.3.0.html
Changes:	https://www.mesa3d.org/relnotes/18.3.1.html
Changes:	https://www.mesa3d.org/relnotes/18.3.2.html
PR:		233034
Tested by:	Kevin Oberman
Approved by:	maintainer timeout (2 weeks after 2019Q1)
Differential Revision:	https://reviews.freebsd.org/D17872
2019-01-17 15:34:55 +00:00

50 lines
1.3 KiB
C

- Without sysinfo() fall back to sysconf()
- Define ETIME if missing
- Define CLOCK_MONOTONIC_RAW if missing
--- src/intel/vulkan/anv_device.c.orig 2018-11-06 16:16:02 UTC
+++ 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>
@@ -44,6 +46,17 @@
#include "genxml/gen7_pack.h"
+#ifndef ETIME
+#define ETIME ETIMEDOUT
+#endif
+#ifndef CLOCK_MONOTONIC_RAW
+# ifdef CLOCK_MONOTONIC_FAST
+# define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC_FAST
+# else
+# define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
+# endif
+#endif
+
static void
compiler_debug_log(void *data, const char *fmt, ...)
{ }
@@ -64,10 +73,15 @@ static VkResult
anv_compute_heap_size(int fd, uint64_t gtt_size, 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.