From 0d07ee03f59cd179758751d5cd2cc6bfbfef7ff9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 21 Jan 2021 12:39:51 +0100 Subject: [PATCH] =?UTF-8?q?shm:=20don=E2=80=99t=20check=20for=20=5F=5Fi386?= =?UTF-8?q?=5F=5F=20and=20=5F=5Fx86=5F64=5F=5F=20-=20there=20are=20other?= =?UTF-8?q?=20architectures=20out=20there?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead, check for __SIZEOF_POINTER__ == 8, since what we’re really interested in is whether we have enough virtual address space or not. --- shm.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/shm.c b/shm.c index ac941f92..2ec581c4 100644 --- a/shm.c +++ b/shm.c @@ -129,7 +129,7 @@ static const struct wl_buffer_listener buffer_listener = { .release = &buffer_release, }; -#if !defined(__i386__) +#if __SIZEOF_POINTER__ == 8 static size_t page_size(void) { @@ -290,12 +290,12 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie, goto err; } -#if defined(__i386__) - off_t initial_offset = 0; - off_t memfd_size = size; -#else +#if __SIZEOF_POINTER__ == 8 off_t initial_offset = scrollable && max_pool_size > 0 ? (max_pool_size / 4) & ~(page_size() - 1) : 0; off_t memfd_size = scrollable && max_pool_size > 0 ? max_pool_size : size; +#else + off_t initial_offset = 0; + off_t memfd_size = size; #endif LOG_DBG("memfd-size: %lu, initial offset: %lu", memfd_size, initial_offset); @@ -307,7 +307,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__) && defined(FALLOC_FL_PUNCH_HOLE) +#if __SIZEOF_POINTER__ == 8 && defined(FALLOC_FL_PUNCH_HOLE) can_punch_hole = fallocate( pool_fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 1) == 0; @@ -412,15 +412,15 @@ err: bool shm_can_scroll(const struct buffer *buf) { -#if defined(__i386__) +#if __SIZEOF_POINTER__ == 8 + return can_punch_hole && max_pool_size > 0 && buf->scrollable; +#else /* Not enough virtual address space in 32-bit */ return false; -#else - return can_punch_hole && max_pool_size > 0 && buf->scrollable; #endif } -#if defined(FALLOC_FL_PUNCH_HOLE) +#if __SIZEOF_POINTER__ == 8 && defined(FALLOC_FL_PUNCH_HOLE) static bool wrap_buffer(struct wl_shm *shm, struct buffer *buf, off_t new_offset) { @@ -660,7 +660,7 @@ 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 __SIZEOF_POINTER__ == 8 && defined(FALLOC_FL_PUNCH_HOLE) if (!shm_can_scroll(buf)) return false;