Changeset View
Changeset View
Standalone View
Standalone View
graphics/mesa-dri/files/patch-src_intel_tools_aubinator.c
# We don't have MAP_NORESERVE so use MAP_NOSYNC | MAP_NOCORE and | - Partially implement memfd_create() via mkostemp() | ||||
# hope for the best (this alloc is too big but it's only a test) | |||||
# | --- src/intel/tools/aubinator.c.orig 2018-08-02 15:41:20 UTC | ||||
--- src/intel/tools/aubinator.c.orig 2017-10-02 15:49:02 UTC | |||||
+++ src/intel/tools/aubinator.c | +++ src/intel/tools/aubinator.c | ||||
@@ -637,7 +637,7 @@ int main(int argc, char *argv[]) | @@ -52,7 +52,29 @@ | ||||
/* mmap a terabyte for our gtt space. */ | static inline int | ||||
gtt_size = 1ull << 40; | memfd_create(const char *name, unsigned int flags) | ||||
gtt = mmap(NULL, gtt_size, PROT_READ | PROT_WRITE, | { | ||||
- MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0); | +#if defined(__linux__) | ||||
+ MAP_PRIVATE | MAP_ANONYMOUS | MAP_NOSYNC | MAP_NOCORE, -1, 0); | return syscall(SYS_memfd_create, name, flags); | ||||
if (gtt == MAP_FAILED) { | +#elif defined(__FreeBSD__) | ||||
fprintf(stderr, "failed to alloc gtt space: %s\n", strerror(errno)); | + return shm_open(SHM_ANON, flags | O_RDWR | O_CREAT, 0600); | ||||
exit(EXIT_FAILURE); | +#else /* DragonFly, NetBSD, OpenBSD, Solaris */ | ||||
+ char template[] = "/tmp/shmfd-XXXXXX"; | |||||
+#ifdef HAVE_MKOSTEMP | |||||
+ int fd = mkostemp(template, flags); | |||||
+#else | |||||
+ int fd = mkstemp(template); | |||||
+ if (flags & O_CLOEXEC) { | |||||
+ int flags = fcntl(fd, F_GETFD); | |||||
+ if (flags != -1) { | |||||
+ flags |= FD_CLOEXEC; | |||||
+ (void) fcntl(fd, F_SETFD, &flags); | |||||
+ } | |||||
+ } | |||||
+#endif /* HAVE_MKOSTEMP */ | |||||
+ if (fd >= 0) | |||||
+ unlink(template); | |||||
+ | |||||
+ return fd; | |||||
+#endif /* __linux__ */ | |||||
} | |||||
#endif | |||||