mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-02-15 22:05:35 -05:00
build: fix build on darwin
Signed-off-by: Weijia Wang <contact@weijia.wang>
This commit is contained in:
parent
dc2be77f63
commit
f9aa9b4a07
7 changed files with 49 additions and 9 deletions
|
|
@ -14,7 +14,11 @@ if ! test -n "$NM"; then
|
|||
exit 99
|
||||
fi
|
||||
|
||||
AVAIL_FUNCS="$($NM -D --format=bsd --defined-only $LIB | awk '{print $3}')"
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
AVAIL_FUNCS="$($NM $LIB | awk '{print $3}')"
|
||||
else
|
||||
AVAIL_FUNCS="$($NM -D --format=bsd --defined-only $LIB | awk '{print $3}')"
|
||||
fi
|
||||
|
||||
# Official ABI, taken from the header.
|
||||
REQ_FUNCS="wl_egl_window_resize
|
||||
|
|
@ -37,8 +41,11 @@ if test -n "$NEW_ABI"; then
|
|||
fi
|
||||
|
||||
REMOVED_ABI=$(echo "$REQ_FUNCS" | while read func; do
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
echo "$AVAIL_FUNCS" | grep -q "^_$func$" && continue
|
||||
else
|
||||
echo "$AVAIL_FUNCS" | grep -q "^$func$" && continue
|
||||
|
||||
fi
|
||||
echo $func
|
||||
done)
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ config_h.set_quoted('PACKAGE', meson.project_name())
|
|||
config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
|
||||
|
||||
cc_args = []
|
||||
if host_machine.system() != 'freebsd'
|
||||
if host_machine.system() not in ['darwin', 'freebsd']
|
||||
cc_args += ['-D_POSIX_C_SOURCE=200809L']
|
||||
endif
|
||||
add_project_arguments(cc_args, language: 'c')
|
||||
|
|
@ -51,7 +51,7 @@ foreach f: have_funcs
|
|||
config_h.set('HAVE_' + f.underscorify().to_upper(), cc.has_function(f))
|
||||
endforeach
|
||||
config_h.set10('HAVE_XUCRED_CR_PID', cc.has_member('struct xucred', 'cr_pid', prefix : '#include <sys/ucred.h>'))
|
||||
have_broken_msg_cmsg_cloexec = false
|
||||
have_broken_msg_cmsg_cloexec = (host_machine.system() == 'darwin')
|
||||
if host_machine.system() == 'freebsd'
|
||||
have_broken_msg_cmsg_cloexec = not cc.compiles('''
|
||||
#include <sys/param.h> /* To get __FreeBSD_version. */
|
||||
|
|
@ -69,8 +69,8 @@ endif
|
|||
config_h.set10('HAVE_BROKEN_MSG_CMSG_CLOEXEC', have_broken_msg_cmsg_cloexec)
|
||||
|
||||
if get_option('libraries')
|
||||
if host_machine.system() == 'freebsd'
|
||||
# When building for FreeBSD, epoll(7) is provided by a userspace
|
||||
if host_machine.system() in ['darwin', 'freebsd']
|
||||
# When building for macOS or FreeBSD, epoll(7) is provided by a userspace
|
||||
# wrapper around kqueue(2).
|
||||
epoll_dep = dependency('epoll-shim')
|
||||
else
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ wl_os_socketpair_cloexec(int domain, int type, int protocol, int sv[2])
|
|||
return retval;
|
||||
}
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||
int
|
||||
wl_os_socket_peercred(int sockfd, uid_t *uid, gid_t *gid, pid_t *pid)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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, ...);
|
||||
|
|
|
|||
|
|
@ -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