mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-22 20:25:39 +02:00
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 <pthread.h>
|
||||||
|
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#ifdef __linux__
|
#include <fcntl.h>
|
||||||
#include <linux/memfd.h>
|
|
||||||
#endif
|
|
||||||
#include <linux/input-event-codes.h>
|
#include <linux/input-event-codes.h>
|
||||||
|
|
||||||
#include <pixman.h>
|
#include <pixman.h>
|
||||||
|
@ -771,7 +769,16 @@ get_buffer(struct wayland_backend *backend)
|
||||||
pixman_image_t *pix = NULL;
|
pixman_image_t *pix = NULL;
|
||||||
|
|
||||||
/* Backing memory for SHM */
|
/* Backing memory for SHM */
|
||||||
|
#if defined(MEMFD_CREATE)
|
||||||
pool_fd = memfd_create("yambar-wayland-shm-buffer-pool", MFD_CLOEXEC);
|
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) {
|
if (pool_fd == -1) {
|
||||||
LOG_ERRNO("failed to create SHM backing memory file");
|
LOG_ERRNO("failed to create SHM backing memory file");
|
||||||
goto err;
|
goto err;
|
||||||
|
|
|
@ -12,6 +12,10 @@ plugs_as_libs = get_option('core-plugins-as-shared-libraries')
|
||||||
|
|
||||||
cc = meson.get_compiler('c')
|
cc = meson.get_compiler('c')
|
||||||
|
|
||||||
|
if cc.has_function('memfd_create')
|
||||||
|
add_project_arguments('-DMEMFD_CREATE', language: 'c')
|
||||||
|
endif
|
||||||
|
|
||||||
# Compute the relative path used by compiler invocations.
|
# Compute the relative path used by compiler invocations.
|
||||||
source_root = meson.current_source_dir().split('/')
|
source_root = meson.current_source_dir().split('/')
|
||||||
build_root = meson.build_root().split('/')
|
build_root = meson.build_root().split('/')
|
||||||
|
|
Loading…
Add table
Reference in a new issue