From b25e230df828ded199d5648380a273ebbd3c5607 Mon Sep 17 00:00:00 2001 From: sghctoma Date: Thu, 8 Nov 2018 13:48:21 +0100 Subject: [PATCH 1/3] Force ftruncate for shared mem. objects on FreeBSD FreeBSD does not allow to use posix_fallocate on shared memory objects. --- util/shm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/shm.c b/util/shm.c index 3783e473..b4e8d087 100644 --- a/util/shm.c +++ b/util/shm.c @@ -42,7 +42,7 @@ int allocate_shm_file(size_t size) { return -1; } -#ifdef WLR_HAS_POSIX_FALLOCATE +#if defined(WLR_HAS_POSIX_FALLOCATE) && !defined(__FreeBSD__) int ret; do { ret = posix_fallocate(fd, 0, size); From bc5e84225c4ccf1a7a7cfa51533c80338fc85635 Mon Sep 17 00:00:00 2001 From: sghctoma Date: Fri, 9 Nov 2018 18:29:19 +0100 Subject: [PATCH 2/3] Use ftruncate to set shared memory object's size The posix_fallocate function should only be used with regular files. --- util/shm.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/util/shm.c b/util/shm.c index b4e8d087..f7c7303e 100644 --- a/util/shm.c +++ b/util/shm.c @@ -42,17 +42,6 @@ int allocate_shm_file(size_t size) { return -1; } -#if defined(WLR_HAS_POSIX_FALLOCATE) && !defined(__FreeBSD__) - int ret; - do { - ret = posix_fallocate(fd, 0, size); - } while (ret == EINTR); - if (ret != 0) { - close(fd); - errno = ret; - return -1; - } -#else int ret; do { ret = ftruncate(fd, size); @@ -61,7 +50,6 @@ int allocate_shm_file(size_t size) { close(fd); return -1; } -#endif return fd; } From 753540335b8ff2e339402dce6500416333899416 Mon Sep 17 00:00:00 2001 From: sghctoma Date: Fri, 9 Nov 2018 18:48:10 +0100 Subject: [PATCH 3/3] Remove WLR_HAS_POSIX_FALLOCATE from build system --- include/wlr/config.h.in | 2 -- meson.build | 4 ---- 2 files changed, 6 deletions(-) diff --git a/include/wlr/config.h.in b/include/wlr/config.h.in index 750ad3b7..17277c07 100644 --- a/include/wlr/config.h.in +++ b/include/wlr/config.h.in @@ -14,6 +14,4 @@ #mesondefine WLR_HAS_XCB_ICCCM #mesondefine WLR_HAS_XCB_XKB -#mesondefine WLR_HAS_POSIX_FALLOCATE - #endif diff --git a/meson.build b/meson.build index 18a5d908..1ed93c04 100644 --- a/meson.build +++ b/meson.build @@ -72,10 +72,6 @@ if logind.found() wlr_deps += logind endif -if cc.has_header_symbol('fcntl.h', 'posix_fallocate', prefix: '#define _POSIX_C_SOURCE 200112L') - conf_data.set('WLR_HAS_POSIX_FALLOCATE', true) -endif - subdir('protocol') subdir('render')