mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-02-22 01:40:49 -05:00
Merge branch 'darwin' into 'main'
build: fix build on macOS Closes #310 See merge request wayland/wayland!254
This commit is contained in:
commit
d8f67f72ab
11 changed files with 97 additions and 19 deletions
|
|
@ -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"
|
||||
|
|
@ -88,7 +89,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]);
|
||||
|
|
|
|||
|
|
@ -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,8 @@ 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]);
|
||||
|
|
@ -824,7 +825,7 @@ TEST(request_bogus_size)
|
|||
for (bogus_size = 11; bogus_size >= 0; bogus_size--) {
|
||||
fprintf(stderr, "* bogus size %d\n", bogus_size);
|
||||
|
||||
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]);
|
||||
|
|
|
|||
|
|
@ -39,6 +39,10 @@
|
|||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
#include <poll.h>
|
||||
|
||||
|
|
@ -1495,6 +1499,9 @@ send_overflow_client(void *data)
|
|||
/* Limit the send buffer size for the display socket to guarantee
|
||||
* that the test will cause an overflow. */
|
||||
sock = wl_display_get_fd(c->wl_display);
|
||||
#ifdef __APPLE__
|
||||
assert(fcntl(sock, F_SETFL, ~O_NONBLOCK) != -1);
|
||||
#endif
|
||||
assert(setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &optval, sizeof(optval)) == 0);
|
||||
|
||||
/* Request to break out of 'display_run' in the main process */
|
||||
|
|
|
|||
|
|
@ -63,6 +63,14 @@ static int fall_back;
|
|||
* __interceptor_ and check at run time if they linked to anything or not.
|
||||
*/
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define DECL(ret_type, func, ...) \
|
||||
static ret_type (*real_ ## func)(__VA_ARGS__); \
|
||||
static int wrapped_calls_ ## func;
|
||||
|
||||
#define REAL(func) \
|
||||
(__typeof__(real_ ## func))dlsym(RTLD_NEXT, #func)
|
||||
#else
|
||||
#define DECL(ret_type, func, ...) \
|
||||
ret_type __interceptor_ ## func(__VA_ARGS__) __attribute__((weak)); \
|
||||
static ret_type (*real_ ## func)(__VA_ARGS__); \
|
||||
|
|
@ -71,6 +79,7 @@ static int fall_back;
|
|||
#define REAL(func) (__interceptor_ ## func) ? \
|
||||
__interceptor_ ## func : \
|
||||
(__typeof__(&__interceptor_ ## func))dlsym(RTLD_NEXT, #func)
|
||||
#endif
|
||||
|
||||
DECL(int, socket, int, int, int);
|
||||
DECL(int, fcntl, int, int, ...);
|
||||
|
|
@ -92,10 +101,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);
|
||||
}
|
||||
|
|
@ -141,10 +152,12 @@ recvmsg(int sockfd, struct msghdr *msg, int flags)
|
|||
{
|
||||
wrapped_calls_recvmsg++;
|
||||
|
||||
#if !(HAVE_BROKEN_MSG_CMSG_CLOEXEC)
|
||||
if (fall_back && (flags & MSG_CMSG_CLOEXEC)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return real_recvmsg(sockfd, msg, flags);
|
||||
}
|
||||
|
|
@ -179,7 +192,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);
|
||||
}
|
||||
|
|
@ -219,7 +236,9 @@ do_os_wrappers_dupfd_cloexec(int n)
|
|||
* Must have 4 calls if falling back, but must also allow
|
||||
* falling back without a forced fallback.
|
||||
*/
|
||||
#if !(HAVE_BROKEN_MSG_CMSG_CLOEXEC)
|
||||
assert(wrapped_calls_fcntl > n);
|
||||
#endif
|
||||
|
||||
exec_fd_leak_check(nr_fds);
|
||||
}
|
||||
|
|
@ -253,8 +272,8 @@ 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);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "wayland-os.h"
|
||||
#include "wayland-server.h"
|
||||
#include "test-runner.h"
|
||||
|
||||
|
|
@ -40,7 +41,7 @@ TEST(create_resource_tst)
|
|||
int s[2];
|
||||
uint32_t id;
|
||||
|
||||
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]);
|
||||
|
|
@ -111,7 +112,7 @@ TEST(destroy_res_tst)
|
|||
.notify = &destroy_notify
|
||||
};
|
||||
|
||||
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]);
|
||||
|
|
@ -159,7 +160,7 @@ TEST(create_resource_with_same_id)
|
|||
int s[2];
|
||||
uint32_t id;
|
||||
|
||||
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]);
|
||||
|
|
|
|||
|
|
@ -63,7 +63,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$__RODATA$test_section");
|
||||
extern const struct test __stop_test_section __asm("section$end$__RODATA$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 +313,12 @@ is_debugger_attached(void)
|
|||
|
||||
return rc;
|
||||
}
|
||||
#else
|
||||
static int
|
||||
is_debugger_attached(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
|
|
|||
|
|
@ -37,11 +37,17 @@ struct test {
|
|||
int must_fail;
|
||||
} __attribute__ ((aligned (16)));
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define TEST_SECTION "__RODATA,test_section"
|
||||
#else
|
||||
#define TEST_SECTION "test_section"
|
||||
#endif
|
||||
|
||||
#define TEST(name) \
|
||||
static void name(void); \
|
||||
\
|
||||
const struct test test##name \
|
||||
__attribute__ ((used, section ("test_section"))) = { \
|
||||
__attribute__ ((used, section (TEST_SECTION))) = { \
|
||||
#name, name, 0 \
|
||||
}; \
|
||||
\
|
||||
|
|
@ -51,7 +57,7 @@ struct test {
|
|||
static void name(void); \
|
||||
\
|
||||
const struct test test##name \
|
||||
__attribute__ ((used, section ("test_section"))) = { \
|
||||
__attribute__ ((used, section (TEST_SECTION))) = { \
|
||||
#name, name, 1 \
|
||||
}; \
|
||||
\
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue