diff options
author | Greg V <[email protected]> | 2018-01-18 23:29:14 +0300 |
---|---|---|
committer | Eric Engestrom <[email protected]> | 2019-08-07 22:57:55 +0000 |
commit | c0376a123418df0050dc45d3e1e84f6b29a6a1f3 (patch) | |
tree | cf94494957e38609c5fbd464e53f10652dbf9909 /src/intel/vulkan/anv_gem_stubs.c | |
parent | 519bebdb40d9df5926e8b16dedd36b8e0f356f60 (diff) |
util: add anon_file.h for all memfd/temp file usage
Move the Weston os_create_anonymous_file code from egl/wayland into util,
add support for Linux memfd and FreeBSD SHM_ANON,
use that code in anv/aubinator instead of explicit memfd calls for portability.
Acked-by: Lionel Landwerlin <[email protected]>
Reviewed-by: Eric Engestrom <[email protected]>
Diffstat (limited to 'src/intel/vulkan/anv_gem_stubs.c')
-rw-r--r-- | src/intel/vulkan/anv_gem_stubs.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/src/intel/vulkan/anv_gem_stubs.c b/src/intel/vulkan/anv_gem_stubs.c index 8cc3ad1f22e..2c27ce26f37 100644 --- a/src/intel/vulkan/anv_gem_stubs.c +++ b/src/intel/vulkan/anv_gem_stubs.c @@ -21,32 +21,21 @@ * IN THE SOFTWARE. */ -#include <linux/memfd.h> #include <sys/mman.h> #include <sys/syscall.h> +#include "util/anon_file.h" #include "anv_private.h" -#ifndef HAVE_MEMFD_CREATE -static inline int -memfd_create(const char *name, unsigned int flags) -{ - return syscall(SYS_memfd_create, name, flags); -} -#endif - uint32_t anv_gem_create(struct anv_device *device, uint64_t size) { - int fd = memfd_create("fake bo", MFD_CLOEXEC); + int fd = os_create_anonymous_file(size, "fake bo"); if (fd == -1) return 0; assert(fd != 0); - if (ftruncate(fd, size) == -1) - return 0; - return fd; } |