pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

wayland: update to 1.14.0



Module Name:	pkgsrc-wip
Committed By:	Mark Davies <mark%ecs.vuw.ac.nz@localhost>
Pushed By:	markd
Date:		Mon Jan 22 15:33:56 2018 +1300
Changeset:	7c634875a0cf3a701cb62b68174c90f6e2e7f3e1

Modified Files:
	wayland/Makefile
	wayland/distinfo
	wayland/patches/patch-src_wayland-server.c
	wayland/patches/patch-tests_test-runner.c
Added Files:
	wayland/patches/patch-Makefile.am
	wayland/patches/patch-configure.ac
	wayland/patches/patch-src_event-loop.c
	wayland/patches/patch-src_wayland-os.c
	wayland/patches/patch-src_wayland-os.h
	wayland/patches/patch-src_wayland-shm.c
	wayland/patches/patch-tests_client-test.c
	wayland/patches/patch-tests_connection-test.c
	wayland/patches/patch-tests_event-loop-test.c
	wayland/patches/patch-tests_os-wrappers-test.c
	wayland/patches/patch-tests_queue-test.c
	wayland/patches/patch-tests_sanity-test.c
	wayland/patches/patch-tests_test-helpers.c
Removed Files:
	wayland/patches/patch-tests_test-compositor.c

Log Message:
wayland: update to 1.14.0

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=7c634875a0cf3a701cb62b68174c90f6e2e7f3e1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 wayland/Makefile                               |  12 +-
 wayland/distinfo                               |  26 +++-
 wayland/patches/patch-Makefile.am              |  51 +++++++
 wayland/patches/patch-configure.ac             |  56 ++++++++
 wayland/patches/patch-src_event-loop.c         |  15 +++
 wayland/patches/patch-src_wayland-os.c         | 101 ++++++++++++++
 wayland/patches/patch-src_wayland-os.h         |  16 +++
 wayland/patches/patch-src_wayland-server.c     |  92 +++++++++++--
 wayland/patches/patch-src_wayland-shm.c        | 151 +++++++++++++++++++++
 wayland/patches/patch-tests_client-test.c      |  23 ++++
 wayland/patches/patch-tests_connection-test.c  |  33 +++++
 wayland/patches/patch-tests_event-loop-test.c  |  43 ++++++
 wayland/patches/patch-tests_os-wrappers-test.c | 107 +++++++++++++++
 wayland/patches/patch-tests_queue-test.c       |  25 ++++
 wayland/patches/patch-tests_sanity-test.c      |  26 ++++
 wayland/patches/patch-tests_test-compositor.c  |  15 ---
 wayland/patches/patch-tests_test-helpers.c     |  56 ++++++++
 wayland/patches/patch-tests_test-runner.c      | 177 ++++++++++++++++++++++---
 18 files changed, 972 insertions(+), 53 deletions(-)

diffs:
diff --git a/wayland/Makefile b/wayland/Makefile
index 8181af02d9..9cea171261 100644
--- a/wayland/Makefile
+++ b/wayland/Makefile
@@ -1,9 +1,9 @@
 # $NetBSD$
 #
 
-DISTNAME=	wayland-1.9.90
+DISTNAME=	wayland-1.14.0
 CATEGORIES=	graphics
-MASTER_SITES=	http://rainbow-runner.nl/freebsd/
+MASTER_SITES=	http://wayland.freedesktop.org/releases/
 EXTRACT_SUFX=	.tar.xz
 
 MAINTAINER=	pkgsrc-users%NetBSD.org@localhost
@@ -11,7 +11,7 @@ HOMEPAGE=	http://wayland.freedesktop.org
 COMMENT=	Computer display server protocol
 LICENSE=	mit
 
-USE_TOOLS+=	gmake pkg-config
+USE_TOOLS+=	autoconf automake autoreconf gmake pkg-config
 USE_LANGUAGES+=	c c++
 GNU_CONFIGURE=	YES
 USE_LIBTOOL=	YES
@@ -22,6 +22,12 @@ PKGCONFIG_OVERRIDE+=	src/wayland-cursor.pc.in
 PKGCONFIG_OVERRIDE+=	src/wayland-scanner.pc.in
 PKGCONFIG_OVERRIDE+=	src/wayland-server.pc.in
 
+CFLAGS+=	-I${BUILDLINK_PREFIX.libepoll-shim}/include/libepoll-shim
+
+pre-configure:
+	cd ${WRKSRC} && autoreconf -fvi
+
+.include "../../wip/libepoll-shim/buildlink3.mk"
 .include "../../devel/libffi/buildlink3.mk"
 .include "../../textproc/expat/buildlink3.mk"
 .include "../../textproc/libxslt/buildlink3.mk"
diff --git a/wayland/distinfo b/wayland/distinfo
index 586d1fea6f..0dddb9d1da 100644
--- a/wayland/distinfo
+++ b/wayland/distinfo
@@ -1,9 +1,21 @@
 $NetBSD$
 
-SHA1 (wayland-1.9.90.tar.xz) = ffed32a005fa91c1eba4e1eaf4de3506f1615950
-RMD160 (wayland-1.9.90.tar.xz) = 38d1cedf203971888e53c3fbce26678d28093356
-SHA512 (wayland-1.9.90.tar.xz) = 3fd70d6d2365086938ddcb0b4cb477f8f35386511938e014e770bdf43449322b3768f940d78d94a19090338f0103ba432c9f0f810a9306cca5e53b8de5df0501
-Size (wayland-1.9.90.tar.xz) = 377944 bytes
-SHA1 (patch-src_wayland-server.c) = 5684c0691dc30f2b8cc9796dc803b5cb98a68a9d
-SHA1 (patch-tests_test-compositor.c) = d92b90063fa2efd0f3d01ca254bb1ca2e789cbaf
-SHA1 (patch-tests_test-runner.c) = 6f1c5f7a1810e89d3e2682c82573e8a6f1e4d804
+SHA1 (wayland-1.14.0.tar.xz) = 53a443be3bafe73209bbc49ef2cb134ed16e0141
+RMD160 (wayland-1.14.0.tar.xz) = b6e3f0bccde63eef905700d98c364b433e859762
+SHA512 (wayland-1.14.0.tar.xz) = bd38b2b8963d4d98d42c270e5d7dbff6323789a173b19b67a18258424fd8adee5021b282c9d7f6dad0bd25aa0160e76aecd8ed803d4eb25d911ef0a81cd713a5
+Size (wayland-1.14.0.tar.xz) = 413960 bytes
+SHA1 (patch-Makefile.am) = 086e3ab80dbaae733ea7c4084aae210026585c99
+SHA1 (patch-configure.ac) = e14c4ee81c2589a2b2ddd2f95aa7ae5bcf5d055e
+SHA1 (patch-src_event-loop.c) = 99bd6717302044430732cff21ede40e0849f026e
+SHA1 (patch-src_wayland-os.c) = 8d88cc2712b9ce8a4df8b05b6a2182d964c77ef1
+SHA1 (patch-src_wayland-os.h) = 0a8d2c7c4cbc68bedf78a924b9919158de540721
+SHA1 (patch-src_wayland-server.c) = 00c35945e8b3609f7e4e1fefd376d5d5546b8d5b
+SHA1 (patch-src_wayland-shm.c) = 6a6f49d531dcb8c9b4c7abdc139536e934c54fcb
+SHA1 (patch-tests_client-test.c) = 6ffe18dfd64176a92f6f795eb757c54a3cf0ad10
+SHA1 (patch-tests_connection-test.c) = af53116c99cbb8d6570bcec66bfd895c1ae01700
+SHA1 (patch-tests_event-loop-test.c) = 066be5163808b0a2727de514d3a7eb4493238dc5
+SHA1 (patch-tests_os-wrappers-test.c) = df3605d6dfd2f8da3b62ea73b0255f6ce6b4a66a
+SHA1 (patch-tests_queue-test.c) = 3ee8433faa50b033ab880d3c5b6a9846063d6bd6
+SHA1 (patch-tests_sanity-test.c) = 0457b89e90b31955b9c9c9f3f848c53d5c4e1f9f
+SHA1 (patch-tests_test-helpers.c) = e16e9aeac44a80e27dffd223e6c15c376d917a68
+SHA1 (patch-tests_test-runner.c) = a15a71fa10b8e8e55fbc307854e36842fab5e28b
diff --git a/wayland/patches/patch-Makefile.am b/wayland/patches/patch-Makefile.am
new file mode 100644
index 0000000000..60ef6596f3
--- /dev/null
+++ b/wayland/patches/patch-Makefile.am
@@ -0,0 +1,51 @@
+$NetBSD$
+
+BSD support from FreeBSD
+
+--- Makefile.am.orig	2017-05-05 11:54:01 UTC
++++ Makefile.am
+@@ -73,7 +73,7 @@ nodist_include_HEADERS =			\
+ 	protocol/wayland-client-protocol.h
+ 
+ libwayland_server_la_CFLAGS = $(FFI_CFLAGS) $(AM_CFLAGS) -pthread
+-libwayland_server_la_LIBADD = $(FFI_LIBS) libwayland-private.la libwayland-util.la -lrt -lm
++libwayland_server_la_LIBADD = $(FFI_LIBS) $(EPOLLSHIM_LIBS) libwayland-private.la libwayland-util.la -lrt -lm
+ libwayland_server_la_LDFLAGS = -version-info 1:0:1
+ libwayland_server_la_SOURCES =			\
+ 	src/wayland-server.c			\
+@@ -85,7 +85,7 @@ nodist_libwayland_server_la_SOURCES =		\
+ 	protocol/wayland-protocol.c
+ 
+ libwayland_client_la_CFLAGS = $(FFI_CFLAGS) $(AM_CFLAGS) -pthread
+-libwayland_client_la_LIBADD = $(FFI_LIBS) libwayland-private.la libwayland-util.la -lrt -lm
++libwayland_client_la_LIBADD = $(FFI_LIBS) $(EPOLLSHIM_LIBS) libwayland-private.la libwayland-util.la -lrt -lm
+ libwayland_client_la_LDFLAGS = -version-info 3:0:3
+ libwayland_client_la_SOURCES =			\
+ 	src/wayland-client.c
+@@ -180,12 +180,12 @@ AM_TESTS_ENVIRONMENT =							\
+ TESTS = $(built_test_programs)			\
+ 	tests/scanner-test.sh
+ 
+-noinst_PROGRAMS =				\
+-	$(built_test_programs)			\
+-	exec-fd-leak-checker			\
+-	fixed-benchmark
++#noinst_PROGRAMS =				\
++#	$(built_test_programs)			\
++#	exec-fd-leak-checker			\
++#	fixed-benchmark
+ 
+-noinst_LTLIBRARIES += libtest-runner.la
++#noinst_LTLIBRARIES += libtest-runner.la
+ 
+ libtest_runner_la_SOURCES =			\
+ 	tests/test-runner.c			\
+@@ -198,7 +198,7 @@ libtest_runner_la_LIBADD =			\
+ 	libwayland-util.la			\
+ 	libwayland-client.la			\
+ 	libwayland-server.la			\
+-	-lrt -ldl $(FFI_LIBS)
++	-lrt $(DL_LIBS) $(FFI_LIBS) $(EPOLLSHIM_LIBS)
+ 
+ 
+ array_test_SOURCES = tests/array-test.c
diff --git a/wayland/patches/patch-configure.ac b/wayland/patches/patch-configure.ac
new file mode 100644
index 0000000000..c90fcca273
--- /dev/null
+++ b/wayland/patches/patch-configure.ac
@@ -0,0 +1,56 @@
+$NetBSD$
+
+BSD support from FreeBSD
+
+--- configure.ac.orig	2017-08-08 18:20:52 UTC
++++ configure.ac
+@@ -63,6 +63,25 @@ AC_SUBST(GCC_CFLAGS)
+ 
+ AC_CHECK_FUNCS([accept4 mkostemp posix_fallocate])
+ 
++AC_CHECK_HEADERS([sys/signalfd.h sys/timerfd.h])
++
++# Use epoll on Linux and epoll-shim (kqueue) on BSD
++AC_CHECK_HEADERS([sys/epoll.h])
++
++# Credential support on FreeBSD
++AC_CHECK_HEADERS([sys/ucred.h])
++
++# dlopen()
++AC_CHECK_LIB([dl], [dlsym], [DL_LIBS=-ldl])
++AC_SUBST([DL_LIBS])
++
++# Defines __FreeBSD__ if we're on FreeBSD
++AC_CHECK_HEADERS([sys/param.h])
++
++# waitid() and signal.h are needed for the test suite.
++AC_CHECK_FUNCS([waitid])
++AC_CHECK_HEADERS([signal.h])
++
+ AC_ARG_ENABLE([libraries],
+ 	      [AC_HELP_STRING([--disable-libraries],
+ 			      [Disable compilation of wayland libraries])],
+@@ -98,17 +117,21 @@ AC_SUBST([ICONDIR])
+ 
+ if test "x$enable_libraries" = "xyes"; then
+ 	PKG_CHECK_MODULES(FFI, [libffi])
++dnl convert SFD_CLOEXEC and TFD_CLOEXEC to warning while figuring out how to do this.
+ 	AC_CHECK_DECL(SFD_CLOEXEC,[],
+-		      [AC_MSG_ERROR("SFD_CLOEXEC is needed to compile wayland libraries")],
++		      [AC_MSG_WARN("SFD_CLOEXEC is needed to compile wayland libraries")],
+ 		      [[#include <sys/signalfd.h>]])
+ 	AC_CHECK_DECL(TFD_CLOEXEC,[],
+-		      [AC_MSG_ERROR("TFD_CLOEXEC is needed to compile wayland libraries")],
++		      [AC_MSG_WARN("TFD_CLOEXEC is needed to compile wayland libraries")],
+ 		      [[#include <sys/timerfd.h>]])
+ 	AC_CHECK_DECL(CLOCK_MONOTONIC,[],
+ 		      [AC_MSG_ERROR("CLOCK_MONOTONIC is needed to compile wayland libraries")],
+ 		      [[#include <time.h>]])
+ 	AC_CHECK_HEADERS([execinfo.h])
+ fi
++
++EPOLLSHIM_LIBS="-lepoll-shim"
++AC_SUBST(EPOLLSHIM_LIBS)
+ 
+ PKG_CHECK_MODULES(EXPAT, [expat], [],
+ 	[AC_CHECK_HEADERS(expat.h, [],
diff --git a/wayland/patches/patch-src_event-loop.c b/wayland/patches/patch-src_event-loop.c
new file mode 100644
index 0000000000..518306ed00
--- /dev/null
+++ b/wayland/patches/patch-src_event-loop.c
@@ -0,0 +1,15 @@
+$NetBSD$
+
+--- event-loop.c.orig	2017-08-08 18:20:52.000000000 +0000
++++ src/event-loop.c
+@@ -34,9 +34,9 @@
+ #include <sys/socket.h>
+ #include <sys/un.h>
+ #include <sys/epoll.h>
++#include <unistd.h>
+ #include <sys/signalfd.h>
+ #include <sys/timerfd.h>
+-#include <unistd.h>
+ #include "wayland-util.h"
+ #include "wayland-private.h"
+ #include "wayland-server-core.h"
diff --git a/wayland/patches/patch-src_wayland-os.c b/wayland/patches/patch-src_wayland-os.c
new file mode 100644
index 0000000000..eccea49077
--- /dev/null
+++ b/wayland/patches/patch-src_wayland-os.c
@@ -0,0 +1,101 @@
+$NetBSD$
+
+BSD support from FreeBSD
+
+--- 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/wayland/patches/patch-src_wayland-os.h b/wayland/patches/patch-src_wayland-os.h
new file mode 100644
index 0000000000..20da3d741d
--- /dev/null
+++ b/wayland/patches/patch-src_wayland-os.h
@@ -0,0 +1,16 @@
+$NetBSD$
+
+BSD support from FreeBSD
+
+--- 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/wayland/patches/patch-src_wayland-server.c b/wayland/patches/patch-src_wayland-server.c
index 76defaa580..84d31d8ef7 100644
--- a/wayland/patches/patch-src_wayland-server.c
+++ b/wayland/patches/patch-src_wayland-server.c
@@ -1,14 +1,90 @@
 $NetBSD$
 
---- src/wayland-server.c.orig	2015-11-25 09:48:11.000000000 +0000
+BSD support from FreeBSD
+
+--- src/wayland-server.c.orig	2017-08-08 18:20:52 UTC
 +++ src/wayland-server.c
-@@ -88,6 +88,9 @@ struct wl_client {
+@@ -25,6 +25,8 @@
+ 
+ #define _GNU_SOURCE
+ 
++#include "../config.h"
++
+ #include <stdlib.h>
+ #include <stdint.h>
+ #include <stddef.h>
+@@ -43,6 +45,11 @@
+ #include <sys/file.h>
+ #include <sys/stat.h>
+ 
++#ifdef HAVE_SYS_UCRED_H
++#include <sys/types.h>
++#include <sys/ucred.h>
++#endif
++
+ #include "wayland-util.h"
+ #include "wayland-private.h"
+ #include "wayland-server.h"
+@@ -77,7 +84,17 @@ struct wl_client {
+ 	struct wl_list link;
  	struct wl_map objects;
- 	struct wl_signal destroy_signal;
- #ifdef HAVE_SYS_UCRED_H
+ 	struct wl_priv_signal destroy_signal;
++#ifdef HAVE_SYS_UCRED_H
 +#ifdef __NetBSD__
-+# define xucred uucred
++	struct uucred xucred;
++#else
++	/* FreeBSD */
++	struct xucred xucred;
++#endif
++#else
++	/* Linux */
+ 	struct ucred ucred;
++#endif
+ 	int error;
+ 	struct wl_priv_signal resource_created_signal;
+ };
+@@ -501,10 +518,20 @@ wl_client_create(struct wl_display *disp
+ 	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_SOCKET, 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)
+@@ -558,12 +585,23 @@ 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
++	/* FreeBSD */
++	if (pid)
++		*pid = 0; /* FIXME: not defined on FreeBSD */
++	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
- 	/* FreeBSD */
- 	struct xucred xucred;
- #else
+ }
+ 
+ /** Get the file descriptor for the client
diff --git a/wayland/patches/patch-src_wayland-shm.c b/wayland/patches/patch-src_wayland-shm.c
new file mode 100644
index 0000000000..bd9353ddd3
--- /dev/null
+++ b/wayland/patches/patch-src_wayland-shm.c
@@ -0,0 +1,151 @@
+$NetBSD$
+
+BSD support from FreeBSD
+
+--- src/wayland-shm.c.orig	2017-08-08 18:20:52 UTC
++++ src/wayland-shm.c
+@@ -30,6 +30,8 @@
+ 
+ #define _GNU_SOURCE
+ 
++#include "../config.h"
++
+ #include <stdbool.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+@@ -59,6 +61,9 @@ struct wl_shm_pool {
+ 	char *data;
+ 	int32_t size;
+ 	int32_t new_size;
++#ifdef HAVE_SYS_UCRED_H
++	int fd;
++#endif
+ };
+ 
+ struct wl_shm_buffer {
+@@ -76,15 +81,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,
+@@ -110,6 +124,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);
+ }
+@@ -223,6 +241,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)
+@@ -284,7 +369,14 @@ shm_create_pool(struct wl_client *client, struct wl_re
+ 				       "failed mmap fd %d", fd);
+ 		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/wayland/patches/patch-tests_client-test.c b/wayland/patches/patch-tests_client-test.c
new file mode 100644
index 0000000000..c78c422aa4
--- /dev/null
+++ b/wayland/patches/patch-tests_client-test.c
@@ -0,0 +1,23 @@
+$NetBSD$
+
+BSD support from FreeBSD
+
+--- 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/wayland/patches/patch-tests_connection-test.c b/wayland/patches/patch-tests_connection-test.c
new file mode 100644
index 0000000000..d690ac9c06
--- /dev/null
+++ b/wayland/patches/patch-tests_connection-test.c
@@ -0,0 +1,33 @@
+$NetBSD$
+
+BSD support from FreeBSD
+
+--- 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/wayland/patches/patch-tests_event-loop-test.c b/wayland/patches/patch-tests_event-loop-test.c
new file mode 100644
index 0000000000..262df0b85f
--- /dev/null
+++ b/wayland/patches/patch-tests_event-loop-test.c
@@ -0,0 +1,43 @@
+$NetBSD$
+
+BSD support from FreeBSD
+
+--- tests/event-loop-test.c.orig	2017-08-08 18:20:52 UTC
++++ tests/event-loop-test.c
+@@ -167,10 +167,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);
+@@ -234,11 +234,19 @@ TEST(event_loop_timer)
+ 
+ 	source = wl_event_loop_add_timer(loop, timer_callback, &got_it);
+ 	assert(source);
+-	wl_event_source_timer_update(source, 10);
+-	wl_event_loop_dispatch(loop, 0);
++	assert(wl_event_source_timer_update(source, 10) == 0);
++	assert(wl_event_loop_dispatch(loop, 0) == 0);
+ 	assert(!got_it);
+-	wl_event_loop_dispatch(loop, 20);
++	/* FreeBSD has a bug where it converts ms_timeout to ticks; it always adds 1 to the tick count.
++	* Consequently, we need to grossly overcompensate here.
++	* See: http://unix.derkeiler.com/Mailing-Lists/FreeBSD/hackers/2012-07/msg00319.html */
++	assert(wl_event_loop_dispatch(loop, 50) == 0);
+ 	assert(got_it == 1);
++
++	/* Check it doesn't fire again. */
++	got_it = 0;
++	assert(wl_event_loop_dispatch(loop, 20) == 0);
++	assert(!got_it);
+ 
+ 	wl_event_source_remove(source);
+ 	wl_event_loop_destroy(loop);
diff --git a/wayland/patches/patch-tests_os-wrappers-test.c b/wayland/patches/patch-tests_os-wrappers-test.c
new file mode 100644
index 0000000000..af6080e042
--- /dev/null
+++ b/wayland/patches/patch-tests_os-wrappers-test.c
@@ -0,0 +1,107 @@
+$NetBSD$
+
+BSD support from FreeBSD
+
+--- 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,10 +75,12 @@ 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);
+ }
+@@ -89,10 +93,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*);
+@@ -106,10 +112,12 @@ 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 +164,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 +205,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 +230,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 +339,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/wayland/patches/patch-tests_queue-test.c b/wayland/patches/patch-tests_queue-test.c
new file mode 100644
index 0000000000..59a6c155a8
--- /dev/null
+++ b/wayland/patches/patch-tests_queue-test.c
@@ -0,0 +1,25 @@
+$NetBSD$
+
+BSD support from FreeBSD
+
+--- 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/wayland/patches/patch-tests_sanity-test.c b/wayland/patches/patch-tests_sanity-test.c
new file mode 100644
index 0000000000..9769f85c91
--- /dev/null
+++ b/wayland/patches/patch-tests_sanity-test.c
@@ -0,0 +1,26 @@
+$NetBSD$
+
+BSD support from FreeBSD
+
+--- tests/sanity-test.c.orig	2016-02-17 01:13:16 UTC
++++ tests/sanity-test.c
+@@ -92,7 +92,8 @@ FAIL_TEST(sanity_malloc_direct)
+ TEST(disable_leak_checks)
+ {
+ 	volatile void *mem;
+-	assert(leak_check_enabled);
++// XXX FreeBSD disables leak checks...
++//	assert(leak_check_enabled);
+ 	/* normally this should be on the beginning of the test.
+ 	 * Here we need to be sure, that the leak checks are
+ 	 * turned on */
+@@ -171,7 +172,8 @@ sanity_fd_no_leak(void)
+ {
+ 	int fd[2];
+ 
+-	assert(leak_check_enabled);
++// XXX FreeBSD leak checks are disabled
++//	assert(leak_check_enabled);
+ 
+ 	/* leak 2 file descriptors */
+ 	if (pipe(fd) < 0)
diff --git a/wayland/patches/patch-tests_test-compositor.c b/wayland/patches/patch-tests_test-compositor.c
deleted file mode 100644
index 1cabb88287..0000000000
--- a/wayland/patches/patch-tests_test-compositor.c
+++ /dev/null
@@ -1,15 +0,0 @@
-$NetBSD$
-
---- tests/test-compositor.c.orig	2015-11-25 09:48:11.000000000 +0000
-+++ tests/test-compositor.c
-@@ -104,7 +104,10 @@ client_destroyed(struct wl_listener *lis
- 	ci = wl_container_of(listener, ci, destroy_listener);
- 	d = ci->display;
- 
-+#ifndef __NetBSD__
- 	assert(waitid(P_PID, ci->pid, &status, WEXITED) != -1);
-+#else
-+#endif
- 
- 	switch (status.si_code) {
- 	case CLD_KILLED:
diff --git a/wayland/patches/patch-tests_test-helpers.c b/wayland/patches/patch-tests_test-helpers.c
new file mode 100644
index 0000000000..9acddfe798
--- /dev/null
+++ b/wayland/patches/patch-tests_test-helpers.c
@@ -0,0 +1,56 @@
+$NetBSD$
+
+BSD support from FreeBSD
+
+--- tests/test-helpers.c.orig	2015-07-06 19:38:51 UTC
++++ tests/test-helpers.c
+@@ -23,6 +23,12 @@
+  * SOFTWARE.
+  */
+ 
++#include "../config.h"
++
++#ifdef HAVE_SYS_PARAM_H
++#include <sys/param.h>
++#endif
++
+ #include <assert.h>
+ #include <errno.h>
+ #include <dirent.h>
+@@ -32,6 +38,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)
+ {
+@@ -39,8 +55,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))) {
+@@ -49,7 +65,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/wayland/patches/patch-tests_test-runner.c b/wayland/patches/patch-tests_test-runner.c
index 81cd300246..1fd58a4c80 100644
--- a/wayland/patches/patch-tests_test-runner.c
+++ b/wayland/patches/patch-tests_test-runner.c
@@ -1,39 +1,176 @@
 $NetBSD$
 
---- tests/test-runner.c.orig	2015-11-25 10:00:50.000000000 +0000
+BSD support from FreeBSD
+
+--- tests/test-runner.c.orig	2017-08-08 18:20:52 UTC
 +++ tests/test-runner.c
-@@ -59,14 +59,14 @@ extern const struct test __start_test_se
+@@ -25,6 +25,12 @@
+ 
+ #define _GNU_SOURCE
+ 
++#include "../config.h"
++
++#ifdef HAVE_SYS_PARAM_H
++#include <sys/param.h>
++#endif
++
+ #include <unistd.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+@@ -37,19 +43,36 @@
+ #include <errno.h>
+ #include <limits.h>
+ #include <sys/ptrace.h>
++#ifdef __linux__
+ #include <sys/prctl.h>
++#endif
+ #ifndef PR_SET_PTRACER
+ # define PR_SET_PTRACER 0x59616d61
+ #endif
++#include <signal.h>
+ 
+ #include "test-runner.h"
  
- /* This is all disabled for FreeBSD because it gives "can't allocate initial
-  * thread" aborts otherwise. */
--#ifndef __FreeBSD__
-+#if !defined(__FreeBSD__) && !defined(__NetBSD__)
+ static int num_alloc;
++
++extern const struct test __start_test_section, __stop_test_section;
++
++/* This is all disabled for FreeBSD because it gives "can't allocate initial
++ * thread" aborts otherwise. */
++#ifndef __FreeBSD__
  static void* (*sys_malloc)(size_t);
  static void (*sys_free)(void*);
  static void* (*sys_realloc)(void*, size_t);
  static void* (*sys_calloc)(size_t, size_t);
- #endif
++#endif
+ 
++#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 memory and opened files.
+  * It is turned on by default. It can be turned off by
+  * WAYLAND_TEST_NO_LEAK_CHECK environment variable. */
+@@ -57,7 +80,7 @@ int leak_check_enabled;
  
--#ifdef __FreeBSD__
-+#if defined(__FreeBSD__) || defined(__NetBSD__)
- /* XXX review ptrace() usage */
- #define PTRACE_ATTACH PT_ATTACH
- #define PTRACE_CONT PT_CONTINUE
-@@ -88,7 +88,7 @@ static int is_atty = 0;
+ /* 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 */
+@@ -65,6 +88,7 @@ static int is_atty = 0;
  
  extern const struct test __start_test_section, __stop_test_section;
  
--#ifndef __FreeBSD__
-+#if !defined(__FreeBSD__) && !defined(__NetBSD__)
++#ifndef __FreeBSD__
  __attribute__ ((visibility("default"))) void *
  malloc(size_t size)
  {
-@@ -378,7 +378,7 @@ int main(int argc, char *argv[])
- 	int status;
- #endif
+@@ -98,6 +122,7 @@ calloc(size_t nmemb, size_t size)
  
--#ifndef __FreeBSD__
-+#if !defined(__FreeBSD__) && !defined(__NetBSD__)
+ 	return sys_calloc(nmemb, size);
+ }
++#endif
+ 
+ static const struct test *
+ find_test(const char *name)
+@@ -292,6 +317,8 @@ is_debugger_attached(void)
+ 		return 0;
+ 	}
+ 
++
++// xxx start here
+ 	pid = fork();
+ 	if (pid == -1) {
+ 		perror("fork");
+@@ -312,7 +339,7 @@ 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 {
+@@ -346,17 +373,19 @@ 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
+ 
++#ifndef __FreeBSD__
  	/* Load system malloc, free, and realloc */
  	sys_calloc = dlsym(RTLD_NEXT, "calloc");
  	sys_realloc = dlsym(RTLD_NEXT, "realloc");
+ 	sys_malloc = dlsym(RTLD_NEXT, "malloc");
+ 	sys_free = dlsym(RTLD_NEXT, "free");
+ 
+-	if (isatty(fileno(stderr)))
+-		is_atty = 1;
+-
+ 	if (is_debugger_attached()) {
+ 		leak_check_enabled = 0;
+ 		timeouts_enabled = 0;
+@@ -364,7 +393,17 @@ int main(int argc, char *argv[])
+ 		leak_check_enabled = !getenv("WAYLAND_TEST_NO_LEAK_CHECK");
+ 		timeouts_enabled = !getenv("WAYLAND_TEST_NO_TIMEOUTS");
+ 	}
++#else
++	/* Disable leak checking on FreeBSD since we can't override malloc().  */
++	leak_check_enabled = 0;
++	/* XXX review later */
++	timeouts_enabled = 0;
++#endif
+ 
++	if (isatty(fileno(stderr)))
++		is_atty = 1;
++
++
+ 	if (argc == 2 && strcmp(argv[1], "--help") == 0)
+ 		usage(argv[0], EXIT_SUCCESS);
+ 
+@@ -395,7 +434,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: %m\n");
+ 			stderr_reset_color();
+@@ -426,6 +466,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++;


Home | Main Index | Thread Index | Old Index