From 93fd77e01b25f2cec62b252e077d48f73dc76c9a Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Tue, 19 Jan 2021 15:22:51 +0000 Subject: [PATCH] shm: disable fallocate optimization if not supported shm.c:301:26: error: implicit declaration of function 'fallocate' is invalid in C99 [-Werror,-Wimplicit-function-declaration] can_punch_hole = fallocate( ^ shm.c:302:22: error: use of undeclared identifier 'FALLOC_FL_PUNCH_HOLE' pool_fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 1) == 0; ^ shm.c:302:45: error: use of undeclared identifier 'FALLOC_FL_KEEP_SIZE' pool_fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 1) == 0; ^ shm.c:432:9: error: implicit declaration of function 'fallocate' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (fallocate( ^ shm.c:434:13: error: use of undeclared identifier 'FALLOC_FL_PUNCH_HOLE' FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, ^ shm.c:434:36: error: use of undeclared identifier 'FALLOC_FL_KEEP_SIZE' FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, ^ shm.c:501:9: error: implicit declaration of function 'fallocate' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (fallocate( ^ shm.c:503:13: error: use of undeclared identifier 'FALLOC_FL_PUNCH_HOLE' FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, ^ shm.c:503:36: error: use of undeclared identifier 'FALLOC_FL_KEEP_SIZE' FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, ^ shm.c:597:9: error: implicit declaration of function 'fallocate' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (fallocate( ^ shm.c:599:13: error: use of undeclared identifier 'FALLOC_FL_PUNCH_HOLE' FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, ^ shm.c:599:36: error: use of undeclared identifier 'FALLOC_FL_KEEP_SIZE' FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, ^ --- shm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/shm.c b/shm.c index c2cd4dcf..81de653b 100644 --- a/shm.c +++ b/shm.c @@ -299,7 +299,7 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie, if (!can_punch_hole_initialized) { can_punch_hole_initialized = true; -#if defined(__x86_64__) +#if defined(__x86_64__) && defined(FALLOC_FL_PUNCH_HOLE) can_punch_hole = fallocate( pool_fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 1) == 0; @@ -410,6 +410,7 @@ shm_can_scroll(const struct buffer *buf) #endif } +#if defined(FALLOC_FL_PUNCH_HOLE) static bool wrap_buffer(struct wl_shm *shm, struct buffer *buf, off_t new_offset) { @@ -642,12 +643,14 @@ err: abort(); return false; } +#endif /* FALLOC_FL_PUNCH_HOLE */ bool shm_scroll(struct wl_shm *shm, struct buffer *buf, int rows, int top_margin, int top_keep_rows, int bottom_margin, int bottom_keep_rows) { +#if defined(FALLOC_FL_PUNCH_HOLE) if (!shm_can_scroll(buf)) return false; @@ -655,6 +658,9 @@ shm_scroll(struct wl_shm *shm, struct buffer *buf, int rows, return rows > 0 ? shm_scroll_forward(shm, buf, rows, top_margin, top_keep_rows, bottom_margin, bottom_keep_rows) : shm_scroll_reverse(shm, buf, -rows, top_margin, top_keep_rows, bottom_margin, bottom_keep_rows); +#else + return false; +#endif } void