mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
Re-enable os-wrappers-test.c on Darwin, fix errors
Signed-off-by: Torrekie Gen <me@torrekie.dev>
This commit is contained in:
parent
f430ba5bd5
commit
f9c13de55d
4 changed files with 43 additions and 9 deletions
|
|
@ -20,7 +20,7 @@ if [ "$(uname)" == "Darwin" ]; then
|
|||
else
|
||||
NM_DYNSYM_TABLE="-D"
|
||||
SYMBOL_PREFIX=""
|
||||
endif
|
||||
fi
|
||||
|
||||
AVAIL_FUNCS="$($NM ${NM_DYNSYM_TABLE} --format=bsd --defined-only $LIB | awk '{print $3}')"
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,14 @@
|
|||
#include "wayland-server-private.h"
|
||||
#include "wayland-os.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
/* epoll-shim should provide this by design */
|
||||
struct itimerspec {
|
||||
struct timespec it_interval;
|
||||
struct timespec it_value;
|
||||
};
|
||||
#endif
|
||||
|
||||
/** \cond INTERNAL */
|
||||
|
||||
#define TIMER_REMOVED -2
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@
|
|||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
/* This test should be skipped on Darwin (as of 2024) */
|
||||
#ifndef __APPLE__
|
||||
#include "../config.h"
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
|
@ -62,12 +60,12 @@ static int
|
|||
socket_wrapper(int domain, int type, int protocol)
|
||||
{
|
||||
wrapped_calls_socket++;
|
||||
|
||||
#ifdef SOCK_CLOEXEC
|
||||
if (fall_back && (type & SOCK_CLOEXEC)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
return socket(domain, type, protocol);
|
||||
}
|
||||
|
||||
|
|
@ -111,11 +109,12 @@ static ssize_t
|
|||
recvmsg_wrapper(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 recvmsg(sockfd, msg, flags);
|
||||
}
|
||||
|
|
@ -160,8 +159,11 @@ do_os_wrappers_socket_cloexec(int n)
|
|||
* Must have 2 calls if falling back, but must also allow
|
||||
* falling back without a forced fallback.
|
||||
*/
|
||||
#ifdef SOCK_CLOEXEC
|
||||
assert(wrapped_calls_socket > n);
|
||||
|
||||
#else
|
||||
assert(wrapped_calls_socket == 1);
|
||||
#endif
|
||||
exec_fd_leak_check(nr_fds);
|
||||
}
|
||||
|
||||
|
|
@ -234,8 +236,14 @@ struct marshal_data {
|
|||
static void
|
||||
setup_marshal_data(struct marshal_data *data)
|
||||
{
|
||||
#ifdef SOCK_CLOEXEC
|
||||
assert(socketpair(AF_UNIX,
|
||||
SOCK_STREAM | SOCK_CLOEXEC, 0, data->s) == 0);
|
||||
#else
|
||||
assert(socketpair(AF_UNIX, SOCK_STREAM, 0, data->s) == 0);
|
||||
assert(set_cloexec_or_close(data->s[0]) != -1);
|
||||
assert(set_cloexec_or_close(data->s[1]) != -1);
|
||||
#endif
|
||||
|
||||
data->read_connection = wl_connection_create(data->s[0],
|
||||
WL_BUFFER_DEFAULT_MAX_SIZE);
|
||||
|
|
@ -325,7 +333,7 @@ do_os_wrappers_recvmsg_cloexec(int n)
|
|||
struct marshal_data data;
|
||||
|
||||
data.nr_fds_begin = count_open_fds();
|
||||
#if HAVE_BROKEN_MSG_CMSG_CLOEXEC
|
||||
#if HAVE_BROKEN_MSG_CMSG_CLOEXEC || !defined(MSG_CMSG_CLOEXEC)
|
||||
/* We call the fallback directly on FreeBSD versions with a broken
|
||||
* MSG_CMSG_CLOEXEC, so we don't call the local recvmsg() wrapper. */
|
||||
data.wrapped_calls = 0;
|
||||
|
|
@ -389,5 +397,4 @@ TEST(os_wrappers_epoll_create_cloexec_fallback)
|
|||
init_fallbacks(1);
|
||||
do_os_wrappers_epoll_create_cloexec(2);
|
||||
}
|
||||
#endif /* __APPLE__ */
|
||||
/* FIXME: add tests for wl_os_accept_cloexec() */
|
||||
|
|
|
|||
|
|
@ -23,7 +23,26 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __APPLE__
|
||||
#define _GNU_SOURCE /* For memrchr */
|
||||
#else
|
||||
#include <string.h>
|
||||
/* No memrchr() on Darwin, borrow one from OpenBSD */
|
||||
static void *
|
||||
memrchr(const void *s, int c, size_t n)
|
||||
{
|
||||
const unsigned char *cp;
|
||||
|
||||
if (n != 0) {
|
||||
cp = (unsigned char *)s + n;
|
||||
do {
|
||||
if (*(--cp) == (unsigned char)c)
|
||||
return((void *)cp);
|
||||
} while (--n != 0);
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue