From 3c379b243b26dd1cce8b5f5da0bc06eba775e740 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Tue, 19 Jan 2021 14:38:45 +0000 Subject: [PATCH 01/20] main: correct header for mode macros main.c:13:10: fatal error: 'sys/sysinfo.h' file not found #include ^~~~~~~~~~~~~~~ main.c:122:28: error: use of undeclared identifier 'S_IRUSR' S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) { ^ main.c:122:38: error: use of undeclared identifier 'S_IWUSR' S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) { ^ main.c:122:48: error: use of undeclared identifier 'S_IRGRP' S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) { ^ main.c:122:58: error: use of undeclared identifier 'S_IROTH' S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) { ^ --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 2775a50d..c0dad5e3 100644 --- a/main.c +++ b/main.c @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include From 567a8de3b08392f049b6a2e3ce7d2a5a8ba4e0ed Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Tue, 19 Jan 2021 14:34:30 +0000 Subject: [PATCH 02/20] client/server: switch to POSIX header for sockaddr_un client.c:13:10: fatal error: 'linux/un.h' file not found #include ^~~~~~~~~~~~ client.c:195:24: error: variable has incomplete type 'struct sockaddr_un' struct sockaddr_un addr = {.sun_family = AF_UNIX}; ^ client.c:195:12: note: forward declaration of 'struct sockaddr_un' struct sockaddr_un addr = {.sun_family = AF_UNIX}; ^ server.c:11:10: fatal error: 'linux/un.h' file not found #include ^~~~~~~~~~~~ server.c:307:24: error: variable has incomplete type 'struct sockaddr_un' struct sockaddr_un addr; ^ server.c:307:12: note: forward declaration of 'struct sockaddr_un' struct sockaddr_un addr; ^ server.c:347:24: error: variable has incomplete type 'struct sockaddr_un' struct sockaddr_un addr = {.sun_family = AF_UNIX}; ^ server.c:347:12: note: forward declaration of 'struct sockaddr_un' struct sockaddr_un addr = {.sun_family = AF_UNIX}; ^ server.c:394:24: error: variable has incomplete type 'struct sockaddr_un' struct sockaddr_un addr = {.sun_family = AF_UNIX}; ^ server.c:394:12: note: forward declaration of 'struct sockaddr_un' struct sockaddr_un addr = {.sun_family = AF_UNIX}; ^ --- client.c | 2 +- server.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client.c b/client.c index 80eb8b40..9a347562 100644 --- a/client.c +++ b/client.c @@ -9,7 +9,7 @@ #include #include -#include +#include #define LOG_MODULE "foot-client" #define LOG_ENABLE_DBG 0 diff --git a/server.c b/server.c index c5db036d..7a4101ea 100644 --- a/server.c +++ b/server.c @@ -8,7 +8,7 @@ #include #include -#include +#include #include From ce7df7cc1f887232202e2695db4779542ab62255 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Tue, 19 Jan 2021 15:05:22 +0000 Subject: [PATCH 03/20] terminal: add/exclude missing headers terminal.c:3:10: fatal error: 'malloc.h' file not found #include ^~~~~~~~~~ terminal.c:1512:9: error: implicit declaration of function 'sigaction' is invalid in C99 [-Werror,-Wimplicit-function-declaration] sigaction(SIGALRM, &(const struct sigaction){.sa_handler = &sig_alarm}, NULL); ^ terminal.c:1532:21: error: implicit declaration of function 'kill' is invalid in C99 [-Werror,-Wimplicit-function-declaration] kill(term->slave, kill_signal); ^ --- terminal.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/terminal.c b/terminal.c index 312da6dd..bb62195d 100644 --- a/terminal.c +++ b/terminal.c @@ -1,6 +1,9 @@ #include "terminal.h" +#if defined(__GLIBC__) #include +#endif +#include #include #include #include From c531c6bc0e0e91722ec99da376d556af46b22bbc Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Tue, 19 Jan 2021 14:41:02 +0000 Subject: [PATCH 04/20] uri: switch to conservative maximum hostname length Current maximum is provided by sysconf(_SC_HOST_NAME_MAX) instead. uri.c:269:20: error: use of undeclared identifier 'HOST_NAME_MAX' char this_host[HOST_NAME_MAX]; ^ --- uri.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uri.c b/uri.c index 21eba6fb..51cd8093 100644 --- a/uri.c +++ b/uri.c @@ -266,7 +266,7 @@ err: bool hostname_is_localhost(const char *hostname) { - char this_host[HOST_NAME_MAX]; + char this_host[_POSIX_HOST_NAME_MAX]; if (gethostname(this_host, sizeof(this_host)) < 0) this_host[0] = '\0'; From 67e713ff3adc1f94087d1016e775d20f89a8675d Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Tue, 19 Jan 2021 15:09:06 +0000 Subject: [PATCH 05/20] slave: skip e310487dae99 if not supported slave.c:188:26: error: use of undeclared identifier 'IUTF8' flags.c_iflag |= IUTF8; ^ --- slave.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/slave.c b/slave.c index 79008e5d..29ad92f5 100644 --- a/slave.c +++ b/slave.c @@ -178,6 +178,7 @@ slave_exec(int ptmx, char *argv[], int err_fd, bool login_shell, goto err; } +#ifdef IUTF8 { struct termios flags; if (tcgetattr(pts, &flags) < 0) { @@ -191,6 +192,7 @@ slave_exec(int ptmx, char *argv[], int err_fd, bool login_shell, goto err; } } +#endif if (tll_length(*notifications) > 0) { int flags = fcntl(pts, F_GETFL); From e35e98ea94dd216dc0eb86c9199aa49997659b96 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Tue, 19 Jan 2021 15:17:38 +0000 Subject: [PATCH 06/20] shm: silence -Wunused-function on i386 shm.c:134:1: error: unused function 'page_size' [-Werror,-Wunused-function] page_size(void) ^ --- shm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shm.c b/shm.c index 2231f057..4038f0f2 100644 --- a/shm.c +++ b/shm.c @@ -130,6 +130,7 @@ static const struct wl_buffer_listener buffer_listener = { .release = &buffer_release, }; +#if !defined(__i386__) static size_t page_size(void) { @@ -146,6 +147,7 @@ page_size(void) xassert(size > 0); return size; } +#endif static bool instantiate_offset(struct wl_shm *shm, struct buffer *buf, off_t new_offset) From 013e3c2d8057842593abf72b174223d350382dbc Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Tue, 19 Jan 2021 15:22:51 +0000 Subject: [PATCH 07/20] 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 4038f0f2..427af1a0 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 From db9dc7e90853208a28d48c8b52f4251118005007 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Tue, 19 Jan 2021 14:20:55 +0000 Subject: [PATCH 08/20] shm: unbreak build without memfd_create New FreeBSD versions have memfd_create but other BSDs don't. pgo/pgo.c:260:22: error: implicit declaration of function 'memfd_create' is invalid in C99 [-Werror,-Wimplicit-function-declaration] int mem_fd = memfd_create("foot-pgo-ptmx", MFD_CLOEXEC); ^ pgo/pgo.c:260:52: error: use of undeclared identifier 'MFD_CLOEXEC' int mem_fd = memfd_create("foot-pgo-ptmx", MFD_CLOEXEC); ^ shm.c:13:10: fatal error: 'linux/mman.h' file not found #include ^~~~~~~~~~~~~~ shm.c:277:15: error: implicit declaration of function 'memfd_create' is invalid in C99 [-Werror,-Wimplicit-function-declaration] pool_fd = memfd_create("foot-wayland-shm-buffer-pool", MFD_CLOEXEC | MFD_ALLOW_SEALING); ^ shm.c:277:60: error: use of undeclared identifier 'MFD_CLOEXEC' pool_fd = memfd_create("foot-wayland-shm-buffer-pool", MFD_CLOEXEC | MFD_ALLOW_SEALING); ^ shm.c:277:74: error: use of undeclared identifier 'MFD_ALLOW_SEALING' pool_fd = memfd_create("foot-wayland-shm-buffer-pool", MFD_CLOEXEC | MFD_ALLOW_SEALING); ^ shm.c:339:15: error: use of undeclared identifier 'F_SEAL_GROW' F_SEAL_GROW | F_SEAL_SHRINK | /*F_SEAL_FUTURE_WRITE |*/ F_SEAL_SEAL) < 0) ^ shm.c:339:29: error: use of undeclared identifier 'F_SEAL_SHRINK' F_SEAL_GROW | F_SEAL_SHRINK | /*F_SEAL_FUTURE_WRITE |*/ F_SEAL_SEAL) < 0) ^ shm.c:339:71: error: use of undeclared identifier 'F_SEAL_SEAL' F_SEAL_GROW | F_SEAL_SHRINK | /*F_SEAL_FUTURE_WRITE |*/ F_SEAL_SEAL) < 0) ^ shm.c:338:24: error: use of undeclared identifier 'F_ADD_SEALS' if (fcntl(pool_fd, F_ADD_SEALS, ^ --- meson.build | 4 ++++ pgo/pgo.c | 9 +++++++++ shm.c | 14 ++++++++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index f943211c..1c61c322 100644 --- a/meson.build +++ b/meson.build @@ -12,6 +12,10 @@ is_debug_build = get_option('buildtype').startswith('debug') cc = meson.get_compiler('c') +if cc.has_function('memfd_create') + add_project_arguments('-DMEMFD_CREATE', language: 'c') +endif + add_project_arguments( ['-D_POSIX_C_SOURCE=200809L', '-D_GNU_SOURCE=200809L'] + (is_debug_build diff --git a/pgo/pgo.c b/pgo/pgo.c index 39c20de0..fa95a0ec 100644 --- a/pgo/pgo.c +++ b/pgo/pgo.c @@ -257,7 +257,16 @@ main(int argc, const char *const *argv) close(fd); +#if defined(MEMFD_CREATE) int mem_fd = memfd_create("foot-pgo-ptmx", MFD_CLOEXEC); +#elif defined(__FreeBSD__) + // memfd_create on FreeBSD 13 is SHM_ANON without sealing support + int mem_fd = shm_open(SHM_ANON, O_RDWR | O_CLOEXEC, 0600); +#else + char name[] = "/tmp/foot-pgo-ptmx-XXXXXX"; + int mem_fd = mkostemp(name, O_CLOEXEC); + unlink(name); +#endif if (mem_fd < 0) { fprintf(stderr, "error: failed to create memory FD\n"); goto out; diff --git a/shm.c b/shm.c index 427af1a0..ac941f92 100644 --- a/shm.c +++ b/shm.c @@ -9,8 +9,7 @@ #include #include #include -#include -#include +#include #include #include @@ -276,7 +275,16 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie, LOG_DBG("cookie=%lx: allocating new buffer: %zu KB", cookie, size / 1024); /* Backing memory for SHM */ +#if defined(MEMFD_CREATE) pool_fd = memfd_create("foot-wayland-shm-buffer-pool", MFD_CLOEXEC | MFD_ALLOW_SEALING); +#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/foot-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; @@ -335,6 +343,7 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie, goto err; } +#if defined(MEMFD_CREATE) /* Seal file - we no longer allow any kind of resizing */ /* TODO: wayland mmaps(PROT_WRITE), for some unknown reason, hence we cannot use F_SEAL_FUTURE_WRITE */ if (fcntl(pool_fd, F_ADD_SEALS, @@ -343,6 +352,7 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie, LOG_ERRNO("failed to seal SHM backing memory file"); /* This is not a fatal error */ } +#endif pool = wl_shm_create_pool(shm, pool_fd, memfd_size); if (pool == NULL) { From f2ad02aaabc4a6bb23ebccc6d8b1d79735b39b8c Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Tue, 19 Jan 2021 14:49:43 +0000 Subject: [PATCH 09/20] render: set thread name in a portable way prctl is Linux-only but pthread_setname_np is same as PR_SET_NAME. Solaris and FreeBSD >= 13 have pthread_setname_np similar to Linux. DragonFly, OpenBSD, FreeBSD < 13 lack pthread_setname_np but provide pthread_set_name_np which doesn't return a value. NetBSD requires 3 arguments for pthread_setname_np where the last one is void *. render.c:8:10: fatal error: 'sys/prctl.h' file not found #include ^~~~~~~~~~~~~ render.c:1234:9: error: implicit declaration of function 'prctl' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (prctl(PR_SET_NAME, proc_title, 0, 0, 0) < 0) ^ render.c:1234:15: error: use of undeclared identifier 'PR_SET_NAME' if (prctl(PR_SET_NAME, proc_title, 0, 0, 0) < 0) ^ --- render.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/render.c b/render.c index f8bb4968..2dccd6a8 100644 --- a/render.c +++ b/render.c @@ -5,7 +5,13 @@ #include #include #include -#include +#include +#if __has_include() +#include +#define pthread_setname_np(thread, name) (pthread_set_name_np(thread, name), 0) +#elif defined(__NetBSD__) +#define pthread_setname_np(thread, name) pthread_setname_np(thread, "%s", (void *)name) +#endif #include #include @@ -1231,7 +1237,7 @@ render_worker_thread(void *_ctx) char proc_title[16]; snprintf(proc_title, sizeof(proc_title), "foot:render:%d", my_id); - if (prctl(PR_SET_NAME, proc_title, 0, 0, 0) < 0) + if (pthread_setname_np(pthread_self(), proc_title) < 0) LOG_ERRNO("render worker %d: failed to set process title", my_id); sem_t *start = &term->render.workers.start; From 36b6cc020abd8e6b4baec53d7df2b9375c773ae8 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Tue, 19 Jan 2021 15:40:32 +0000 Subject: [PATCH 10/20] meson: don't force POSIX compliance foot uses a number of functions not in any POSIX version. On non-glibc systems defining _POSIX_C_SOURCE usually hides non-compliant interfaces. In file included from grid.c:1: In file included from grid.h:4: terminal.h:45:15: error: expected parameter declarator static_assert(sizeof(struct attributes) == 8, "bad size"); ^ terminal.h:45:15: error: expected ')' terminal.h:45:14: note: to match this '(' static_assert(sizeof(struct attributes) == 8, "bad size"); ^ terminal.h:45:1: error: type specifier missing, defaults to 'int' [-Werror,-Wimplicit-int] static_assert(sizeof(struct attributes) == 8, "bad size"); ^ terminal.h:55:15: error: expected parameter declarator static_assert(sizeof(struct cell) == 12, "bad size"); ^ terminal.h:55:15: error: expected ')' terminal.h:55:14: note: to match this '(' static_assert(sizeof(struct cell) == 12, "bad size"); ^ terminal.h:55:1: error: type specifier missing, defaults to 'int' [-Werror,-Wimplicit-int] static_assert(sizeof(struct cell) == 12, "bad size"); ^ grid.c:317:32: error: implicit declaration of function 'wcwidth' is invalid in C99 [-Werror,-Wimplicit-function-declaration] int width = max(1, wcwidth(wc)); ^ grid.c:317:32: note: did you mean '__wcwidth'? /usr/include/_ctype.h:161:1: note: '__wcwidth' declared here __wcwidth(__ct_rune_t _c) ^ selection.c:1695:9: error: implicit declaration of function 'pipe2' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (pipe2(fds, O_CLOEXEC) == -1) { ^ selection.c:1695:9: note: did you mean 'pipe'? /usr/include/unistd.h:358:6: note: 'pipe' declared here int pipe(int *); ^ selection.c:1842:9: error: implicit declaration of function 'pipe2' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (pipe2(fds, O_CLOEXEC) == -1) { ^ selection.c:2129:9: error: implicit declaration of function 'pipe2' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (pipe2(fds, O_CLOEXEC) == -1) { ^ vt.c:241:12: error: implicit declaration of function 'wcwidth' is invalid in C99 [-Werror,-Wimplicit-function-declaration] assert(wcwidth(c) == 1); ^ vt.c:241:12: note: did you mean '__wcwidth'? /usr/include/_ctype.h:161:1: note: '__wcwidth' declared here __wcwidth(__ct_rune_t _c) ^ vt.c:544:17: error: implicit declaration of function 'wcwidth' is invalid in C99 [-Werror,-Wimplicit-function-declaration] int width = wcwidth(wc); ^ csi.c:713:35: error: implicit declaration of function 'wcwidth' is invalid in C99 [-Werror,-Wimplicit-function-declaration] const int width = wcwidth(term->vt.last_printed); ^ csi.c:713:35: note: did you mean '__wcwidth'? /usr/include/_ctype.h:161:1: note: '__wcwidth' declared here __wcwidth(__ct_rune_t _c) ^ ime.c:169:25: error: implicit declaration of function 'wcwidth' is invalid in C99 [-Werror,-Wimplicit-function-declaration] int width = max(wcwidth(term->ime.preedit.text[i]), 1); ^ ime.c:169:25: note: did you mean '__wcwidth'? /usr/include/_ctype.h:161:1: note: '__wcwidth' declared here __wcwidth(__ct_rune_t _c) ^ quirks.c:81:22: error: implicit declaration of function 'strcasestr' is invalid in C99 [-Werror,-Wimplicit-function-declaration] is_kde = strcasestr(cur_desktop, "kde") != NULL; ^ quirks.c:81:53: error: comparison between pointer and integer ('int' and 'void *') [-Werror,-Wpointer-integer-compare] is_kde = strcasestr(cur_desktop, "kde") != NULL; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~ config.c:89:15: error: expected ')' static_assert(ALEN(binding_action_map) == BIND_ACTION_COUNT, ^ util.h:5:18: note: expanded from macro 'ALEN' #define ALEN(v) (sizeof(v) / sizeof((v)[0])) ^ config.c:358:12: error: implicit declaration of function 'strcasecmp' is invalid in C99 [-Werror,-Wimplicit-function-declaration] return strcasecmp(s, "on") == 0 || ^ config.c:358:12: note: did you mean 'wcscasecmp'? /usr/include/wchar.h:223:5: note: 'wcscasecmp' declared here int wcscasecmp(const wchar_t *, const wchar_t *); ^ config.c:510:23: error: implicit declaration of function 'strcasecmp' is invalid in C99 [-Werror,-Wimplicit-function-declaration] bool center = strcasecmp(mode, "center") == 0; ^ config.c:1243:13: error: implicit declaration of function 'strcasecmp' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (strcasecmp(value, "none") == 0) { ^ config.c:1330:13: error: implicit declaration of function 'strcasecmp' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (strcasecmp(value, "none") == 0) { ^ config.c:1534:13: error: implicit declaration of function 'strcasecmp' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (strcasecmp(value, "none") == 0) { ^ spawn.c:20:9: error: implicit declaration of function 'pipe2' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (pipe2(pipe_fds, O_CLOEXEC) < 0) { ^ spawn.c:20:9: note: did you mean 'pipe'? /usr/include/unistd.h:358:6: note: 'pipe' declared here int pipe(int *); ^ spawn.c:52:5: error: implicit declaration of function 'static_assert' is invalid in C99 [-Werror,-Wimplicit-function-declaration] static_assert(sizeof(_errno) == sizeof(errno), "errno size mismatch"); ^ server.c:309:21: error: implicit declaration of function 'accept4' is invalid in C99 [-Werror,-Wimplicit-function-declaration] int client_fd = accept4( ^ server.c:309:21: note: did you mean 'accept'? /usr/include/sys/socket.h:679:5: note: 'accept' declared here int accept(int, struct sockaddr * __restrict, socklen_t * __restrict); ^ server.c:310:59: error: use of undeclared identifier 'SOCK_CLOEXEC' server->fd, (struct sockaddr *)&addr, &addr_size, SOCK_CLOEXEC | SOCK_NONBLOCK); ^ server.c:310:74: error: use of undeclared identifier 'SOCK_NONBLOCK' server->fd, (struct sockaddr *)&addr, &addr_size, SOCK_CLOEXEC | SOCK_NONBLOCK); ^ server.c:341:44: error: use of undeclared identifier 'SOCK_CLOEXEC' int fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0); ^ server.c:341:59: error: use of undeclared identifier 'SOCK_NONBLOCK' int fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0); ^ server.c:371:44: error: use of undeclared identifier 'SOCK_CLOEXEC' int fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0); ^ server.c:371:59: error: use of undeclared identifier 'SOCK_NONBLOCK' int fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0); ^ shm.c:138:26: error: use of undeclared identifier '_SC_PAGE_SIZE' long n = sysconf(_SC_PAGE_SIZE); ^ shm.c:279:15: error: implicit declaration of function 'memfd_create' is invalid in C99 [-Werror,-Wimplicit-function-declaration] pool_fd = memfd_create("foot-wayland-shm-buffer-pool", MFD_CLOEXEC | MFD_ALLOW_SEALING); ^ shm.c:279:15: note: did you mean 'timer_create'? /usr/include/time.h:170:5: note: 'timer_create' declared here int timer_create(clockid_t, struct sigevent *__restrict, timer_t *__restrict); ^ shm.c:279:60: error: use of undeclared identifier 'MFD_CLOEXEC' pool_fd = memfd_create("foot-wayland-shm-buffer-pool", MFD_CLOEXEC | MFD_ALLOW_SEALING); ^ shm.c:279:74: error: use of undeclared identifier 'MFD_ALLOW_SEALING' pool_fd = memfd_create("foot-wayland-shm-buffer-pool", MFD_CLOEXEC | MFD_ALLOW_SEALING); ^ shm.c:350:15: error: use of undeclared identifier 'F_SEAL_GROW' F_SEAL_GROW | F_SEAL_SHRINK | /*F_SEAL_FUTURE_WRITE |*/ F_SEAL_SEAL) < 0) ^ shm.c:350:29: error: use of undeclared identifier 'F_SEAL_SHRINK' F_SEAL_GROW | F_SEAL_SHRINK | /*F_SEAL_FUTURE_WRITE |*/ F_SEAL_SEAL) < 0) ^ shm.c:350:71: error: use of undeclared identifier 'F_SEAL_SEAL' F_SEAL_GROW | F_SEAL_SHRINK | /*F_SEAL_FUTURE_WRITE |*/ F_SEAL_SEAL) < 0) ^ shm.c:349:24: error: use of undeclared identifier 'F_ADD_SEALS' if (fcntl(pool_fd, F_ADD_SEALS, ^ slave.c:151:28: error: implicit declaration of function 'ptsname' is invalid in C99 [-Werror,-Wimplicit-function-declaration] const char *pts_name = ptsname(ptmx); ^ slave.c:151:28: note: did you mean 'ttyname'? /usr/include/unistd.h:371:7: note: 'ttyname' declared here char *ttyname(int); ^ slave.c:151:17: error: incompatible integer to pointer conversion initializing 'const char *' with an expression of type 'int' [-Werror,-Wint-conversion] const char *pts_name = ptsname(ptmx); ^ ~~~~~~~~~~~~~ slave.c:153:9: error: implicit declaration of function 'grantpt' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (grantpt(ptmx) == -1) { ^ slave.c:157:9: error: implicit declaration of function 'unlockpt' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (unlockpt(ptmx) == -1) { ^ slave.c:252:9: error: implicit declaration of function 'pipe2' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (pipe2(fork_pipe, O_CLOEXEC) < 0) { ^ slave.c:252:9: note: did you mean 'pipe'? /usr/include/unistd.h:358:6: note: 'pipe' declared here int pipe(int *); ^ render.c:1166:28: error: implicit declaration of function 'wcwidth' is invalid in C99 [-Werror,-Wimplicit-function-declaration] int width = max(1, wcwidth(cell->wc)); ^ render.c:1166:28: note: did you mean '__wcwidth'? /usr/include/_ctype.h:161:1: note: '__wcwidth' declared here __wcwidth(__ct_rune_t _c) ^ render.c:1932:9: error: implicit declaration of function 'gettimeofday' is invalid in C99 [-Werror,-Wimplicit-function-declaration] gettimeofday(&start_time, NULL); ^ render.c:2240:28: error: implicit declaration of function 'wcwidth' is invalid in C99 [-Werror,-Wimplicit-function-declaration] widths[i] = max(1, wcwidth(text[i])); ^ render.c:2243:32: error: implicit declaration of function 'wcswidth' is invalid in C99 [-Werror,-Wimplicit-function-declaration] const size_t total_cells = wcswidth(text, text_len); ^ render.c:2243:32: note: did you mean 'wcwidth'? render.c:1166:28: note: 'wcwidth' declared here int width = max(1, wcwidth(cell->wc)); ^ util.h:7:27: note: expanded from macro 'max' #define max(x, y) ((x) > (y) ? (x) : (y)) ^ input.c:1540:9: error: implicit declaration of function 'gettimeofday' is invalid in C99 [-Werror,-Wimplicit-function-declaration] gettimeofday(&now, NULL); ^ --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 1c61c322..47ce4e43 100644 --- a/meson.build +++ b/meson.build @@ -17,7 +17,7 @@ if cc.has_function('memfd_create') endif add_project_arguments( - ['-D_POSIX_C_SOURCE=200809L', '-D_GNU_SOURCE=200809L'] + + ['-D_GNU_SOURCE=200809L'] + (is_debug_build ? ['-D_DEBUG'] : [cc.get_supported_arguments('-fno-asynchronous-unwind-tables')]) + From d97b5389173f6fb5924c3546cdd5b8a03fcb90cc Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Tue, 19 Jan 2021 15:48:56 +0000 Subject: [PATCH 11/20] meson: libpthread may lack C11 threads e.g., on FreeBSD ld: error: undefined symbol: mtx_init >>> referenced by terminal.c:579 (terminal.c:579) >>> terminal.c.o:(initialize_render_workers) in archive libpgolib.a ld: error: undefined symbol: thrd_create >>> referenced by terminal.c:595 (terminal.c:595) >>> terminal.c.o:(initialize_render_workers) in archive libpgolib.a >>> referenced by terminal.c:935 (terminal.c:935) >>> terminal.c.o:(reload_fonts) in archive libpgolib.a >>> did you mean: thr_create >>> defined in: /lib/libc.so.7 ld: error: undefined symbol: mtx_lock >>> referenced by terminal.c:1410 (terminal.c:1410) >>> terminal.c.o:(term_destroy) in archive libpgolib.a ld: error: undefined symbol: mtx_unlock >>> referenced by terminal.c:1427 (terminal.c:1427) >>> terminal.c.o:(term_destroy) in archive libpgolib.a ld: error: undefined symbol: thrd_join >>> referenced by terminal.c:1462 (terminal.c:1462) >>> terminal.c.o:(term_destroy) in archive libpgolib.a >>> referenced by terminal.c:947 (terminal.c:947) >>> terminal.c.o:(reload_fonts) in archive libpgolib.a ld: error: undefined symbol: mtx_destroy >>> referenced by terminal.c:1466 (terminal.c:1466) >>> terminal.c.o:(term_destroy) in archive libpgolib.a --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 47ce4e43..2c7954fd 100644 --- a/meson.build +++ b/meson.build @@ -60,7 +60,7 @@ if cc.has_argument('-fmacro-prefix-map=/foo=') endif math = cc.find_library('m') -threads = dependency('threads') +threads = [dependency('threads'), cc.find_library('stdthreads', required: false)] pixman = dependency('pixman-1') wayland_protocols = dependency('wayland-protocols') wayland_client = dependency('wayland-client') From 603bbcbcff3514e29ea54dc316010027a6d740a9 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Tue, 19 Jan 2021 15:54:18 +0000 Subject: [PATCH 12/20] meson: require epoll-shim on BSDs epoll/timerfd are Linux-only but BSDs have a shim via kqueue. libwayland on FreeBSD uses epoll-shim by default, so the build may fail at linking instead of compilation stage. csi.c:13:10: fatal error: 'sys/timerfd.h' file not found #include ^~~~~~~~~~~~~~~ selection.c:10:10: fatal error: 'sys/epoll.h' file not found #include ^~~~~~~~~~~~~ terminal.c:15:10: fatal error: 'sys/epoll.h' file not found #include ^~~~~~~~~~~~~ ld: error: undefined symbol: timerfd_create >>> referenced by pgo.c:154 (pgo/pgo.c:154) >>> pgo.p/pgo_pgo.c.o:(main) >>> referenced by pgo.c:158 (pgo/pgo.c:158) >>> pgo.p/pgo_pgo.c.o:(main) >>> referenced by terminal.c:2022 (terminal.c:2022) >>> terminal.c.o:(cursor_blink_rearm_timer) in archive libpgolib.a >>> referenced 7 more times ld: error: undefined symbol: epoll_shim_close >>> referenced by pgo.c:160 (pgo/pgo.c:160) >>> pgo.p/pgo_pgo.c.o:(main) >>> referenced by pgo.c:258 (pgo/pgo.c:258) >>> pgo.p/pgo_pgo.c.o:(main) >>> referenced by pgo.c:277 (pgo/pgo.c:277) >>> pgo.p/pgo_pgo.c.o:(main) >>> referenced 14 more times ld: error: undefined symbol: epoll_shim_read >>> referenced by pgo.c:251 (pgo/pgo.c:251) >>> pgo.p/pgo_pgo.c.o:(main) >>> referenced by terminal.c:237 (terminal.c:237) >>> terminal.c.o:(fdm_ptmx) in archive libpgolib.a >>> referenced by terminal.c:363 (terminal.c:363) >>> terminal.c.o:(fdm_blink) in archive libpgolib.a >>> referenced 8 more times ld: error: undefined symbol: timerfd_settime >>> referenced by terminal.c:301 (terminal.c:301) >>> terminal.c.o:(fdm_ptmx) in archive libpgolib.a >>> referenced by terminal.c:309 (terminal.c:309) >>> terminal.c.o:(fdm_ptmx) in archive libpgolib.a >>> referenced by terminal.c:2041 (terminal.c:2041) >>> terminal.c.o:(cursor_blink_rearm_timer) in archive libpgolib.a >>> referenced 11 more times ld: error: undefined symbol: timerfd_gettime >>> referenced by selection.c:1165 (selection.c:1165) >>> selection.c.o:(selection_start_scroll_timer) in archive libpgolib.a --- meson.build | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index 2c7954fd..dd3c07c1 100644 --- a/meson.build +++ b/meson.build @@ -61,6 +61,7 @@ endif math = cc.find_library('m') threads = [dependency('threads'), cc.find_library('stdthreads', required: false)] +libepoll = dependency('epoll-shim', required: false) pixman = dependency('pixman-1') wayland_protocols = dependency('wayland-protocols') wayland_client = dependency('wayland-client') @@ -130,7 +131,7 @@ vtlib = static_library( 'vt.c', 'vt.h', wl_proto_src + wl_proto_headers, version, - dependencies: [pixman, fcft, tllist], + dependencies: [libepoll, pixman, fcft, tllist], link_with: misc, ) @@ -140,7 +141,7 @@ pgolib = static_library( 'selection.c', 'selection.h', 'terminal.c', 'terminal.h', wl_proto_src + wl_proto_headers, - dependencies: [pixman, fcft, tllist], + dependencies: [libepoll, pixman, fcft, tllist], link_with: vtlib, ) @@ -148,7 +149,7 @@ executable( 'pgo', 'pgo/pgo.c', wl_proto_src + wl_proto_headers, - dependencies: [math, threads, pixman, wayland_client, fcft, tllist], + dependencies: [math, threads, libepoll, pixman, wayland_client, fcft, tllist], link_with: pgolib, ) @@ -177,7 +178,7 @@ executable( 'user-notification.h', 'wayland.c', 'wayland.h', wl_proto_src + wl_proto_headers, version, - dependencies: [math, threads, pixman, wayland_client, wayland_cursor, xkb, fontconfig, + dependencies: [math, threads, libepoll, pixman, wayland_client, wayland_cursor, xkb, fontconfig, tllist, fcft], link_with: pgolib, install: true) From e3a1dfcf5a0d5dab904827c5b6668933354502c5 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Thu, 21 Jan 2021 07:00:57 +0000 Subject: [PATCH 13/20] meson: depend on wayland-client when using wayland-protocols Base compiler on BSDs doesn't look where packages are installed to avoid tainting build environment. When system fcft is installed to the same prefix as wayland-client it passes CFLAGS that satisfy both but when using subprojects/fcft there's a build error. xdg-shell.c:33:10: fatal error: 'wayland-util.h' file not found xdg-decoration-unstable-v1.c:28:10: fatal error: 'wayland-util.h' file not found xdg-output-unstable-v1.c:28:10: fatal error: 'wayland-util.h' file not found presentation-time.c:28:10: fatal error: 'wayland-util.h' file not found primary-selection-unstable-v1.c:28:10: fatal error: 'wayland-util.h' file not found text-input-unstable-v3.c:33:10: fatal error: 'wayland-util.h' file not found In file included from ../../foot/grid.c:1: In file included from ../../foot/grid.h:5: In file included from ../../foot/terminal.h:19: ../../foot/wayland.h:8:10: fatal error: 'wayland-client.h' file not found In file included from ../../foot/selection.c:1: ../../foot/selection.h:4:10: fatal error: 'wayland-client.h' file not found --- meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index dd3c07c1..eb95fa87 100644 --- a/meson.build +++ b/meson.build @@ -131,7 +131,7 @@ vtlib = static_library( 'vt.c', 'vt.h', wl_proto_src + wl_proto_headers, version, - dependencies: [libepoll, pixman, fcft, tllist], + dependencies: [libepoll, pixman, fcft, tllist, wayland_client], link_with: misc, ) @@ -141,7 +141,7 @@ pgolib = static_library( 'selection.c', 'selection.h', 'terminal.c', 'terminal.h', wl_proto_src + wl_proto_headers, - dependencies: [libepoll, pixman, fcft, tllist], + dependencies: [libepoll, pixman, fcft, tllist, wayland_client], link_with: vtlib, ) From 15f2bebdcb972c26fed6070ef03cefebadaa593b Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Tue, 19 Jan 2021 14:22:41 +0000 Subject: [PATCH 14/20] meson: optionalize terminfo dependency ncurses on FreeBSD still uses termcap(5) while foot works fine with xterm-256color sans status line and visible bell. Having more than one ncurses version installed may break other applications. Document -Dterminfo=false uses --term=xterm-256color by default --- config.c | 4 ++++ doc/foot.ini.5.scd | 3 ++- foot.ini | 2 +- meson.build | 22 ++++++++++++++-------- meson_options.txt | 1 + 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/config.c b/config.c index 5956a516..da55f8f8 100644 --- a/config.c +++ b/config.c @@ -2042,7 +2042,11 @@ config_load(struct config *conf, const char *conf_path, bool ret = false; *conf = (struct config) { +#ifdef HAVE_TERMINFO .term = xstrdup("foot"), +#else + .term = xstrdup("xterm-256color"), +#endif .shell = get_shell(), .title = xstrdup("foot"), .app_id = xstrdup("foot"), diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index 16fd270b..c78ad7bc 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -29,7 +29,8 @@ in this order: by prepending a '-' to argv[0]. Default: _no_. *term* - Value to set the environment variable *TERM* to. Default: _foot_. + Value to set the environment variable *TERM* to. Default: _foot_ + or _xterm-256color_ if built with _-Dterminfo=false_ *font*, *font-bold*, *font-italic*, *font-bold-italic* Comma separated list of fonts to use, in fontconfig format. That diff --git a/foot.ini b/foot.ini index 3cff1842..330b4b7f 100644 --- a/foot.ini +++ b/foot.ini @@ -1,7 +1,7 @@ # -*- conf -*- # shell=$SHELL (if set, otherwise user's default shell from /etc/passwd) -# term=foot +# term=foot (or xterm-256color if built with -Dterminfo=false) # login-shell=no # font=monospace:size=8 diff --git a/meson.build b/meson.build index eb95fa87..f747957f 100644 --- a/meson.build +++ b/meson.build @@ -72,6 +72,11 @@ fontconfig = dependency('fontconfig') tllist = dependency('tllist', version: '>=1.0.4', fallback: 'tllist') fcft = dependency('fcft', version: ['>=2.3.0', '<3.0.0'], fallback: 'fcft') +tic = find_program('tic', native: true, required: get_option('terminfo')) +if tic.found() + add_project_arguments('-DHAVE_TERMINFO', language: 'c') +endif + wayland_protocols_datadir = wayland_protocols.get_pkgconfig_variable('pkgdatadir') wscanner = dependency('wayland-scanner', native: true) @@ -194,14 +199,15 @@ executable( version, install: true) -tic = find_program('tic', native: true) -custom_target( - 'terminfo', - output: 'f', - input: 'foot.info', - command: [tic, '-x', '-o', '@OUTDIR@', '-e', 'foot,foot-direct', '@INPUT@'], - install: true, - install_dir: join_paths(get_option('datadir'), 'terminfo')) +if tic.found() + custom_target( + 'terminfo', + output: 'f', + input: 'foot.info', + command: [tic, '-x', '-o', '@OUTDIR@', '-e', 'foot,foot-direct', '@INPUT@'], + install: true, + install_dir: join_paths(get_option('datadir'), 'terminfo')) +endif install_data( 'LICENSE', 'README.md', 'CHANGELOG.md', diff --git a/meson_options.txt b/meson_options.txt index fc3c1b0f..0a5b0a3d 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1 +1,2 @@ option('ime', type: 'boolean', value: true, description: 'IME (Input Method Editor) support') +option('terminfo', type: 'boolean', value: true, description: 'Install terminfo') From dfc157e6b1551c52553327ad5ecea28ac29b08d8 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Thu, 21 Jan 2021 06:52:22 +0000 Subject: [PATCH 15/20] ci: enable freebsd-x64 job - Add missing dependencies - Disable terminfo to match downstream --- .builds/{freebsd-x64.yml.disabled => freebsd-x64.yml} | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) rename .builds/{freebsd-x64.yml.disabled => freebsd-x64.yml} (64%) diff --git a/.builds/freebsd-x64.yml.disabled b/.builds/freebsd-x64.yml similarity index 64% rename from .builds/freebsd-x64.yml.disabled rename to .builds/freebsd-x64.yml index 55c9496a..8147184e 100644 --- a/.builds/freebsd-x64.yml.disabled +++ b/.builds/freebsd-x64.yml @@ -1,5 +1,7 @@ image: freebsd/latest packages: + - evdev-proto + - libepoll-shim - meson - ninja - pkgconf @@ -11,10 +13,9 @@ packages: - harfbuzz - pixman - libxkbcommon - - ncurses - check - - ttf-hack - - font-noto-emoji + - hack-font + - noto-emoji sources: - https://codeberg.org/dnkl/foot @@ -27,11 +28,11 @@ sources: tasks: - debug: | mkdir -p bld/debug - meson --buildtype=debug -Dfcft:text-shaping=enabled -Dfcft:test-text-shaping=true foot bld/debug + meson --buildtype=debug -Dterminfo=false -Dfcft:text-shaping=enabled -Dfcft:test-text-shaping=true foot bld/debug ninja -C bld/debug -k0 meson test -C bld/debug --print-errorlogs - release: | mkdir -p bld/release - meson --buildtype=minsize -Dfcft:text-shaping=enabled -Dfcft:test-text-shaping=true foot bld/release + meson --buildtype=minsize -Dterminfo=false -Dfcft:text-shaping=enabled -Dfcft:test-text-shaping=true foot bld/release ninja -C bld/release -k0 meson test -C bld/release --print-errorlogs From 73522cec27759923ab38c18f5a660ac315db9d2b Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Thu, 21 Jan 2021 14:23:20 +0000 Subject: [PATCH 16/20] completions/zsh: unbreak with BSD find(1) find: -printf: unknown primary or operator --- completions/zsh/_foot | 2 +- completions/zsh/_footclient | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/completions/zsh/_foot b/completions/zsh/_foot index 24ddd671..c6f0f93b 100644 --- a/completions/zsh/_foot +++ b/completions/zsh/_foot @@ -31,6 +31,6 @@ case ${state} in ;; terms) - _values 'terminal definitions' $(find /usr/share/terminfo -type f -printf "%f\n") + _values 'terminal definitions' /usr/share/terminfo/**/*(.:t) ;; esac diff --git a/completions/zsh/_footclient b/completions/zsh/_footclient index 26aa2c5c..e355527f 100644 --- a/completions/zsh/_footclient +++ b/completions/zsh/_footclient @@ -20,6 +20,6 @@ _arguments \ case ${state} in terms) - _values 'terminal definitions' $(find /usr/share/terminfo -type f -printf "%f\n") + _values 'terminal definitions' /usr/share/terminfo/**/*(.:t) ;; esac From 0bb928e02fa9ce4ec36cf2f1683e7a4e0c5e09dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 21 Jan 2021 12:15:40 +0100 Subject: [PATCH 17/20] =?UTF-8?q?client:=20explicitly=20use=20a=2064-bit?= =?UTF-8?q?=20type=20for=20=E2=80=98total=5Flen=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes an out-of-range comparison in 32-bit builds: client.c:289:19: error: result of comparison of constant 4294967296 with expression of type 'size_t' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare] if (total_len >= 1llu << (8 * sizeof(uint32_t)) || ~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.c b/client.c index 9a347562..dead7117 100644 --- a/client.c +++ b/client.c @@ -263,7 +263,7 @@ main(int argc, char *const *argv) }; /* Total packet length, not (yet) including argv[] */ - size_t total_len = ( + uint64_t total_len = ( sizeof(data) + cwd_len + term_len + 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 18/20] =?UTF-8?q?shm:=20don=E2=80=99t=20check=20for=20=5F?= =?UTF-8?q?=5Fi386=5F=5F=20and=20=5F=5Fx86=5F64=5F=5F=20-=20there=20are=20?= =?UTF-8?q?other=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; From b2d0af701673e89f444a3bc984b1c79a7625b0a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 23 Jan 2021 10:07:02 +0100 Subject: [PATCH 19/20] ci: freebsd-x64: compile with -Wno-missing-braces The freebsd/latest image is still FreeBSD-12, with clang-8. It generate false positive warnings: ../../foot/search.c:357:21: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces] mbstate_t ps = {0}; --- .builds/freebsd-x64.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.builds/freebsd-x64.yml b/.builds/freebsd-x64.yml index 8147184e..41cc26c4 100644 --- a/.builds/freebsd-x64.yml +++ b/.builds/freebsd-x64.yml @@ -25,14 +25,16 @@ sources: # condition: failure # to: +# TODO: drop -Dc_args=-Wno-missing-braces when freebsd/latest is >= 13 + tasks: - debug: | mkdir -p bld/debug - meson --buildtype=debug -Dterminfo=false -Dfcft:text-shaping=enabled -Dfcft:test-text-shaping=true foot bld/debug + meson --buildtype=debug -Dc_args=-Wno-missing-braces -Dterminfo=false -Dfcft:text-shaping=enabled -Dfcft:test-text-shaping=true foot bld/debug ninja -C bld/debug -k0 meson test -C bld/debug --print-errorlogs - release: | mkdir -p bld/release - meson --buildtype=minsize -Dterminfo=false -Dfcft:text-shaping=enabled -Dfcft:test-text-shaping=true foot bld/release + meson --buildtype=minsize -Dc_args=-Wno-missing-braces -Dterminfo=false -Dfcft:text-shaping=enabled -Dfcft:test-text-shaping=true foot bld/release ninja -C bld/release -k0 meson test -C bld/release --print-errorlogs From 124bc3c084fb6d4975f30029f199438aa2ceb5e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 23 Jan 2021 10:12:39 +0100 Subject: [PATCH 20/20] changelog: freebsd support --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 767f5669..c43c8f92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ * Key/mouse binding `select-extend-character-wise`, which forces the selection mode to 'character-wise' when extending a selection. * `DECSET` `47`, `1047` and `1048`. +* FreeBSD support ### Changed @@ -91,6 +92,7 @@ * [birger](https://codeberg.org/birger) * [pc](https://codeberg.org/pc) * [FollieHiyuki](https://codeberg.org/FollieHiyuki) +* jbeich ## 1.6.2