git: 571ee96df4f6 - main - graphics/wayland: update to 1.20.0

From: Jan Beich <jbeich_at_FreeBSD.org>
Date: Fri, 10 Dec 2021 02:15:37 UTC
The branch main has been updated by jbeich:

URL: https://cgit.FreeBSD.org/ports/commit/?id=571ee96df4f6e8d0028f2b678c903b1cb3b2300f

commit 571ee96df4f6e8d0028f2b678c903b1cb3b2300f
Author:     Jan Beich <jbeich@FreeBSD.org>
AuthorDate: 2021-10-09 13:09:04 +0000
Commit:     Jan Beich <jbeich@FreeBSD.org>
CommitDate: 2021-12-10 02:14:54 +0000

    graphics/wayland: update to 1.20.0
    
    Changes:        https://lists.freedesktop.org/archives/wayland-devel/2021-December/042064.html
    PR:             258547
    Exp-run by:     antoine
    Approved by:    manu
---
 devel/sdl20/files/patch-wayland-1.20               |  29 ++++
 graphics/wayland/Makefile                          |   8 +-
 graphics/wayland/distinfo                          |   8 +-
 .../wayland/files/patch-cursor_os-compatibility.c  |  23 ----
 graphics/wayland/files/patch-meson.build           |  33 -----
 graphics/wayland/files/patch-src_meson.build       |  36 -----
 graphics/wayland/files/patch-src_wayland-os.c      |  97 --------------
 graphics/wayland/files/patch-src_wayland-os.h      |  12 --
 graphics/wayland/files/patch-src_wayland-server.c  | 109 ---------------
 graphics/wayland/files/patch-src_wayland-shm.c     | 147 ---------------------
 graphics/wayland/files/patch-tests_client-test.c   |  19 ---
 .../wayland/files/patch-tests_connection-test.c    |  29 ----
 .../wayland/files/patch-tests_event-loop-test.c    |  44 ------
 .../wayland/files/patch-tests_os-wrappers-test.c   | 122 -----------------
 graphics/wayland/files/patch-tests_queue-test.c    |  21 ---
 graphics/wayland/files/patch-tests_test-helpers.c  |  48 -------
 graphics/wayland/files/patch-tests_test-runner.c   | 128 ------------------
 graphics/wayland/pkg-plist                         |   8 +-
 mail/thunderbird/files/patch-wayland-1.20          |  25 ++++
 www/firefox-esr/files/patch-wayland-1.20           |  25 ++++
 www/firefox/files/patch-wayland-1.20               |  25 ++++
 21 files changed, 112 insertions(+), 884 deletions(-)

diff --git a/devel/sdl20/files/patch-wayland-1.20 b/devel/sdl20/files/patch-wayland-1.20
new file mode 100644
index 000000000000..bd219dccc701
--- /dev/null
+++ b/devel/sdl20/files/patch-wayland-1.20
@@ -0,0 +1,29 @@
+ld: error: undefined symbol: wl_proxy_marshal_flags
+>>> referenced by SDL_waylanddatamanager.c
+>>>               build/.libs/SDL_waylanddatamanager.o:(Wayland_data_source_destroy)
+>>> referenced by SDL_waylanddatamanager.c
+>>>               build/.libs/SDL_waylanddatamanager.o:(Wayland_data_offer_receive)
+>>> referenced by SDL_waylanddatamanager.c
+>>>               build/.libs/SDL_waylanddatamanager.o:(Wayland_data_offer_destroy)
+>>> referenced 109 more times
+
+--- src/video/wayland/SDL_waylanddyn.h.orig	2020-03-11 01:36:18 UTC
++++ src/video/wayland/SDL_waylanddyn.h
+@@ -75,6 +75,7 @@ void SDL_WAYLAND_UnloadSymbols(void);
+ #define wl_proxy_create (*WAYLAND_wl_proxy_create)
+ #define wl_proxy_destroy (*WAYLAND_wl_proxy_destroy)
+ #define wl_proxy_marshal (*WAYLAND_wl_proxy_marshal)
++#define wl_proxy_marshal_flags (*WAYLAND_wl_proxy_marshal_flags)
+ #define wl_proxy_set_user_data (*WAYLAND_wl_proxy_set_user_data)
+ #define wl_proxy_get_user_data (*WAYLAND_wl_proxy_get_user_data)
+ #define wl_proxy_get_version (*WAYLAND_wl_proxy_get_version)
+--- src/video/wayland/SDL_waylandsym.h.orig	2020-03-11 01:36:18 UTC
++++ src/video/wayland/SDL_waylandsym.h
+@@ -35,6 +35,7 @@
+ 
+ SDL_WAYLAND_MODULE(WAYLAND_CLIENT)
+ SDL_WAYLAND_SYM(void, wl_proxy_marshal, (struct wl_proxy *, uint32_t, ...))
++SDL_WAYLAND_SYM(struct wl_proxy *, wl_proxy_marshal_flags, (struct wl_proxy *, uint32_t, const struct wl_interface *, uint32_t, uint32_t, ...))
+ SDL_WAYLAND_SYM(struct wl_proxy *, wl_proxy_create, (struct wl_proxy *, const struct wl_interface *))
+ SDL_WAYLAND_SYM(void, wl_proxy_destroy, (struct wl_proxy *))
+ SDL_WAYLAND_SYM(int, wl_proxy_add_listener, (struct wl_proxy *, void (**)(void), void *))
diff --git a/graphics/wayland/Makefile b/graphics/wayland/Makefile
index f7a7ef2c7ceb..341d12a4ebb1 100644
--- a/graphics/wayland/Makefile
+++ b/graphics/wayland/Makefile
@@ -1,14 +1,10 @@
 # Created by: kwm@FreeBSD.org
 
 PORTNAME=	wayland
-PORTVERSION=	1.19.0
-PORTREVISION=	1
+DISTVERSION=	1.20.0
 CATEGORIES=	graphics wayland
 MASTER_SITES=	https://wayland.freedesktop.org/releases/
 
-PATCH_SITES=	https://gitlab.freedesktop.org/${PORTNAME}/${PORTNAME}/commit/
-PATCHFILES+=	ed55438366e93d70867e3ba6b80978673e536fc0.patch:-p1 # MR 133
-
 MAINTAINER=	x11@FreeBSD.org
 COMMENT=	Wayland composite "server"
 
@@ -19,8 +15,6 @@ LIB_DEPENDS=	libexpat.so:textproc/expat2 \
 		libffi.so:devel/libffi \
 		libepoll-shim.so:devel/libepoll-shim
 
-CFLAGS+=	"-I${LOCALBASE}/include/libepoll-shim"
-
 USES=		cpe gnome meson pkgconfig tar:xz
 USE_GNOME=	libxslt:build
 USE_LDCONFIG=	yes
diff --git a/graphics/wayland/distinfo b/graphics/wayland/distinfo
index 7e14bd29b092..805396f3a16a 100644
--- a/graphics/wayland/distinfo
+++ b/graphics/wayland/distinfo
@@ -1,5 +1,3 @@
-TIMESTAMP = 1622412504
-SHA256 (wayland-1.19.0.tar.xz) = baccd902300d354581cd5ad3cc49daa4921d55fb416a5883e218750fef166d15
-SIZE (wayland-1.19.0.tar.xz) = 456380
-SHA256 (ed55438366e93d70867e3ba6b80978673e536fc0.patch) = cdf90fc3ec9455aad348a5251842f9035484fb49a7d10fd4930192002308c6ea
-SIZE (ed55438366e93d70867e3ba6b80978673e536fc0.patch) = 927
+TIMESTAMP = 1639066836
+SHA256 (wayland-1.20.0.tar.xz) = b8a034154c7059772e0fdbd27dbfcda6c732df29cae56a82274f6ec5d7cd8725
+SIZE (wayland-1.20.0.tar.xz) = 225188
diff --git a/graphics/wayland/files/patch-cursor_os-compatibility.c b/graphics/wayland/files/patch-cursor_os-compatibility.c
deleted file mode 100644
index 7f81a2d1aae1..000000000000
--- a/graphics/wayland/files/patch-cursor_os-compatibility.c
+++ /dev/null
@@ -1,23 +0,0 @@
---- cursor/os-compatibility.c.orig	2020-02-11 23:46:03 UTC
-+++ cursor/os-compatibility.c
-@@ -34,7 +34,7 @@
- #include <string.h>
- #include <stdlib.h>
- 
--#ifdef HAVE_MEMFD_CREATE
-+#if defined(HAVE_MEMFD_CREATE) || defined(__FreeBSD__)
- #include <sys/mman.h>
- #endif
- 
-@@ -131,6 +131,11 @@ os_create_anonymous_file(off_t size)
- 		 */
- 		fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
- 	} else
-+#elif defined(__FreeBSD__)
-+/* posix_fallocate returns ENODEV before https://svnweb.freebsd.org/changeset/base/356512 */
-+#undef HAVE_POSIX_FALLOCATE
-+	fd = shm_open(SHM_ANON, O_CREAT | O_RDWR | O_CLOEXEC, 0600); // shm_open is always CLOEXEC
-+	if (fd < 0)
- #endif
- 	{
- 		path = getenv("XDG_RUNTIME_DIR");
diff --git a/graphics/wayland/files/patch-meson.build b/graphics/wayland/files/patch-meson.build
deleted file mode 100644
index f20c90ba0264..000000000000
--- a/graphics/wayland/files/patch-meson.build
+++ /dev/null
@@ -1,33 +0,0 @@
---- meson.build.orig	2020-02-11 23:46:03 UTC
-+++ meson.build
-@@ -26,7 +26,14 @@ add_project_arguments(
- 	language: 'c'
- )
- 
--foreach h: [ 'sys/prctl.h' ]
-+have_headers = [
-+	'signal.h',
-+	'sys/epoll.h',
-+	'sys/prctl.h',
-+	'sys/ucred.h',
-+]
-+
-+foreach h: have_headers
- 	config_h.set('HAVE_' + h.underscorify().to_upper(), cc.has_header(h))
- endforeach
- 
-@@ -37,12 +44,14 @@ have_funcs = [
- 	'prctl',
- 	'memfd_create',
- 	'strndup',
-+	'waitid',
- ]
- foreach f: have_funcs
- 	config_h.set('HAVE_' + f.underscorify().to_upper(), cc.has_function(f))
- endforeach
- 
- if get_option('libraries')
-+	epoll_dep = dependency('epoll-shim', required: false)
- 	ffi_dep = dependency('libffi')
- 
- 	decls = [
diff --git a/graphics/wayland/files/patch-src_meson.build b/graphics/wayland/files/patch-src_meson.build
deleted file mode 100644
index e064387029e4..000000000000
--- a/graphics/wayland/files/patch-src_meson.build
+++ /dev/null
@@ -1,36 +0,0 @@
---- src/meson.build.orig	2021-01-06 19:25:15 UTC
-+++ src/meson.build
-@@ -77,7 +77,7 @@ if get_option('libraries')
- 			'connection.c',
- 			'wayland-os.c'
- 		],
--		dependencies: [ ffi_dep, rt_dep ]
-+		dependencies: [ epoll_dep, ffi_dep, rt_dep ]
- 	)
- 
- 	wayland_private_dep = declare_dependency(
-@@ -151,6 +151,7 @@ if get_option('libraries')
- 		],
- 		version: '0.1.0',
- 		dependencies: [
-+			epoll_dep,
- 			ffi_dep,
- 			wayland_private_dep,
- 			wayland_util_dep,
-@@ -165,7 +166,7 @@ if get_option('libraries')
- 	wayland_server_dep = declare_dependency(
- 		link_with: wayland_server,
- 		include_directories: [ root_inc, include_directories('.') ],
--		dependencies: [ ffi_dep, mathlib_dep, threads_dep ],
-+		dependencies: [ epoll_dep, ffi_dep, mathlib_dep, threads_dep ],
- 		sources: [
- 			wayland_server_protocol_core_h,
- 			wayland_server_protocol_h
-@@ -194,6 +195,7 @@ if get_option('libraries')
- 		],
- 		version: '0.3.0',
- 		dependencies: [
-+			epoll_dep,
- 			ffi_dep,
- 			wayland_private_dep,
- 			wayland_util_dep,
diff --git a/graphics/wayland/files/patch-src_wayland-os.c b/graphics/wayland/files/patch-src_wayland-os.c
deleted file mode 100644
index dfd96a1d8e20..000000000000
--- a/graphics/wayland/files/patch-src_wayland-os.c
+++ /dev/null
@@ -1,97 +0,0 @@
---- src/wayland-os.c.orig	2017-08-08 18:20:52 UTC
-+++ src/wayland-os.c
-@@ -25,6 +25,8 @@
- 
- #define _GNU_SOURCE
- 
-+#include "../config.h"
-+
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <unistd.h>
-@@ -32,7 +34,6 @@
- #include <errno.h>
- #include <sys/epoll.h>
- 
--#include "../config.h"
- #include "wayland-os.h"
- 
- static int
-@@ -62,26 +63,50 @@ wl_os_socket_cloexec(int domain, int type, int protoco
- {
- 	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);
- }
- 
- int
-+wl_os_socketpair_cloexec(int domain, int type, int protocol, int sv[2])
-+{
-+       int retval;
-+
-+#ifdef SOCK_CLOEXEC
-+       retval = socketpair(domain, type | SOCK_CLOEXEC, protocol, sv);
-+       if (retval >= 0)
-+               return retval;
-+       if (errno != EINVAL)
-+               return -1;
-+#endif
-+
-+       retval = socketpair(domain, type, protocol, sv);
-+       if (set_cloexec_or_close(sv[0]) < 0 || set_cloexec_or_close(sv[1]) < 0)
-+               retval = -1;
-+
-+       return retval;
-+}
-+
-+int
- wl_os_dupfd_cloexec(int fd, long minfd)
- {
- 	int newfd;
- 
-+#ifdef F_DUPFD_CLOEXEC
- 	newfd = fcntl(fd, F_DUPFD_CLOEXEC, minfd);
- 	if (newfd >= 0)
- 		return newfd;
- 	if (errno != EINVAL)
- 		return -1;
-+#endif
- 
- 	newfd = fcntl(fd, F_DUPFD, minfd);
- 	return set_cloexec_or_close(newfd);
-@@ -123,15 +148,18 @@ wl_os_recvmsg_cloexec(int sockfd, struct msghdr *msg, 
- {
- 	ssize_t len;
- 
-+#ifdef MSG_CMSG_CLOEXEC
- 	len = recvmsg(sockfd, msg, flags | MSG_CMSG_CLOEXEC);
- 	if (len >= 0)
- 		return len;
- 	if (errno != EINVAL)
- 		return -1;
-+#endif
- 
- 	return recvmsg_cloexec_fallback(sockfd, msg, flags);
- }
- 
-+#ifdef HAVE_SYS_EPOLL_H
- int
- wl_os_epoll_create_cloexec(void)
- {
-@@ -148,6 +176,7 @@ wl_os_epoll_create_cloexec(void)
- 	fd = epoll_create(1);
- 	return set_cloexec_or_close(fd);
- }
-+#endif
- 
- int
- wl_os_accept_cloexec(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
diff --git a/graphics/wayland/files/patch-src_wayland-os.h b/graphics/wayland/files/patch-src_wayland-os.h
deleted file mode 100644
index ee1d3b6c3360..000000000000
--- a/graphics/wayland/files/patch-src_wayland-os.h
+++ /dev/null
@@ -1,12 +0,0 @@
---- src/wayland-os.h.orig	2017-08-08 18:20:52 UTC
-+++ src/wayland-os.h
-@@ -30,6 +30,9 @@ int
- wl_os_socket_cloexec(int domain, int type, int protocol);
- 
- int
-+wl_os_socketpair_cloexec(int domain, int type, int protocol, int sv[2]);
-+
-+int
- wl_os_dupfd_cloexec(int fd, long minfd);
- 
- ssize_t
diff --git a/graphics/wayland/files/patch-src_wayland-server.c b/graphics/wayland/files/patch-src_wayland-server.c
deleted file mode 100644
index 981ea2fe1f20..000000000000
--- a/graphics/wayland/files/patch-src_wayland-server.c
+++ /dev/null
@@ -1,109 +0,0 @@
---- src/wayland-server.c.orig	2020-12-21 10:17:10 UTC
-+++ src/wayland-server.c
-@@ -25,6 +25,8 @@
- 
- #define _GNU_SOURCE
- 
-+#include "../config.h"
-+
- #include <stdbool.h>
- #include <stdlib.h>
- #include <stdint.h>
-@@ -44,6 +46,15 @@
- #include <sys/file.h>
- #include <sys/stat.h>
- 
-+#ifdef HAVE_SYS_UCRED_H
-+#include <sys/param.h>
-+#include <sys/ucred.h>
-+#ifndef SOL_LOCAL
-+/* DragonFly or FreeBSD < 12.2 */
-+#define SOL_LOCAL 0
-+#endif
-+#endif
-+
- #include "wayland-util.h"
- #include "wayland-private.h"
- #include "wayland-server-private.h"
-@@ -79,7 +86,13 @@ struct wl_client {
- 	struct wl_list link;
- 	struct wl_map objects;
- 	struct wl_priv_signal destroy_signal;
-+#ifdef HAVE_SYS_UCRED_H
-+	/* FreeBSD */
-+	struct xucred xucred;
-+#else
-+	/* Linux */
- 	struct ucred ucred;
-+#endif
- 	int error;
- 	struct wl_priv_signal resource_created_signal;
- };
-@@ -315,7 +328,17 @@ wl_resource_post_error(struct wl_resource *resource,
- static void
- destroy_client_with_error(struct wl_client *client, const char *reason)
- {
-+#ifdef HAVE_SYS_UCRED_H
-+	/* FreeBSD */
-+#if defined(__FreeBSD__) && __FreeBSD_version >= 1300030
-+	wl_log("%s (pid %u)\n", reason, client->xucred.cr_pid);
-+#else
-+	wl_log("%s\n", reason);
-+#endif
-+#else
-+	/* Linux */
- 	wl_log("%s (pid %u)\n", reason, client->ucred.pid);
-+#endif
- 	wl_client_destroy(client);
- }
- 
-@@ -529,10 +552,20 @@ wl_client_create(struct wl_display *display, int fd)
- 	if (!client->source)
- 		goto err_client;
- 
-+#if defined(SO_PEERCRED)
-+	/* Linux */
- 	len = sizeof client->ucred;
- 	if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED,
- 		       &client->ucred, &len) < 0)
- 		goto err_source;
-+#elif defined(LOCAL_PEERCRED)
-+	/* FreeBSD */
-+	len = sizeof client->xucred;
-+	if (getsockopt(fd, SOL_LOCAL, LOCAL_PEERCRED,
-+		       &client->xucred, &len) < 0 ||
-+		       client->xucred.cr_version != XUCRED_VERSION)
-+		goto err_source;
-+#endif
- 
- 	client->connection = wl_connection_create(fd);
- 	if (client->connection == NULL)
-@@ -586,12 +619,28 @@ WL_EXPORT void
- wl_client_get_credentials(struct wl_client *client,
- 			  pid_t *pid, uid_t *uid, gid_t *gid)
- {
-+#ifdef HAVE_SYS_UCRED_H
-+	/* DragonFly or FreeBSD */
- 	if (pid)
-+#if defined(__FreeBSD__) && __FreeBSD_version >= 1300030
-+		/* Since https://cgit.freebsd.org/src/commit/?id=c5afec6e895a */
-+		*pid = client->xucred.cr_pid;
-+#else
-+		*pid = 0;
-+#endif
-+	if (uid)
-+		*uid = client->xucred.cr_uid;
-+	if (gid)
-+		*gid = client->xucred.cr_gid;
-+#else
-+	/* Linux */
-+	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/graphics/wayland/files/patch-src_wayland-shm.c b/graphics/wayland/files/patch-src_wayland-shm.c
deleted file mode 100644
index a2561fc81ffd..000000000000
--- a/graphics/wayland/files/patch-src_wayland-shm.c
+++ /dev/null
@@ -1,147 +0,0 @@
---- src/wayland-shm.c.orig	2020-02-11 23:46:03 UTC
-+++ src/wayland-shm.c
-@@ -32,6 +32,8 @@
- 
- #include "config.h"
- 
-+#include "../config.h"
-+
- #include <stdbool.h>
- #include <stdio.h>
- #include <stdlib.h>
-@@ -64,6 +66,9 @@ struct wl_shm_pool {
- 	int32_t size;
- 	int32_t new_size;
- 	bool sigbus_is_impossible;
-+#ifdef HAVE_SYS_UCRED_H
-+	int fd;
-+#endif
- };
- 
- struct wl_shm_buffer {
-@@ -81,15 +86,24 @@ struct wl_shm_sigbus_data {
- 	int fallback_mapping_used;
- };
- 
-+static void *mremap_compat_maymove(void *, size_t, size_t, int, int, int);
-+
- static void
- shm_pool_finish_resize(struct wl_shm_pool *pool)
- {
- 	void *data;
-+	int fd = -1;
- 
- 	if (pool->size == pool->new_size)
- 		return;
- 
--	data = mremap(pool->data, pool->size, pool->new_size, MREMAP_MAYMOVE);
-+#ifdef HAVE_SYS_UCRED_H
-+	fd = pool->fd;
-+#endif
-+
-+	data = mremap_compat_maymove(pool->data, pool->size, pool->new_size,
-+				     PROT_READ | PROT_WRITE, MAP_SHARED, fd);
-+
- 	if (data == MAP_FAILED) {
- 		wl_resource_post_error(pool->resource,
- 				       WL_SHM_ERROR_INVALID_FD,
-@@ -115,6 +129,10 @@ shm_pool_unref(struct wl_shm_pool *pool, bool external
- 	if (pool->internal_refcount + pool->external_refcount)
- 		return;
- 
-+#ifdef HAVE_SYS_UCRED_H
-+	close(pool->fd);
-+#endif
-+
- 	munmap(pool->data, pool->size);
- 	free(pool);
- }
-@@ -228,6 +246,73 @@ shm_pool_destroy(struct wl_client *client, struct wl_r
- 	wl_resource_destroy(resource);
- }
- 
-+#ifdef HAVE_MREMAP
-+static void *
-+mremap_compat_maymove(void *old_address, size_t old_size, size_t new_size,
-+		      int old_prot, int old_flags, int old_fd)
-+{
-+	return mremap(old_address, old_size, new_size, MREMAP_MAYMOVE);
-+}
-+#else
-+static void *
-+mremap_compat_maymove(void *old_address, size_t old_size, size_t new_size,
-+		      int old_prot, int old_flags, int old_fd)
-+{
-+	/* FreeBSD doesn't support mremap() yet, so we have to emulate it.
-+	 * This assumes MREMAP_MAYMOVE is the only flag in use. */
-+	if (new_size == old_size) {
-+		return old_address;
-+	} else if (new_size < old_size) {
-+		/* Shrinking: munmap() the spare region. */
-+		munmap(old_address + old_size, new_size - old_size);
-+		return old_address;
-+	} else {
-+		void *ret;
-+
-+		/* Growing. Try and mmap() the extra region at the end of
-+		 * our existing allocation. If that gets mapped in the
-+		 * wrong place, fall back to mmap()ing an entirely new
-+		 * region of new_size and copying the data across. */
-+		ret = mmap(old_address + old_size, new_size - old_size,
-+			   old_prot, old_flags, old_fd, 0);
-+
-+/* FIXME TODO: msync() before munmap()? */
-+		if (ret == MAP_FAILED) {
-+			/* Total failure! */
-+			return ret;
-+		} else if (ret == old_address + old_size) {
-+			/* Success. */
-+			return old_address;
-+		} else if (ret != old_address + old_size) {
-+			/* Partial failure. Fall back to mapping an
-+			 * entirely new region. Unmap the region we
-+			 * just mapped first. */
-+			munmap(ret, new_size - old_size);
-+
-+			/* Map an entirely new region. */
-+			ret = mmap(NULL, new_size,
-+				   old_prot, old_flags, old_fd, 0);
-+			if (ret == MAP_FAILED) {
-+				/* Total failure! */
-+				return ret;
-+			}
-+
-+			/* Copy the old data across. Implicit assumption
-+			 * that the old and new regions don't overlap. */
-+			memcpy(ret, old_address, old_size);
-+
-+			/* Unmap the old region. */
-+			munmap(old_address, old_size);
-+
-+			return ret;
-+		}
-+	}
-+
-+	/* Unreachable. */
-+	return MAP_FAILED;
-+}
-+#endif
-+
- static void
- shm_pool_resize(struct wl_client *client, struct wl_resource *resource,
- 		int32_t size)
-@@ -300,7 +385,14 @@ shm_create_pool(struct wl_client *client, struct wl_re
- 				       strerror(errno));
- 		goto err_free;
- 	}
-+
-+#ifdef HAVE_SYS_UCRED_H
-+	/* We need to keep the FD around on FreeBSD so we can implement
-+	 * mremap(). See: mremap_compat_maymove(). */
-+	pool->fd = fd;
-+#else
- 	close(fd);
-+#endif
- 
- 	pool->resource =
- 		wl_resource_create(client, &wl_shm_pool_interface, 1, id);
diff --git a/graphics/wayland/files/patch-tests_client-test.c b/graphics/wayland/files/patch-tests_client-test.c
deleted file mode 100644
index 88822779dd6a..000000000000
--- a/graphics/wayland/files/patch-tests_client-test.c
+++ /dev/null
@@ -1,19 +0,0 @@
---- tests/client-test.c.orig	2015-07-06 19:38:51 UTC
-+++ tests/client-test.c
-@@ -34,6 +34,7 @@
- #include <sys/types.h>
- #include <sys/stat.h>
- 
-+#include "wayland-os.h"
- #include "wayland-private.h"
- #include "wayland-server.h"
- #include "test-runner.h"
-@@ -59,7 +60,7 @@ TEST(client_destroy_listener)
- 	struct client_destroy_listener a, b;
- 	int s[2];
- 
--	assert(socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, s) == 0);
-+	assert(wl_os_socketpair_cloexec(AF_UNIX, SOCK_STREAM, 0, s) == 0);
- 	display = wl_display_create();
- 	assert(display);
- 	client = wl_client_create(display, s[0]);
diff --git a/graphics/wayland/files/patch-tests_connection-test.c b/graphics/wayland/files/patch-tests_connection-test.c
deleted file mode 100644
index 365888d2b712..000000000000
--- a/graphics/wayland/files/patch-tests_connection-test.c
+++ /dev/null
@@ -1,29 +0,0 @@
---- tests/connection-test.c.orig	2017-02-07 22:59:06 UTC
-+++ tests/connection-test.c
-@@ -37,6 +37,7 @@
- #include <sys/stat.h>
- #include <poll.h>
- 
-+#include "wayland-os.h"
- #include "wayland-private.h"
- #include "test-runner.h"
- #include "test-compositor.h"
-@@ -48,7 +49,7 @@ setup(int *s)
- {
- 	struct wl_connection *connection;
- 
--	assert(socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, s) == 0);
-+	assert(wl_os_socketpair_cloexec(AF_UNIX, SOCK_STREAM, 0, s) == 0);
- 
- 	connection = wl_connection_create(s[0]);
- 	assert(connection);
-@@ -181,8 +182,7 @@ struct marshal_data {
- static void
- setup_marshal_data(struct marshal_data *data)
- {
--	assert(socketpair(AF_UNIX,
--			  SOCK_STREAM | SOCK_CLOEXEC, 0, data->s) == 0);
-+	assert(wl_os_socketpair_cloexec(AF_UNIX, SOCK_STREAM, 0, data->s) == 0);
- 	data->read_connection = wl_connection_create(data->s[0]);
- 	assert(data->read_connection);
- 	data->write_connection = wl_connection_create(data->s[1]);
diff --git a/graphics/wayland/files/patch-tests_event-loop-test.c b/graphics/wayland/files/patch-tests_event-loop-test.c
deleted file mode 100644
index 6480c4b86ee1..000000000000
--- a/graphics/wayland/files/patch-tests_event-loop-test.c
+++ /dev/null
@@ -1,44 +0,0 @@
---- tests/event-loop-test.c.orig	2020-02-11 23:46:03 UTC
-+++ tests/event-loop-test.c
-@@ -168,10 +168,10 @@ TEST(event_loop_signal)
- 					  signal_callback, &got_it);
- 	assert(source);
- 
--	wl_event_loop_dispatch(loop, 0);
-+	assert(wl_event_loop_dispatch(loop, 0) == 0);
- 	assert(!got_it);
--	kill(getpid(), SIGUSR1);
--	wl_event_loop_dispatch(loop, 0);
-+	assert(kill(getpid(), SIGUSR1) == 0);
-+	assert(wl_event_loop_dispatch(loop, 0) == 0);
- 	assert(got_it == 1);
- 
- 	wl_event_source_remove(source);
-@@ -235,11 +235,11 @@ TEST(event_loop_timer)
- 
- 	source1 = wl_event_loop_add_timer(loop, timer_callback, &got_it);
- 	assert(source1);
--	wl_event_source_timer_update(source1, 20);
-+	assert(wl_event_source_timer_update(source1, 20) == 0);
- 
- 	source2 = wl_event_loop_add_timer(loop, timer_callback, &got_it);
- 	assert(source2);
--	wl_event_source_timer_update(source2, 100);
-+	assert(wl_event_source_timer_update(source2, 100) == 0);
- 
- 	/* Check that the timer marked for 20 msec from now fires within 30
- 	 * msec, and that the timer marked for 100 msec is expected to fire
-@@ -248,11 +248,11 @@ TEST(event_loop_timer)
- 
- 	wl_event_loop_dispatch(loop, 0);
- 	assert(got_it == 0);
--	wl_event_loop_dispatch(loop, 30);
-+	assert(wl_event_loop_dispatch(loop, 30) == 0);
- 	assert(got_it == 1);
- 	wl_event_loop_dispatch(loop, 0);
- 	assert(got_it == 1);
--	wl_event_loop_dispatch(loop, 90);
-+	assert(wl_event_loop_dispatch(loop, 90) == 0);
- 	assert(got_it == 2);
- 
- 	wl_event_source_remove(source1);
diff --git a/graphics/wayland/files/patch-tests_os-wrappers-test.c b/graphics/wayland/files/patch-tests_os-wrappers-test.c
deleted file mode 100644
index e58d75ba56fd..000000000000
--- a/graphics/wayland/files/patch-tests_os-wrappers-test.c
+++ /dev/null
@@ -1,122 +0,0 @@
---- tests/os-wrappers-test.c.orig	2017-08-08 18:20:52 UTC
-+++ tests/os-wrappers-test.c
-@@ -26,6 +26,8 @@
- 
- #define _GNU_SOURCE
- 
-+#include "../config.h"
-+
- #include <stdlib.h>
- #include <stdint.h>
- #include <assert.h>
-@@ -73,15 +75,22 @@ socket(int domain, int type, int protocol)
- {
- 	wrapped_calls_socket++;
- 
-+#ifdef SOCK_CLOEXEC
- 	if (fall_back && (type & SOCK_CLOEXEC)) {
- 		errno = EINVAL;
- 		return -1;
- 	}
-+#endif
- 
- 	return real_socket(domain, type, protocol);
- }
- 
- __attribute__ ((visibility("default"))) int
-+#ifdef fcntl
-+/* Work around #define fcntl in epoll-shim */
-+#define old_fcntl fcntl
-+#undef fcntl
-+#endif
- fcntl(int fd, int cmd, ...)
- {
- 	va_list ap;
-@@ -89,10 +98,12 @@ fcntl(int fd, int cmd, ...)
- 
- 	wrapped_calls_fcntl++;
- 
-+#ifdef F_DUPFD_CLOEXEC
- 	if (fall_back && (cmd == F_DUPFD_CLOEXEC)) {
- 		errno = EINVAL;
- 		return -1;
- 	}
-+#endif
- 
- 	va_start(ap, cmd);
- 	arg = va_arg(ap, void*);
-@@ -100,16 +111,21 @@ fcntl(int fd, int cmd, ...)
- 
- 	return real_fcntl(fd, cmd, arg);
- }
-+#ifdef old_fcntl
-+#define fcntl old_fcntl 
-+#endif
- 
- __attribute__ ((visibility("default"))) ssize_t
- recvmsg(int sockfd, struct msghdr *msg, int flags)
- {
- 	wrapped_calls_recvmsg++;
- 
-+#ifdef MSG_CMSG_CLOEXEC
- 	if (fall_back && (flags & MSG_CMSG_CLOEXEC)) {
- 		errno = EINVAL;
- 		return -1;
- 	}
-+#endif
- 
- 	return real_recvmsg(sockfd, msg, flags);
- }
-@@ -156,12 +172,14 @@ TEST(os_wrappers_socket_cloexec)
- 	do_os_wrappers_socket_cloexec(0);
- }
- 
-+#ifdef SOCK_CLOEXEC
- TEST(os_wrappers_socket_cloexec_fallback)
- {
- 	/* forced fallback */
- 	init_fallbacks(1);
- 	do_os_wrappers_socket_cloexec(1);
- }
-+#endif
- 
- static void
- do_os_wrappers_dupfd_cloexec(int n)
-@@ -195,11 +213,13 @@ TEST(os_wrappers_dupfd_cloexec)
- 	do_os_wrappers_dupfd_cloexec(0);
- }
- 
-+#ifdef F_DUPFD_CLOEXEC
- TEST(os_wrappers_dupfd_cloexec_fallback)
- {
- 	init_fallbacks(1);
- 	do_os_wrappers_dupfd_cloexec(3);
- }
-+#endif
- 
- struct marshal_data {
- 	struct wl_connection *read_connection;
-@@ -218,8 +238,7 @@ struct marshal_data {
- static void
- setup_marshal_data(struct marshal_data *data)
- {
--	assert(socketpair(AF_UNIX,
--			  SOCK_STREAM | SOCK_CLOEXEC, 0, data->s) == 0);
-+	assert(wl_os_socketpair_cloexec(AF_UNIX, SOCK_STREAM, 0, data->s) == 0);
- 
- 	data->read_connection = wl_connection_create(data->s[0]);
- 	assert(data->read_connection);
-@@ -328,11 +347,13 @@ TEST(os_wrappers_recvmsg_cloexec)
- 	do_os_wrappers_recvmsg_cloexec(0);
- }
- 
-+#ifdef MSG_CMSG_CLOEXEC
- TEST(os_wrappers_recvmsg_cloexec_fallback)
- {
- 	init_fallbacks(1);
- 	do_os_wrappers_recvmsg_cloexec(1);
- }
-+#endif
- 
- static void
- do_os_wrappers_epoll_create_cloexec(int n)
diff --git a/graphics/wayland/files/patch-tests_queue-test.c b/graphics/wayland/files/patch-tests_queue-test.c
deleted file mode 100644
index e7329bf4fabf..000000000000
--- a/graphics/wayland/files/patch-tests_queue-test.c
+++ /dev/null
@@ -1,21 +0,0 @@
---- tests/queue-test.c.orig	2016-10-22 16:23:10 UTC
-+++ tests/queue-test.c
-@@ -23,6 +23,8 @@
-  * SOFTWARE.
-  */
- 
-+#include "../config.h"
-+
- #include <stdlib.h>
- #include <stdint.h>
- #include <stdio.h>
-@@ -31,6 +33,9 @@
- #include <sys/types.h>
- #include <sys/wait.h>
- #include <assert.h>
-+#ifdef HAVE_SIGNAL_H
-+#include <signal.h>
-+#endif
- 
- #include "wayland-client.h"
- #include "wayland-server.h"
diff --git a/graphics/wayland/files/patch-tests_test-helpers.c b/graphics/wayland/files/patch-tests_test-helpers.c
deleted file mode 100644
index 9dfa1da3e030..000000000000
--- a/graphics/wayland/files/patch-tests_test-helpers.c
+++ /dev/null
@@ -1,48 +0,0 @@
---- tests/test-helpers.c.orig	2020-02-11 23:46:03 UTC
-+++ tests/test-helpers.c
-@@ -25,6 +25,8 @@
- 
- #include "config.h"
- 
-+#include "../config.h"
-+
- #include <assert.h>
- #include <errno.h>
- #include <dirent.h>
-@@ -41,6 +43,16 @@
- 
- #include "test-runner.h"
- 
-+#ifdef __FreeBSD__
-+/* FreeBSD uses fdescfs (which must be mounted using:
-+ *    mount -t fdescfs fdescfs /dev/fd
-+ * before the test suite can be run). */
-+#define OPEN_FDS_DIR "/dev/fd"
-+#else
-+/* Linux. */
-+#define OPEN_FDS_DIR "/proc/self/fd"
-+#endif
-+
- int
- count_open_fds(void)
- {
-@@ -48,8 +60,8 @@ count_open_fds(void)
- 	struct dirent *ent;
- 	int count = 0;
- 
--	dir = opendir("/proc/self/fd");
--	assert(dir && "opening /proc/self/fd failed.");
-+	dir = opendir(OPEN_FDS_DIR);
-+	assert(dir && "opening " OPEN_FDS_DIR " failed.");
- 
- 	errno = 0;
- 	while ((ent = readdir(dir))) {
-@@ -58,7 +70,7 @@ count_open_fds(void)
- 			continue;
- 		count++;
- 	}
--	assert(errno == 0 && "reading /proc/self/fd failed.");
-+	assert(errno == 0 && "reading " OPEN_FDS_DIR " failed.");
- 
- 	closedir(dir);
- 
diff --git a/graphics/wayland/files/patch-tests_test-runner.c b/graphics/wayland/files/patch-tests_test-runner.c
deleted file mode 100644
index 9ba39a6e975b..000000000000
--- a/graphics/wayland/files/patch-tests_test-runner.c
+++ /dev/null
@@ -1,128 +0,0 @@
---- tests/test-runner.c.orig	2020-02-11 23:46:03 UTC
-+++ tests/test-runner.c
-@@ -25,6 +25,8 @@
- 
- #define _GNU_SOURCE
- 
-+#include "../config.h"
-+
- #include <unistd.h>
- #include <stdio.h>
- #include <stdlib.h>
-@@ -37,13 +39,23 @@
- #include <errno.h>
- #include <limits.h>
- #include <sys/ptrace.h>
-+#ifdef HAVE_SYS_PRCTL_H
- #include <sys/prctl.h>
-+#endif
- #ifndef PR_SET_PTRACER
- # define PR_SET_PTRACER 0x59616d61
- #endif
-+#include <signal.h>
- 
- #include "test-runner.h"
- 
-+#ifdef __FreeBSD__
-+/* XXX review ptrace() usage */
-+#define PTRACE_ATTACH PT_ATTACH
-+#define PTRACE_CONT PT_CONTINUE
-+#define PTRACE_DETACH PT_DETACH
-+#endif
-+
- /* when set to 1, check if tests are not leaking opened files.
-  * It is turned on by default. It can be turned off by
-  * WAYLAND_TEST_NO_LEAK_CHECK environment variable. */
-@@ -51,7 +63,7 @@ int fd_leak_check_enabled;
- 
- /* when this var is set to 0, every call to test_set_timeout() is
-  * suppressed - handy when debugging the test. Can be set by
-- * WAYLAND_TEST_NO_TIMEOUTS environment variable. */
-+ * WAYLAND_TESTS_NO_TIMEOUTS evnironment var */
- static int timeouts_enabled = 1;
- 
- /* set to one if the output goes to the terminal */
-@@ -239,6 +251,8 @@ is_debugger_attached(void)
- 		return 0;
*** 200 LINES SKIPPED ***