From aa030f5f1c5871620910a39ab9cc7c2d4acdb552 Mon Sep 17 00:00:00 2001 From: Pierre-Alain TORET Date: Tue, 1 Nov 2022 14:55:17 +0100 Subject: [PATCH] graphics/wayland : first attempt at using FreeBSD port as base --- .../wayland/dragonfly/patch-meson.build | 42 ++++++ .../patch-src_connection.c | 14 +- .../patch-src_event-loop.c | 137 +++++++++--------- .../wayland/dragonfly/patch-src_wayland-os.c | 63 ++++++++ .../patch-src_wayland-os.h | 6 +- .../dragonfly/patch-src_wayland-server.c | 32 ++++ .../dragonfly/patch-tests_os-wrappers-test.c | 42 ++++++ .../patch-tests_test-runner.c | 50 ++++--- ports/graphics/wayland/newport/Makefile | 22 --- .../wayland/newport/Makefile.DragonFly | 2 - ports/graphics/wayland/newport/distinfo | 2 - .../files/patch-cursor_wayland-cursor.c | 14 -- .../wayland/newport/files/patch-meson.build | 19 --- .../newport/files/patch-src_wayland-os.c | 61 -------- .../newport/files/patch-src_wayland-server.c | 83 ----------- .../newport/files/patch-src_wayland-shm.c | 120 --------------- .../newport/files/patch-src_wayland-util.c | 10 -- .../files/patch-tests_os-wrappers-test.c | 49 ------- .../files/patch-tests_test-compositor.c | 46 ------ ports/graphics/wayland/newport/pkg-descr | 3 - ports/graphics/wayland/newport/pkg-plist | 35 ----- 21 files changed, 293 insertions(+), 559 deletions(-) create mode 100644 ports/graphics/wayland/dragonfly/patch-meson.build rename ports/graphics/wayland/{newport/files => dragonfly}/patch-src_connection.c (80%) rename ports/graphics/wayland/{newport/files => dragonfly}/patch-src_event-loop.c (87%) create mode 100644 ports/graphics/wayland/dragonfly/patch-src_wayland-os.c rename ports/graphics/wayland/{newport/files => dragonfly}/patch-src_wayland-os.h (62%) create mode 100644 ports/graphics/wayland/dragonfly/patch-src_wayland-server.c create mode 100644 ports/graphics/wayland/dragonfly/patch-tests_os-wrappers-test.c rename ports/graphics/wayland/{newport/files => dragonfly}/patch-tests_test-runner.c (67%) delete mode 100644 ports/graphics/wayland/newport/Makefile delete mode 100644 ports/graphics/wayland/newport/Makefile.DragonFly delete mode 100644 ports/graphics/wayland/newport/distinfo delete mode 100644 ports/graphics/wayland/newport/files/patch-cursor_wayland-cursor.c delete mode 100644 ports/graphics/wayland/newport/files/patch-meson.build delete mode 100644 ports/graphics/wayland/newport/files/patch-src_wayland-os.c delete mode 100644 ports/graphics/wayland/newport/files/patch-src_wayland-server.c delete mode 100644 ports/graphics/wayland/newport/files/patch-src_wayland-shm.c delete mode 100644 ports/graphics/wayland/newport/files/patch-src_wayland-util.c delete mode 100644 ports/graphics/wayland/newport/files/patch-tests_os-wrappers-test.c delete mode 100644 ports/graphics/wayland/newport/files/patch-tests_test-compositor.c delete mode 100644 ports/graphics/wayland/newport/pkg-descr delete mode 100644 ports/graphics/wayland/newport/pkg-plist diff --git a/ports/graphics/wayland/dragonfly/patch-meson.build b/ports/graphics/wayland/dragonfly/patch-meson.build new file mode 100644 index 000000000000..bfed5abd67f4 --- /dev/null +++ b/ports/graphics/wayland/dragonfly/patch-meson.build @@ -0,0 +1,42 @@ +--- meson.build.orig 2022-10-22 10:59:58.476779000 +0200 ++++ meson.build 2022-10-31 16:12:58.994390000 +0100 +@@ -16,7 +16,7 @@ + config_h.set_quoted('PACKAGE_VERSION', meson.project_version()) + + cc_args = [] +-if host_machine.system() != 'freebsd' ++if host_machine.system() != 'dragonfly' + cc_args += ['-D_POSIX_C_SOURCE=200809L'] + endif + add_project_arguments(cc_args, language: 'c') +@@ -43,7 +43,6 @@ + 'mkostemp', + 'posix_fallocate', + 'prctl', +- 'memfd_create', + 'mremap', + 'strndup', + ] +@@ -52,11 +51,11 @@ + endforeach + config_h.set10('HAVE_XUCRED_CR_PID', cc.has_member('struct xucred', 'cr_pid', prefix : '#include ')) + have_broken_msg_cmsg_cloexec = false +-if host_machine.system() == 'freebsd' ++if host_machine.system() == 'freebsd' or host_machine.system() == 'dragonfly' + have_broken_msg_cmsg_cloexec = not cc.compiles(''' + #include /* To get __FreeBSD_version. */ + #if __FreeBSD_version < 1300502 || \ +- (__FreeBSD_version >= 1400000 && __FreeBSD_version < 1400006) ++ (__FreeBSD_version >= 1400000 && __FreeBSD_version < 1400006) || defined(__DragonFly__) + /* + * FreeBSD had a broken implementation of MSG_CMSG_CLOEXEC between 2015 and + * 2021. Check if we are compiling against a version that includes the fix +@@ -80,8 +79,6 @@ + ffi_dep = dependency('libffi') + + decls = [ +- { 'header': 'sys/signalfd.h', 'symbol': 'SFD_CLOEXEC' }, +- { 'header': 'sys/timerfd.h', 'symbol': 'TFD_CLOEXEC' }, + { 'header': 'time.h', 'symbol': 'CLOCK_MONOTONIC' }, + ] + diff --git a/ports/graphics/wayland/newport/files/patch-src_connection.c b/ports/graphics/wayland/dragonfly/patch-src_connection.c similarity index 80% rename from ports/graphics/wayland/newport/files/patch-src_connection.c rename to ports/graphics/wayland/dragonfly/patch-src_connection.c index b1e5bb517842..ef85589c0cb7 100644 --- a/ports/graphics/wayland/newport/files/patch-src_connection.c +++ b/ports/graphics/wayland/dragonfly/patch-src_connection.c @@ -1,5 +1,5 @@ ---- src/connection.c.orig 2018-07-20 17:20:22.749299000 +0300 -+++ src/connection.c 2018-07-20 17:27:23.761642000 +0300 +--- src/connection.c.orig 2022-10-22 10:58:12.859174000 +0200 ++++ src/connection.c 2022-11-01 18:50:36.315356000 +0100 @@ -38,6 +38,7 @@ #include #include @@ -8,8 +8,8 @@ #include #include "wayland-util.h" -@@ -299,7 +300,10 @@ - msg.msg_namelen = 0; +@@ -306,7 +307,10 @@ + msg.msg_iov = iov; msg.msg_iovlen = count; - msg.msg_control = (clen > 0) ? cmsg : NULL; @@ -18,9 +18,9 @@ + else + msg.msg_control = cmsg; msg.msg_controllen = clen; - msg.msg_flags = 0; -@@ -370,11 +374,25 @@ + do { +@@ -376,11 +380,25 @@ wl_connection_write(struct wl_connection *connection, const void *data, size_t count) { @@ -49,4 +49,4 @@ + } } - if (wl_buffer_put(&connection->out, data, count) < 0) + if (ring_buffer_put(&connection->out, data, count) < 0) diff --git a/ports/graphics/wayland/newport/files/patch-src_event-loop.c b/ports/graphics/wayland/dragonfly/patch-src_event-loop.c similarity index 87% rename from ports/graphics/wayland/newport/files/patch-src_event-loop.c rename to ports/graphics/wayland/dragonfly/patch-src_event-loop.c index 4ae90969293b..6d9b79473baf 100644 --- a/ports/graphics/wayland/newport/files/patch-src_event-loop.c +++ b/ports/graphics/wayland/dragonfly/patch-src_event-loop.c @@ -1,18 +1,19 @@ ---- src/event-loop.c.orig 2020-04-08 17:13:54.915257000 +0300 -+++ src/event-loop.c 2020-05-16 17:46:32.581743000 +0300 -@@ -35,9 +35,8 @@ +--- src/event-loop.c.orig 2022-11-01 19:04:03.507533000 +0100 ++++ src/event-loop.c 2022-11-01 19:04:05.187496000 +0100 +@@ -34,10 +34,9 @@ + #include #include #include ++#include ++#include #include -#include -#include -#include -+#include -+#include #include #include "wayland-util.h" #include "wayland-private.h" -@@ -68,7 +67,7 @@ struct wl_timer_heap { +@@ -68,7 +67,7 @@ }; struct wl_event_loop { @@ -21,19 +22,16 @@ struct wl_list check_list; struct wl_list idle_list; struct wl_list destroy_list; -@@ -80,10 +79,9 @@ struct wl_event_loop { +@@ -80,7 +79,7 @@ struct wl_event_source_interface { int (*dispatch)(struct wl_event_source *source, - struct epoll_event *ep); -+ struct kevent *ev); ++ struct kevent *kv); }; -- - struct wl_event_source_fd { - struct wl_event_source base; - wl_event_loop_fd_func_t func; -@@ -94,22 +92,22 @@ struct wl_event_source_fd { + +@@ -94,22 +93,22 @@ static int wl_event_source_fd_dispatch(struct wl_event_source *source, @@ -62,7 +60,7 @@ } struct wl_event_source_interface fd_source_interface = { -@@ -120,30 +118,10 @@ static struct wl_event_source * +@@ -120,30 +119,10 @@ add_source(struct wl_event_loop *loop, struct wl_event_source *source, uint32_t mask, void *data) { @@ -93,17 +91,17 @@ return source; } -@@ -179,6 +157,9 @@ wl_event_loop_add_fd(struct wl_event_loo +@@ -179,6 +158,9 @@ { struct wl_event_source_fd *source; + struct kevent events[2]; + unsigned int num_events = 0; + - source = malloc(sizeof *source); + source = zalloc(sizeof *source); if (source == NULL) return NULL; -@@ -187,8 +168,36 @@ wl_event_loop_add_fd(struct wl_event_loo +@@ -187,8 +169,36 @@ source->base.fd = wl_os_dupfd_cloexec(fd, 0); source->func = func; source->fd = fd; @@ -115,7 +113,8 @@ + free(source); + return NULL; + } -+ + +- return add_source(loop, &source->base, mask, data); + if (mask & WL_EVENT_READABLE) { + EV_SET(&events[num_events], source->base.fd, EVFILT_READ, + EV_ADD | EV_ENABLE, 0, 0, &source->base); @@ -135,13 +134,12 @@ + free(source); + return NULL; + } - -- return add_source(loop, &source->base, mask, data); ++ + return &source->base; } /** Update a file descriptor source's event mask -@@ -215,16 +224,22 @@ WL_EXPORT int +@@ -215,16 +225,22 @@ wl_event_source_fd_update(struct wl_event_source *source, uint32_t mask) { struct wl_event_loop *loop = source->loop; @@ -172,7 +170,7 @@ } /** \cond INTERNAL */ -@@ -239,7 +254,7 @@ struct wl_event_source_timer { +@@ -239,7 +255,7 @@ static int noop_dispatch(struct wl_event_source *source, @@ -181,7 +179,7 @@ return 0; } -@@ -257,25 +272,47 @@ time_lt(struct timespec ta, struct times +@@ -257,25 +273,47 @@ } static int @@ -199,11 +197,7 @@ + + if (clock_gettime(CLOCK_MONOTONIC, &now) == -1) + return -1; - -- its.it_interval.tv_sec = 0; -- its.it_interval.tv_nsec = 0; -- its.it_value = deadline; -- return timerfd_settime(timerfd, TFD_TIMER_ABSTIME, &its, NULL); ++ + if (!time_lt(now, deadline)) + return -1; + @@ -213,7 +207,11 @@ + diff_sec--; + diff_nsec += 1000000000L; + } -+ + +- its.it_interval.tv_sec = 0; +- its.it_interval.tv_nsec = 0; +- its.it_value = deadline; +- return timerfd_settime(timerfd, TFD_TIMER_ABSTIME, &its, NULL); + rel_deadline = (long) ((diff_sec * 1000) + (diff_nsec / 1000000)); + if ((diff_nsec % 1000000) > 499999) + rel_deadline++; @@ -242,7 +240,7 @@ } static void -@@ -296,37 +333,43 @@ wl_timer_heap_init(struct wl_timer_heap +@@ -296,37 +334,43 @@ static void wl_timer_heap_release(struct wl_timer_heap *timers) { @@ -274,6 +272,10 @@ - TFD_CLOEXEC | TFD_NONBLOCK); - if (timer_fd < 0) - return -1; +- +- if (epoll_ctl(timers->base.loop->epoll_fd, +- EPOLL_CTL_ADD, timer_fd, &ep) < 0) { +- close(timer_fd); + struct kevent ev; + /* + * Deprecated. @@ -281,10 +283,7 @@ + * It must be => 0. + */ + static int timer_id = 1; - -- if (epoll_ctl(timers->base.loop->epoll_fd, -- EPOLL_CTL_ADD, timer_fd, &ep) < 0) { -- close(timer_fd); ++ + /* + * We need to add timer filter already here. This avoids error messages + * when the timer filter is removed before ever updating it. @@ -307,7 +306,7 @@ return 0; } -@@ -484,7 +527,6 @@ wl_timer_heap_arm(struct wl_timer_heap * +@@ -484,7 +528,6 @@ heap_sift_up(timers->data, source); } @@ -315,7 +314,7 @@ static int wl_timer_heap_dispatch(struct wl_timer_heap *timers) { -@@ -511,10 +553,10 @@ wl_timer_heap_dispatch(struct wl_timer_h +@@ -511,10 +554,10 @@ list_tail->next_due = NULL; if (timers->active > 0) { @@ -328,7 +327,7 @@ return -1; } -@@ -531,7 +573,7 @@ wl_timer_heap_dispatch(struct wl_timer_h +@@ -531,7 +574,7 @@ static int wl_event_source_timer_dispatch(struct wl_event_source *source, @@ -337,16 +336,16 @@ { struct wl_event_source_timer *timer; -@@ -639,7 +681,7 @@ wl_event_source_timer_update(struct wl_e +@@ -639,7 +682,7 @@ if (tsource->heap_idx == 0) { /* Only update the timerfd if the new deadline is * the earliest */ - if (set_timer(timers->base.fd, deadline) < 0) -+ if (set_timer(timers->base.fd, deadline, timers) < 0) ++ if (set_timer(timers->base.fd, timers->data[0]->deadline, timers) < 0) return -1; } } else { -@@ -650,7 +692,7 @@ wl_event_source_timer_update(struct wl_e +@@ -650,7 +693,7 @@ if (timers->active == 0) { /* Only update the timerfd if this was the last * active timer */ @@ -355,7 +354,7 @@ return -1; } } -@@ -670,17 +712,11 @@ struct wl_event_source_signal { +@@ -670,17 +713,11 @@ static int wl_event_source_signal_dispatch(struct wl_event_source *source, @@ -377,15 +376,15 @@ return signal_source->func(signal_source->signal_number, signal_source->base.data); -@@ -717,6 +753,7 @@ wl_event_loop_add_signal(struct wl_event +@@ -717,6 +754,7 @@ { struct wl_event_source_signal *source; sigset_t mask; + struct kevent ev; - source = malloc(sizeof *source); + source = zalloc(sizeof *source); if (source == NULL) -@@ -724,15 +761,26 @@ wl_event_loop_add_signal(struct wl_event +@@ -724,15 +762,26 @@ source->base.interface = &signal_source_interface; source->signal_number = signal_number; @@ -399,8 +398,7 @@ - source->func = func; + source->base.fd = 0; + add_source(loop, &source->base, WL_EVENT_READABLE, data); - -- return add_source(loop, &source->base, WL_EVENT_READABLE, data); ++ + EV_SET(&ev, signal_number, EVFILT_SIGNAL, EV_ADD | EV_ENABLE, 0, 0, + source); + @@ -410,12 +408,13 @@ + free(source); + return NULL; + } -+ + +- return add_source(loop, &source->base, WL_EVENT_READABLE, data); + return &source->base; } /** \cond INTERNAL */ -@@ -829,17 +877,72 @@ WL_EXPORT int +@@ -829,24 +878,100 @@ wl_event_source_remove(struct wl_event_source *source) { struct wl_event_loop *loop = source->loop; @@ -467,6 +466,7 @@ - epoll_ctl(loop->epoll_fd, EPOLL_CTL_DEL, source->fd, NULL); close(source->fd); source->fd = -1; +- } + } else if (source->interface == &timer_source_interface) { + + /* @@ -486,18 +486,26 @@ + "Error removing timer = %i from kqueue: %s\n", + source->fd, strerror(saved_errno)); + } - } ++ } - if (source->interface == &timer_source_interface && - source->fd != TIMER_REMOVED) { +- /* Disarm the timer (and the loop's timerfd, if necessary), +- * before removing its space in the loop timer heap */ +- wl_event_source_timer_update(source, 0); +- wl_timer_heap_unreserve(&loop->timers); +- /* Set the fd field to to indicate that the timer should NOT +- * be dispatched in `wl_event_loop_dispatch` */ +- source->fd = TIMER_REMOVED; + if (source->fd != TIMER_REMOVED) { - /* Disarm the timer (and the loop's timerfd, if necessary), - * before removing its space in the loop timer heap */ - wl_event_source_timer_update(source, 0); -@@ -848,6 +951,27 @@ wl_event_source_remove(struct wl_event_s - * be dispatched in `wl_event_loop_dispatch` */ - source->fd = TIMER_REMOVED; - } ++ /* Disarm the timer (and the loop's timerfd, if necessary), ++ * before removing its space in the loop timer heap */ ++ wl_event_source_timer_update(source, 0); ++ wl_timer_heap_unreserve(&loop->timers); ++ /* Set the fd field to to indicate that the timer should NOT ++ * be dispatched in `wl_event_loop_dispatch` */ ++ source->fd = TIMER_REMOVED; ++ } + } else if (source->interface == &signal_source_interface) { + struct kevent ev; + int signal_number; @@ -518,11 +526,10 @@ + source->fd, strerror(saved_errno)); + } + source->fd = -1; -+ } + } wl_list_remove(&source->link); - wl_list_insert(&loop->destroy_list, &source->link); -@@ -889,8 +1013,8 @@ wl_event_loop_create(void) +@@ -889,8 +1014,8 @@ if (loop == NULL) return NULL; @@ -533,7 +540,7 @@ free(loop); return NULL; } -@@ -925,22 +1049,21 @@ wl_event_loop_destroy(struct wl_event_lo +@@ -925,22 +1050,21 @@ wl_event_loop_process_destroy_list(loop); wl_timer_heap_release(&loop->timers); @@ -557,9 +564,9 @@ - dispatch_result = source->interface->dispatch(source, &ep); + dispatch_result = source->interface->dispatch(source, &ev); if (dispatch_result < 0) { - wl_log("Source dispatch function returned negative value!"); - wl_log("This would previously accidentally suppress a follow-up dispatch"); -@@ -994,19 +1117,25 @@ wl_event_loop_dispatch_idle(struct wl_ev + wl_log("Source dispatch function returned negative value!\n"); + wl_log("This would previously accidentally suppress a follow-up dispatch\n"); +@@ -994,19 +1118,25 @@ WL_EXPORT int wl_event_loop_dispatch(struct wl_event_loop *loop, int timeout) { @@ -588,7 +595,7 @@ if (source == &loop->timers.base) has_timers = true; } -@@ -1022,9 +1151,10 @@ wl_event_loop_dispatch(struct wl_event_l +@@ -1022,9 +1152,10 @@ } for (i = 0; i < count; i++) { @@ -602,7 +609,7 @@ } wl_event_loop_process_destroy_list(loop); -@@ -1055,7 +1185,7 @@ wl_event_loop_dispatch(struct wl_event_l +@@ -1055,7 +1186,7 @@ WL_EXPORT int wl_event_loop_get_fd(struct wl_event_loop *loop) { diff --git a/ports/graphics/wayland/dragonfly/patch-src_wayland-os.c b/ports/graphics/wayland/dragonfly/patch-src_wayland-os.c new file mode 100644 index 000000000000..77ddeb5a5ef2 --- /dev/null +++ b/ports/graphics/wayland/dragonfly/patch-src_wayland-os.c @@ -0,0 +1,63 @@ +--- src/wayland-os.c.orig 2022-10-22 10:58:42.178509000 +0200 ++++ src/wayland-os.c 2022-10-31 16:39:33.763815000 +0100 +@@ -33,7 +33,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + #ifdef HAVE_SYS_UCRED_H +@@ -69,17 +69,19 @@ + { + int fd; + ++#ifdef SOCK_CLOEXEC + fd = socket(domain, type | SOCK_CLOEXEC, protocol); + if (fd >= 0) + return fd; + if (errno != EINVAL) + return -1; ++#endif + + fd = socket(domain, type, protocol); + return set_cloexec_or_close(fd); + } + +-#if defined(__FreeBSD__) ++#if defined(__FreeBSD__) || defined(__DragonFly__) + int + wl_os_socket_peercred(int sockfd, uid_t *uid, gid_t *gid, pid_t *pid) + { +@@ -87,7 +89,7 @@ + struct xucred ucred; + + len = sizeof(ucred); +- if (getsockopt(sockfd, SOL_LOCAL, LOCAL_PEERCRED, &ucred, &len) < 0 || ++ if (getsockopt(sockfd, 0, LOCAL_PEERCRED, &ucred, &len) < 0 || + ucred.cr_version != XUCRED_VERSION) + return -1; + *uid = ucred.cr_uid; +@@ -189,19 +191,11 @@ + } + + int +-wl_os_epoll_create_cloexec(void) ++wl_os_kqueue_create_cloexec(void) + { + int fd; + +-#ifdef EPOLL_CLOEXEC +- fd = epoll_create1(EPOLL_CLOEXEC); +- if (fd >= 0) +- return fd; +- if (errno != EINVAL) +- return -1; +-#endif +- +- fd = epoll_create(1); ++ fd = kqueue(); + return set_cloexec_or_close(fd); + } + diff --git a/ports/graphics/wayland/newport/files/patch-src_wayland-os.h b/ports/graphics/wayland/dragonfly/patch-src_wayland-os.h similarity index 62% rename from ports/graphics/wayland/newport/files/patch-src_wayland-os.h rename to ports/graphics/wayland/dragonfly/patch-src_wayland-os.h index 5dd661353dd0..d26074464093 100644 --- a/ports/graphics/wayland/newport/files/patch-src_wayland-os.h +++ b/ports/graphics/wayland/dragonfly/patch-src_wayland-os.h @@ -1,6 +1,6 @@ ---- src/wayland-os.h.orig 2018-07-19 16:09:29.690556000 +0300 -+++ src/wayland-os.h 2018-07-19 16:09:42.470627000 +0300 -@@ -36,7 +36,7 @@ +--- src/wayland-os.h.orig 2022-10-31 16:28:37.828288000 +0100 ++++ src/wayland-os.h 2022-10-31 16:28:58.707858000 +0100 +@@ -42,7 +42,7 @@ wl_os_recvmsg_cloexec(int sockfd, struct msghdr *msg, int flags); int diff --git a/ports/graphics/wayland/dragonfly/patch-src_wayland-server.c b/ports/graphics/wayland/dragonfly/patch-src_wayland-server.c new file mode 100644 index 000000000000..55fbab3f4b7b --- /dev/null +++ b/ports/graphics/wayland/dragonfly/patch-src_wayland-server.c @@ -0,0 +1,32 @@ +--- src/wayland-server.c.orig 2022-10-31 16:48:01.102621000 +0100 ++++ src/wayland-server.c 2022-11-01 14:08:34.644016000 +0100 +@@ -40,7 +40,6 @@ + #include + #include + #include +-#include + #include + #include + +@@ -1075,10 +1074,6 @@ + return NULL; + } + +- display->terminate_efd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); +- if (display->terminate_efd < 0) +- goto err_eventfd; +- + display->term_source = wl_event_loop_add_fd(display->loop, + display->terminate_efd, + WL_EVENT_READABLE, +@@ -1109,10 +1104,6 @@ + + err_term_source: + close(display->terminate_efd); +-err_eventfd: +- wl_event_loop_destroy(display->loop); +- free(display); +- return NULL; + } + + static void diff --git a/ports/graphics/wayland/dragonfly/patch-tests_os-wrappers-test.c b/ports/graphics/wayland/dragonfly/patch-tests_os-wrappers-test.c new file mode 100644 index 000000000000..d1738ff83cf1 --- /dev/null +++ b/ports/graphics/wayland/dragonfly/patch-tests_os-wrappers-test.c @@ -0,0 +1,42 @@ +--- tests/os-wrappers-test.c.orig 2022-11-01 14:26:03.250878000 +0100 ++++ tests/os-wrappers-test.c 2022-11-01 14:28:28.137680000 +0100 +@@ -39,7 +39,6 @@ + #include + #include + #include +-#include + + #include "wayland-private.h" + #include "test-runner.h" +@@ -152,15 +151,7 @@ + __attribute__ ((visibility("default"))) int + epoll_create1(int flags) + { +- wrapped_calls_epoll_create1++; +- +- if (fall_back) { +- wrapped_calls_epoll_create1++; /* epoll_create() not wrapped */ +- errno = EINVAL; +- return -1; +- } +- +- return real_epoll_create1(flags); ++ return 0; + } + + static void +@@ -375,6 +366,7 @@ + do_os_wrappers_recvmsg_cloexec(1); + } + ++#if !defined(__DragonFly__) + static void + do_os_wrappers_epoll_create_cloexec(int n) + { +@@ -406,5 +398,6 @@ + init_fallbacks(1); + do_os_wrappers_epoll_create_cloexec(2); + } ++#endif + + /* FIXME: add tests for wl_os_accept_cloexec() */ diff --git a/ports/graphics/wayland/newport/files/patch-tests_test-runner.c b/ports/graphics/wayland/dragonfly/patch-tests_test-runner.c similarity index 67% rename from ports/graphics/wayland/newport/files/patch-tests_test-runner.c rename to ports/graphics/wayland/dragonfly/patch-tests_test-runner.c index 9d7cd359485d..4f61a5c66b36 100644 --- a/ports/graphics/wayland/newport/files/patch-tests_test-runner.c +++ b/ports/graphics/wayland/dragonfly/patch-tests_test-runner.c @@ -1,6 +1,6 @@ ---- tests/test-runner.c -+++ tests/test-runner.c -@@ -28,6 +28,7 @@ +--- tests/test-runner.c.orig 2022-11-01 14:11:31.710109000 +0100 ++++ tests/test-runner.c 2022-11-01 14:24:36.312796000 +0100 +@@ -29,6 +29,7 @@ #include #include #include @@ -8,17 +8,17 @@ #include #include #include -@@ -37,7 +38,9 @@ - #include - #include - #include +@@ -42,7 +43,9 @@ + #ifdef HAVE_SYS_PROCCTL_H + #include + #elif defined(HAVE_SYS_PRCTL_H) +#ifndef __DragonFly__ #include +#endif #ifndef PR_SET_PTRACER # define PR_SET_PTRACER 0x59616d61 #endif -@@ -307,17 +310,22 @@ is_debugger_attached(void) +@@ -276,17 +279,22 @@ close(pipefd[0]); if (buf == '-') _exit(1); @@ -41,7 +41,7 @@ rc = prctl(PR_SET_PTRACER, pid); if (rc != 0 && errno != EINVAL) { /* An error prevents us from telling if a debugger is attached. -@@ -331,6 +339,7 @@ is_debugger_attached(void) +@@ -300,6 +308,7 @@ /* Signal to client that parent is ready by passing '+' */ write(pipefd[1], "+", 1); } @@ -49,7 +49,7 @@ close(pipefd[1]); waitpid(pid, &status, 0); -@@ -345,7 +354,11 @@ int main(int argc, char *argv[]) +@@ -315,18 +324,16 @@ const struct test *t; pid_t pid; int total, pass; @@ -59,9 +59,22 @@ siginfo_t info; +#endif - /* Load system malloc, free, and realloc */ - sys_calloc = dlsym(RTLD_NEXT, "calloc"); -@@ -394,6 +407,12 @@ int main(int argc, char *argv[]) + if (isatty(fileno(stderr))) + is_atty = 1; +- +- if (is_debugger_attached()) { +- fd_leak_check_enabled = 0; +- timeouts_enabled = 0; +- } else { +- fd_leak_check_enabled = !getenv("WAYLAND_TEST_NO_LEAK_CHECK"); +- timeouts_enabled = !getenv("WAYLAND_TEST_NO_TIMEOUTS"); +- } ++ fd_leak_check_enabled = !getenv("WAYLAND_TEST_NO_LEAK_CHECK"); ++ timeouts_enabled = !getenv("WAYLAND_TEST_NO_TIMEOUTS"); + + if (argc == 2 && strcmp(argv[1], "--help") == 0) + usage(argv[0], EXIT_SUCCESS); +@@ -358,6 +365,12 @@ if (pid == 0) run_test(t); /* never returns */ @@ -73,13 +86,13 @@ +#else if (waitid(P_PID, pid, &info, WEXITED)) { stderr_set_color(RED); - fprintf(stderr, "waitid failed: %m\n"); -@@ -401,7 +420,20 @@ int main(int argc, char *argv[]) + fprintf(stderr, "waitid failed: %s\n", +@@ -366,6 +379,21 @@ abort(); } +#endif - ++ + fprintf(stderr, "test \"%s\":\t", t->name); +#ifdef __DragonFly__ + if (WIFEXITED(status)) { @@ -92,10 +105,11 @@ + break; + } +#else ++ + switch (info.si_code) { case CLD_EXITED: - if (info.si_status == EXIT_SUCCESS) -@@ -425,6 +457,7 @@ int main(int argc, char *argv[]) +@@ -390,6 +418,7 @@ break; } diff --git a/ports/graphics/wayland/newport/Makefile b/ports/graphics/wayland/newport/Makefile deleted file mode 100644 index f7596fb85728..000000000000 --- a/ports/graphics/wayland/newport/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -PORTNAME= wayland -PORTVERSION= 1.18.0 -CATEGORIES= graphics -MASTER_SITES= https://wayland.freedesktop.org/releases/ -MAINTAINER= karu.pruun@gmail.com -COMMENT= Wayland Display Protocol implementation - -LICENSE= MIT -LICENSE_FILE= ${WRKSRC}/COPYING - -WRKSRC= ${WRKDIR}/${PORTNAME}-${PORTVERSION} - -LIB_DEPENDS= libexpat.so:textproc/expat2 \ - libffi.so:devel/libffi - -USES= gnome meson pkgconfig tar:xz -USE_GNOME= libxslt:build -USE_LDCONFIG= yes -MESON_ARGS= -Ddocumentation=false - -.include - diff --git a/ports/graphics/wayland/newport/Makefile.DragonFly b/ports/graphics/wayland/newport/Makefile.DragonFly deleted file mode 100644 index ff67db8ea993..000000000000 --- a/ports/graphics/wayland/newport/Makefile.DragonFly +++ /dev/null @@ -1,2 +0,0 @@ -# wayland-scanner created wayland-server-protocols.h gets raced in bulk -MAKE_JOBS_UNSAFE= yes diff --git a/ports/graphics/wayland/newport/distinfo b/ports/graphics/wayland/newport/distinfo deleted file mode 100644 index c3eabaf1fc8b..000000000000 --- a/ports/graphics/wayland/newport/distinfo +++ /dev/null @@ -1,2 +0,0 @@ -SHA256 (wayland-1.18.0.tar.xz) = 4675a79f091020817a98fd0484e7208c8762242266967f55a67776936c2e294d -SIZE (wayland-1.18.0.tar.xz) = 453968 diff --git a/ports/graphics/wayland/newport/files/patch-cursor_wayland-cursor.c b/ports/graphics/wayland/newport/files/patch-cursor_wayland-cursor.c deleted file mode 100644 index 7185e94c6e8c..000000000000 --- a/ports/graphics/wayland/newport/files/patch-cursor_wayland-cursor.c +++ /dev/null @@ -1,14 +0,0 @@ ---- cursor/wayland-cursor.c.orig 2015-06-13 00:51:38 +0200 -+++ cursor/wayland-cursor.c -@@ -97,7 +97,11 @@ - - pool->data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, - pool->fd, 0); -+#if defined(__DragonFly__) -+ if (pool->data == MAP_FAILED) -+#else - if (pool->data == (void *)-1) -+#endif - return 0; - pool->size = size; - diff --git a/ports/graphics/wayland/newport/files/patch-meson.build b/ports/graphics/wayland/newport/files/patch-meson.build deleted file mode 100644 index 68e8d83b57ea..000000000000 --- a/ports/graphics/wayland/newport/files/patch-meson.build +++ /dev/null @@ -1,19 +0,0 @@ ---- ./meson.build.orig 2020-04-08 15:17:04.718035000 +0300 -+++ ./meson.build 2020-04-08 15:17:56.818891000 +0300 -@@ -35,7 +35,6 @@ have_funcs = [ - 'mkostemp', - 'posix_fallocate', - 'prctl', -- 'memfd_create', - 'strndup', - ] - foreach f: have_funcs -@@ -46,8 +45,6 @@ if get_option('libraries') - ffi_dep = dependency('libffi') - - decls = [ -- { 'header': 'sys/signalfd.h', 'symbol': 'SFD_CLOEXEC' }, -- { 'header': 'sys/timerfd.h', 'symbol': 'TFD_CLOEXEC' }, - { 'header': 'time.h', 'symbol': 'CLOCK_MONOTONIC' }, - ] - diff --git a/ports/graphics/wayland/newport/files/patch-src_wayland-os.c b/ports/graphics/wayland/newport/files/patch-src_wayland-os.c deleted file mode 100644 index 48954f9aa0ac..000000000000 --- a/ports/graphics/wayland/newport/files/patch-src_wayland-os.c +++ /dev/null @@ -1,61 +0,0 @@ ---- src/wayland-os.c.orig 2018-07-20 14:23:23.966930000 +0300 -+++ src/wayland-os.c 2018-07-20 14:27:15.698222000 +0300 -@@ -30,7 +30,7 @@ - #include - #include - #include --#include -+#include - - #include "../config.h" - #include "wayland-os.h" -@@ -62,11 +62,13 @@ - { - int fd; - -+#ifdef SOCK_CLOEXEC - fd = socket(domain, type | SOCK_CLOEXEC, protocol); - if (fd >= 0) - return fd; - if (errno != EINVAL) - return -1; -+#endif - - fd = socket(domain, type, protocol); - return set_cloexec_or_close(fd); -@@ -121,6 +123,7 @@ - ssize_t - wl_os_recvmsg_cloexec(int sockfd, struct msghdr *msg, int flags) - { -+#ifdef MSG_CMSG_CLOEXEC - ssize_t len; - - len = recvmsg(sockfd, msg, flags | MSG_CMSG_CLOEXEC); -@@ -128,24 +131,17 @@ - return len; - if (errno != EINVAL) - return -1; -+#endif - - return recvmsg_cloexec_fallback(sockfd, msg, flags); - } - - int --wl_os_epoll_create_cloexec(void) -+wl_os_kqueue_create_cloexec(void) - { - int fd; - --#ifdef EPOLL_CLOEXEC -- fd = epoll_create1(EPOLL_CLOEXEC); -- if (fd >= 0) -- return fd; -- if (errno != EINVAL) -- return -1; --#endif -- -- fd = epoll_create(1); -+ fd = kqueue(); - return set_cloexec_or_close(fd); - } - diff --git a/ports/graphics/wayland/newport/files/patch-src_wayland-server.c b/ports/graphics/wayland/newport/files/patch-src_wayland-server.c deleted file mode 100644 index c726eeac4a91..000000000000 --- a/ports/graphics/wayland/newport/files/patch-src_wayland-server.c +++ /dev/null @@ -1,83 +0,0 @@ ---- src/wayland-server.c.orig 2020-04-08 17:02:04.353375000 +0300 -+++ src/wayland-server.c 2020-04-08 17:12:50.414179000 +0300 -@@ -44,6 +44,11 @@ - #include - #include - -+#if defined(__DragonFly__) -+#include -+#include -+#endif -+ - #include "wayland-util.h" - #include "wayland-private.h" - #include "wayland-server-private.h" -@@ -79,7 +84,11 @@ struct wl_client { - struct wl_list link; - struct wl_map objects; - struct wl_priv_signal destroy_signal; -+#if defined(__DragonFly__) -+ struct xucred xucred; -+#else - struct ucred ucred; -+#endif - int error; - struct wl_priv_signal resource_created_signal; - }; -@@ -315,7 +324,11 @@ wl_resource_post_error(struct wl_resourc - static void - destroy_client_with_error(struct wl_client *client, const char *reason) - { -+#if defined(__DragonFly__) -+ wl_log("%s (uid %u)\n", reason, client->xucred.cr_uid); -+#else - wl_log("%s (pid %u)\n", reason, client->ucred.pid); -+#endif - wl_client_destroy(client); - } - -@@ -514,7 +527,9 @@ WL_EXPORT struct wl_client * - wl_client_create(struct wl_display *display, int fd) - { - struct wl_client *client; -+#if !defined(__DragonFly__) - socklen_t len; -+#endif - - client = zalloc(sizeof *client); - if (client == NULL) -@@ -529,10 +544,12 @@ wl_client_create(struct wl_display *disp - if (!client->source) - goto err_client; - -+#if !defined(__DragonFly__) - len = sizeof client->ucred; - if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, - &client->ucred, &len) < 0) - goto err_source; -+#endif - - client->connection = wl_connection_create(fd); - if (client->connection == NULL) -@@ -586,12 +603,21 @@ WL_EXPORT void - wl_client_get_credentials(struct wl_client *client, - pid_t *pid, uid_t *uid, gid_t *gid) - { -+#if defined(__DragonFly__) -+ if (pid) -+ *pid = 0; -+ if (uid) -+ *uid = client->xucred.cr_uid; -+ if (gid) -+ *gid = client->xucred.cr_gid; -+#else - if (pid) - *pid = client->ucred.pid; - if (uid) - *uid = client->ucred.uid; - if (gid) - *gid = client->ucred.gid; -+#endif - } - - /** Get the file descriptor for the client diff --git a/ports/graphics/wayland/newport/files/patch-src_wayland-shm.c b/ports/graphics/wayland/newport/files/patch-src_wayland-shm.c deleted file mode 100644 index c730c9b0efa7..000000000000 --- a/ports/graphics/wayland/newport/files/patch-src_wayland-shm.c +++ /dev/null @@ -1,120 +0,0 @@ ---- src/wayland-shm.c.orig 2020-04-08 15:51:20.552406000 +0300 -+++ src/wayland-shm.c 2020-04-08 16:05:05.566225000 +0300 -@@ -30,6 +30,10 @@ - - #define _GNU_SOURCE - -+#if defined(__DragonFly__) -+#include -+#endif -+ - #include "config.h" - - #include -@@ -64,6 +68,9 @@ struct wl_shm_pool { - int32_t size; - int32_t new_size; - bool sigbus_is_impossible; -+#if defined(__DragonFly__) -+ int fd; -+#endif - }; - - struct wl_shm_buffer { -@@ -89,7 +96,24 @@ shm_pool_finish_resize(struct wl_shm_poo - if (pool->size == pool->new_size) - return; - -+#if defined(__DragonFly__) -+ int32_t osize = (pool->size + PAGE_SIZE - 1) & ~PAGE_MASK; -+ if (pool->new_size <= osize) { -+ pool->size = pool->new_size; -+ return; -+ } -+ data = mmap(pool->data + osize, pool->new_size - osize, PROT_READ, -+ MAP_SHARED | MAP_TRYFIXED, pool->fd, osize); -+ if (data == MAP_FAILED) { -+ munmap(pool->data, pool->size); -+ data = mmap(NULL, pool->new_size, PROT_READ, MAP_SHARED, pool->fd, 0); -+ } else { -+ pool->size = pool->new_size; -+ return; -+ } -+#else - data = mremap(pool->data, pool->size, pool->new_size, MREMAP_MAYMOVE); -+#endif - if (data == MAP_FAILED) { - wl_resource_post_error(pool->resource, - WL_SHM_ERROR_INVALID_FD, -@@ -116,6 +140,9 @@ shm_pool_unref(struct wl_shm_pool *pool, - return; - - munmap(pool->data, pool->size); -+#if defined(__DragonFly__) -+ close(pool->fd); -+#endif - free(pool); - } - -@@ -240,6 +267,8 @@ shm_pool_resize(struct wl_client *client - "shrinking pool invalid"); - return; - } -+ if (size == pool->size) -+ return; - - pool->new_size = size; - -@@ -292,7 +321,7 @@ shm_create_pool(struct wl_client *client - pool->size = size; - pool->new_size = size; - pool->data = mmap(NULL, size, -- PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); -+ PROT_READ, MAP_SHARED, fd, 0); - if (pool->data == MAP_FAILED) { - wl_resource_post_error(resource, - WL_SHM_ERROR_INVALID_FD, -@@ -300,13 +329,20 @@ shm_create_pool(struct wl_client *client - strerror(errno)); - goto err_free; - } -+#if defined(__DragonFly__) -+ pool->fd = fd; -+#else - close(fd); -+#endif - - pool->resource = - wl_resource_create(client, &wl_shm_pool_interface, 1, id); - if (!pool->resource) { - wl_client_post_no_memory(client); - munmap(pool->data, pool->size); -+#if defined(__DragonFly__) -+ close(fd); -+#endif - free(pool); - return; - } -@@ -511,6 +547,14 @@ sigbus_handler(int signum, siginfo_t *in - sigbus_data->fallback_mapping_used = 1; - - /* This should replace the previous mapping */ -+#if defined(__DragonFly__) -+ if (mmap(pool->data, pool->size, -+ PROT_READ, MAP_PRIVATE | MAP_FIXED | MAP_ANON, -+ 0, 0) == MAP_FAILED) { -+ reraise_sigbus(); -+ return; -+ } -+#else - if (mmap(pool->data, pool->size, - PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS, -@@ -518,6 +562,7 @@ sigbus_handler(int signum, siginfo_t *in - reraise_sigbus(); - return; - } -+#endif - } - - static void diff --git a/ports/graphics/wayland/newport/files/patch-src_wayland-util.c b/ports/graphics/wayland/newport/files/patch-src_wayland-util.c deleted file mode 100644 index 5da849bee129..000000000000 --- a/ports/graphics/wayland/newport/files/patch-src_wayland-util.c +++ /dev/null @@ -1,10 +0,0 @@ ---- src/wayland-util.c -+++ src/wayland-util.c -@@ -29,6 +29,7 @@ - #include - #include - #include -+#include - - #include "wayland-util.h" - #include "wayland-private.h" diff --git a/ports/graphics/wayland/newport/files/patch-tests_os-wrappers-test.c b/ports/graphics/wayland/newport/files/patch-tests_os-wrappers-test.c deleted file mode 100644 index 7136c3eb39ea..000000000000 --- a/ports/graphics/wayland/newport/files/patch-tests_os-wrappers-test.c +++ /dev/null @@ -1,49 +0,0 @@ ---- tests/os-wrappers-test.c.orig 2020-04-08 15:30:32.051523000 +0300 -+++ tests/os-wrappers-test.c 2020-04-08 17:43:14.174683000 +0300 -@@ -38,7 +38,9 @@ - #include - #include - #include -+#if !defined(__DragonFly__) - #include -+#endif - - #include "wayland-private.h" - #include "test-runner.h" -@@ -114,6 +116,7 @@ recvmsg(int sockfd, struct msghdr *msg, - return real_recvmsg(sockfd, msg, flags); - } - -+#if !defined(__DragonFly__) - __attribute__ ((visibility("default"))) int - epoll_create1(int flags) - { -@@ -127,6 +130,13 @@ epoll_create1(int flags) - - return real_epoll_create1(flags); - } -+#else -+__attribute__ ((visibility("default"))) int -+epoll_create1(int flags) -+{ -+ return 0; -+} -+#endif - - static void - do_os_wrappers_socket_cloexec(int n) -@@ -334,6 +344,7 @@ TEST(os_wrappers_recvmsg_cloexec_fallbac - do_os_wrappers_recvmsg_cloexec(1); - } - -+#if !defined(__DragonFly__) - static void - do_os_wrappers_epoll_create_cloexec(int n) - { -@@ -365,5 +376,6 @@ TEST(os_wrappers_epoll_create_cloexec_fa - init_fallbacks(1); - do_os_wrappers_epoll_create_cloexec(2); - } -+#endif - - /* FIXME: add tests for wl_os_accept_cloexec() */ diff --git a/ports/graphics/wayland/newport/files/patch-tests_test-compositor.c b/ports/graphics/wayland/newport/files/patch-tests_test-compositor.c deleted file mode 100644 index 3da4dd3a1ff9..000000000000 --- a/ports/graphics/wayland/newport/files/patch-tests_test-compositor.c +++ /dev/null @@ -1,46 +0,0 @@ ---- tests/test-compositor.c.orig 2017-07-25 14:34:46.337944000 +0300 -+++ tests/test-compositor.c 2017-07-25 14:33:46.687620000 +0300 -@@ -97,12 +97,33 @@ - { - struct client_info *ci = data; - struct display *d; -- siginfo_t status; -+#ifdef __DragonFly__ -+ int status; -+#else -+ siginfo_t status; -+#endif - - d = ci->display; - -- assert(waitid(P_PID, ci->pid, &status, WEXITED) != -1); -+#ifdef __DragonFly__ -+ assert(waitpid(ci->pid, &status, 0) != -1); -+#else -+ assert(waitid(P_PID, ci->pid, &status, WEXITED) != -1); -+#endif - -+#ifdef __DragonFly__ -+ if (WIFEXITED(status)) { -+ if (WEXITSTATUS(status) != EXIT_SUCCESS) -+ fprintf(stderr, "Client '%s' exited with code %d\n", -+ ci->name, WEXITSTATUS(status)); -+ -+ ci->exit_code = WEXITSTATUS(status); -+ } else if (WIFSIGNALED(status) || WCOREDUMP(status)) { -+ fprintf(stderr, "Client '%s' was killed by signal %d\n", -+ ci->name, WTERMSIG(status)); -+ ci->exit_code = WEXITSTATUS(status); -+ } -+#else - switch (status.si_code) { - case CLD_KILLED: - case CLD_DUMPED: -@@ -118,6 +139,7 @@ - ci->exit_code = status.si_status; - break; - } -+#endif - - ++d->clients_terminated_no; - if (d->clients_no == d->clients_terminated_no) { diff --git a/ports/graphics/wayland/newport/pkg-descr b/ports/graphics/wayland/newport/pkg-descr deleted file mode 100644 index f07298d3bc61..000000000000 --- a/ports/graphics/wayland/newport/pkg-descr +++ /dev/null @@ -1,3 +0,0 @@ -wayland is a compositor protocol - -WWW: http://wayland.freedesktop.org diff --git a/ports/graphics/wayland/newport/pkg-plist b/ports/graphics/wayland/newport/pkg-plist deleted file mode 100644 index cc92f9a6a551..000000000000 --- a/ports/graphics/wayland/newport/pkg-plist +++ /dev/null @@ -1,35 +0,0 @@ -bin/wayland-scanner -include/wayland-client-core.h -include/wayland-client-protocol.h -include/wayland-client.h -include/wayland-cursor.h -include/wayland-egl-backend.h -include/wayland-egl-core.h -include/wayland-egl.h -include/wayland-server-core.h -include/wayland-server-protocol.h -include/wayland-server.h -include/wayland-util.h -include/wayland-version.h -lib/libwayland-client.so -lib/libwayland-client.so.0 -lib/libwayland-client.so.0.3.0 -lib/libwayland-cursor.so -lib/libwayland-cursor.so.0 -lib/libwayland-cursor.so.0.0.0 -lib/libwayland-egl.so -lib/libwayland-egl.so.1 -lib/libwayland-egl.so.1.0.0 -lib/libwayland-server.so -lib/libwayland-server.so.0 -lib/libwayland-server.so.0.1.0 -libdata/pkgconfig/wayland-client.pc -libdata/pkgconfig/wayland-cursor.pc -libdata/pkgconfig/wayland-egl-backend.pc -libdata/pkgconfig/wayland-egl.pc -libdata/pkgconfig/wayland-scanner.pc -libdata/pkgconfig/wayland-server.pc -share/aclocal/wayland-scanner.m4 -%%DATADIR%%/wayland-scanner.mk -%%DATADIR%%/wayland.dtd -%%DATADIR%%/wayland.xml