forked from external/yambar
wayland: unbreak build without memfd_create
New FreeBSD versions have memfd_create but other BSDs don't. bar/wayland.c:774:15: error: implicit declaration of function 'memfd_create' is invalid in C99 [-Werror,-Wimplicit-function-declaration] pool_fd = memfd_create("yambar-wayland-shm-buffer-pool", MFD_CLOEXEC); ^ bar/wayland.c:774:62: error: use of undeclared identifier 'MFD_CLOEXEC' pool_fd = memfd_create("yambar-wayland-shm-buffer-pool", MFD_CLOEXEC); ^
This commit is contained in:
parent
f8e544ae05
commit
ec465ba3b3
2 changed files with 14 additions and 3 deletions
|
@ -9,9 +9,7 @@
|
|||
#include <pthread.h>
|
||||
|
||||
#include <sys/mman.h>
|
||||
#ifdef __linux__
|
||||
#include <linux/memfd.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <linux/input-event-codes.h>
|
||||
|
||||
#include <pixman.h>
|
||||
|
@ -771,7 +769,16 @@ get_buffer(struct wayland_backend *backend)
|
|||
pixman_image_t *pix = NULL;
|
||||
|
||||
/* Backing memory for SHM */
|
||||
#if defined(MEMFD_CREATE)
|
||||
pool_fd = memfd_create("yambar-wayland-shm-buffer-pool", MFD_CLOEXEC);
|
||||
#elif defined(__FreeBSD__)
|
||||
// memfd_create on FreeBSD 13 is SHM_ANON without sealing support
|
||||
pool_fd = shm_open(SHM_ANON, O_RDWR | O_CLOEXEC, 0600);
|
||||
#else
|
||||
char name[] = "/tmp/yambar-wayland-shm-buffer-pool-XXXXXX";
|
||||
pool_fd = mkostemp(name, O_CLOEXEC);
|
||||
unlink(name);
|
||||
#endif
|
||||
if (pool_fd == -1) {
|
||||
LOG_ERRNO("failed to create SHM backing memory file");
|
||||
goto err;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue