mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-03-18 05:34:45 -04:00
build: Fix build and tests on macOS
This commit addresses several compatibility issues that prevented Wayland from building and passing its test suite on macOS Core and Compatibility changes: - Emulate Linux behavior by explicitly setting O_NONBLOCK on connections (fixes blocking sendmsg issues on macOS). - Fix compilation on platforms missing SOCK_CLOEXEC and MSG_CMSG_CLOEXEC. - Implement wl_os_socket_peercred() using LOCAL_PEERPID for macOS. - Ensure availability of struct itimerspec (required for POSIX Timers API). Test suite fixes: - Add socketpair_cloexec() wrapper to handle platforms without atomic SOCK_CLOEXEC support. - Add implementation of memrchr() for platforms that do not provide it. - Implement is_debugger_attached() for macOS to handle test timeouts. - Fix tests to handle Mach-O binary format (instead of ELF). - Update egl-symbols-check to support macOS *.dylib Mach-O libraries. Build system: - Add meson option 'xml_catalog' to allow specifying custom catalog paths. Signed-off-by: Martin Lopatář <lopin@dataplex.cz>
This commit is contained in:
parent
5a45a89a83
commit
0f7f06bd4c
16 changed files with 180 additions and 23 deletions
|
|
@ -36,9 +36,11 @@
|
|||
#include <assert.h>
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <signal.h>
|
||||
#include <sys/ptrace.h>
|
||||
#include <sys/socket.h>
|
||||
#ifdef HAVE_SYS_PROCCTL_H
|
||||
#include <sys/procctl.h>
|
||||
#elif defined(HAVE_SYS_PRCTL_H)
|
||||
|
|
@ -46,6 +48,8 @@
|
|||
#ifndef PR_SET_PTRACER
|
||||
# define PR_SET_PTRACER 0x59616d61
|
||||
#endif
|
||||
#elif defined(__APPLE__)
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#include "test-runner.h"
|
||||
|
|
@ -63,7 +67,12 @@ static int timeouts_enabled = 1;
|
|||
/* set to one if the output goes to the terminal */
|
||||
static int is_atty = 0;
|
||||
|
||||
#ifdef __APPLE__
|
||||
extern const struct test __start_test_section __asm("section$start$__DATA$test_section");
|
||||
extern const struct test __stop_test_section __asm("section$end$__DATA$test_section");
|
||||
#else
|
||||
extern const struct test __start_test_section, __stop_test_section;
|
||||
#endif
|
||||
|
||||
static const struct test *
|
||||
find_test(const char *name)
|
||||
|
|
@ -308,6 +317,22 @@ is_debugger_attached(void)
|
|||
|
||||
return rc;
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
static int
|
||||
is_debugger_attached(void)
|
||||
{
|
||||
int ret;
|
||||
int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid() };
|
||||
struct kinfo_proc info;
|
||||
size_t size;
|
||||
|
||||
info.kp_proc.p_flag = 0;
|
||||
ret = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0);
|
||||
assert(ret == 0);
|
||||
|
||||
return (info.kp_proc.p_flag & P_TRACED) != 0;
|
||||
}
|
||||
|
||||
#else
|
||||
static int
|
||||
is_debugger_attached(void)
|
||||
|
|
@ -317,6 +342,43 @@ is_debugger_attached(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
socketpair_cloexec(int domain, int type, int protocol, int sv[2])
|
||||
{
|
||||
int flags;
|
||||
|
||||
#ifdef SOCK_CLOEXEC
|
||||
if (socketpair(domain, type | SOCK_CLOEXEC, protocol, sv) == 0)
|
||||
return 0;
|
||||
if (errno != EINVAL)
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
if (socketpair(domain, type, protocol, sv) < 0)
|
||||
return -1;
|
||||
|
||||
flags = fcntl(sv[0], F_GETFD);
|
||||
if (flags < 0)
|
||||
goto err;
|
||||
|
||||
if (fcntl(sv[0], F_SETFD, flags | FD_CLOEXEC) < 0)
|
||||
goto err;
|
||||
|
||||
flags = fcntl(sv[1], F_GETFD);
|
||||
if (flags < 0)
|
||||
goto err;
|
||||
|
||||
if (fcntl(sv[1], F_SETFD, flags | FD_CLOEXEC) < 0)
|
||||
goto err;
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
close(sv[0]);
|
||||
close(sv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const struct test *t;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue