Lines 1-30
Link Here
|
1 |
- Partially implement sys_futex() via _umtx_op() |
|
|
2 |
- Partially implement memfd_create() via mkostemp() |
1 |
- Partially implement memfd_create() via mkostemp() |
3 |
- Ignore MAP_POPULATE if unsupported |
2 |
- Ignore MAP_POPULATE if unsupported |
4 |
|
3 |
|
5 |
--- src/intel/vulkan/anv_allocator.c.orig 2017-08-12 16:09:52 UTC |
4 |
--- src/intel/vulkan/anv_allocator.c.orig 2018-01-23 18:08:50 UTC |
6 |
+++ src/intel/vulkan/anv_allocator.c |
5 |
+++ src/intel/vulkan/anv_allocator.c |
7 |
@@ -26,12 +26,31 @@ |
6 |
@@ -25,9 +25,21 @@ |
8 |
#include <unistd.h> |
7 |
#include <unistd.h> |
9 |
#include <limits.h> |
8 |
#include <limits.h> |
10 |
#include <assert.h> |
9 |
#include <assert.h> |
11 |
+#ifdef __linux__ |
10 |
+#ifdef __linux__ |
12 |
#include <linux/futex.h> |
|
|
13 |
#include <linux/memfd.h> |
11 |
#include <linux/memfd.h> |
14 |
+#endif |
|
|
15 |
#include <sys/time.h> |
16 |
#include <sys/mman.h> |
17 |
+#ifdef __linux__ |
18 |
#include <sys/syscall.h> |
19 |
+#else |
12 |
+#else |
20 |
+#include <fcntl.h> |
13 |
+#include <fcntl.h> |
21 |
+#endif |
14 |
+#endif |
|
|
15 |
#include <sys/mman.h> |
22 |
|
16 |
|
23 |
+#ifdef __FreeBSD__ |
|
|
24 |
+#include <errno.h> |
25 |
+#include <sys/umtx.h> |
26 |
+#endif |
27 |
+ |
28 |
+#ifndef MAP_POPULATE |
17 |
+#ifndef MAP_POPULATE |
29 |
+#define MAP_POPULATE 0 |
18 |
+#define MAP_POPULATE 0 |
30 |
+#endif |
19 |
+#endif |
Lines 36-78
Link Here
|
36 |
#include "anv_private.h" |
25 |
#include "anv_private.h" |
37 |
|
26 |
|
38 |
#include "util/hash_table.h" |
27 |
#include "util/hash_table.h" |
39 |
@@ -112,6 +131,8 @@ struct anv_mmap_cleanup { |
28 |
@@ -113,7 +125,29 @@ struct anv_mmap_cleanup { |
40 |
|
|
|
41 |
#define ANV_MMAP_CLEANUP_INIT ((struct anv_mmap_cleanup){0}) |
42 |
|
43 |
+#if defined(__linux__) |
44 |
+ |
45 |
static inline long |
46 |
sys_futex(void *addr1, int op, int val1, |
47 |
struct timespec *timeout, void *addr2, int val3) |
48 |
@@ -131,11 +152,56 @@ futex_wait(uint32_t *addr, int32_t value) |
49 |
return sys_futex(addr, FUTEX_WAIT, value, NULL, NULL, 0); |
50 |
} |
51 |
|
52 |
+#elif defined(__FreeBSD__) |
53 |
+ |
54 |
+/* Based on libxshmfence */ |
55 |
+ |
56 |
+static inline int |
57 |
+sys_futex(void *addr, int op, int32_t val) |
58 |
+{ |
59 |
+ return _umtx_op(addr, op, (uint32_t)val, NULL, NULL) == -1 ? errno : 0; |
60 |
+} |
61 |
+ |
62 |
+static inline int |
63 |
+futex_wake(uint32_t *addr, int count) |
64 |
+{ |
65 |
+ return sys_futex(addr, UMTX_OP_WAKE, count); |
66 |
+} |
67 |
+ |
68 |
+static inline int |
69 |
+futex_wait(uint32_t *addr, int32_t value) |
70 |
+{ |
71 |
+ return sys_futex(addr, UMTX_OP_WAIT_UINT, value); |
72 |
+} |
73 |
+#endif |
74 |
+ |
75 |
#ifndef HAVE_MEMFD_CREATE |
76 |
static inline int |
29 |
static inline int |
77 |
memfd_create(const char *name, unsigned int flags) |
30 |
memfd_create(const char *name, unsigned int flags) |
78 |
{ |
31 |
{ |