aboutsummaryrefslogtreecommitdiff
path: root/graphics/wayland/files
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/wayland/files')
-rw-r--r--graphics/wayland/files/patch-cursor_os-compatibility.c23
-rw-r--r--graphics/wayland/files/patch-meson.build33
-rw-r--r--graphics/wayland/files/patch-src_meson.build36
-rw-r--r--graphics/wayland/files/patch-src_wayland-os.c97
-rw-r--r--graphics/wayland/files/patch-src_wayland-os.h12
-rw-r--r--graphics/wayland/files/patch-src_wayland-server.c109
-rw-r--r--graphics/wayland/files/patch-src_wayland-shm.c147
-rw-r--r--graphics/wayland/files/patch-tests_client-test.c19
-rw-r--r--graphics/wayland/files/patch-tests_connection-test.c29
-rw-r--r--graphics/wayland/files/patch-tests_event-loop-test.c44
-rw-r--r--graphics/wayland/files/patch-tests_os-wrappers-test.c122
-rw-r--r--graphics/wayland/files/patch-tests_queue-test.c21
-rw-r--r--graphics/wayland/files/patch-tests_test-helpers.c48
-rw-r--r--graphics/wayland/files/patch-tests_test-runner.c128
14 files changed, 0 insertions, 868 deletions
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;
- }
-
-+
-+// xxx start here
- pid = fork();
- if (pid == -1) {
- perror("fork");
-@@ -259,13 +273,14 @@ is_debugger_attached(void)
- _exit(1);
- if (!waitpid(-1, NULL, 0))
- _exit(1);
-- ptrace(PTRACE_CONT, NULL, NULL);
-+ ptrace(PTRACE_CONT, ppid, NULL, NULL);
- ptrace(PTRACE_DETACH, ppid, NULL, NULL);
- _exit(0);
- } else {
- close(pipefd[0]);
-
- /* Enable child to ptrace the parent process */
-+#if defined(HAVE_PRCTL)
- rc = prctl(PR_SET_PTRACER, pid);
- if (rc != 0 && errno != EINVAL) {
- /* An error prevents us from telling if a debugger is attached.
-@@ -275,7 +290,9 @@ is_debugger_attached(void)
- */
- perror("prctl");
- write(pipefd[1], "-", 1);
-- } else {
-+ } else
-+#endif
-+ {
- /* Signal to client that parent is ready by passing '+' */
- write(pipefd[1], "+", 1);
- }
-@@ -293,7 +310,11 @@ int main(int argc, char *argv[])
- const struct test *t;
- pid_t pid;
- int total, pass;
-+#ifdef HAVE_WAITID
- siginfo_t info;
-+#else
-+ int status;
-+#endif
-
- if (isatty(fileno(stderr)))
- is_atty = 1;
-@@ -336,7 +357,8 @@ int main(int argc, char *argv[])
- if (pid == 0)
- run_test(t); /* never returns */
-
-- if (waitid(P_PID, pid, &info, WEXITED)) {
-+#ifdef HAVE_WAITID
-+ if (waitid(P_PID, 0, &info, WEXITED)) {
- stderr_set_color(RED);
- fprintf(stderr, "waitid failed: %s\n",
- strerror(errno));
-@@ -368,6 +390,25 @@ int main(int argc, char *argv[])
-
- break;
- }
-+#else
-+ if (waitpid(-1, &status, 0) == -1) {
-+ fprintf(stderr, "waitpid failed: %s\n",
-+ strerror(errno));
-+ abort();
-+ }
-+
-+ fprintf(stderr, "test \"%s\":\t", t->name);
-+ if (WIFEXITED(status)) {
-+ fprintf(stderr, "exit status %d", WEXITSTATUS(status));
-+ if (WEXITSTATUS(status) == EXIT_SUCCESS)
-+ success = 1;
-+ } else if (WIFSIGNALED(status)) {
-+ fprintf(stderr, "signal %d", WTERMSIG(status));
-+ }
-+#endif
-+
-+ if (t->must_fail)
-+ success = !success;
-
- if (success) {
- pass++;