mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
build: fix build and provide compat for OpenBSD
- wayland-egl-abi-check: try to use llvm-nm first instead of BSD nm (incompatible options) - avoid forcing _POSIX_C_SOURCE=200809L (SOCK_CLOEXEC become available) - epoll(7) is provided by a userspace wrapper around kqueue(2) as FreeBSD - when using SO_PEERCRED, the struct to use is `struct sockpeercred` instead of `struct ucred` on OpenBSD - provide a compatibility layer for count_open_fds() using sysctl(2) as FreeBSD Signed-off-by: Sebastien Marie <semarie@online.fr>
This commit is contained in:
parent
791912c678
commit
d80bce5f1a
5 changed files with 41 additions and 3 deletions
|
|
@ -13,7 +13,7 @@ if get_option('tests')
|
||||||
wayland_egl_abi_check = executable('wayland-egl-abi-check', 'wayland-egl-abi-check.c')
|
wayland_egl_abi_check = executable('wayland-egl-abi-check', 'wayland-egl-abi-check.c')
|
||||||
test('wayland-egl abi check', wayland_egl_abi_check)
|
test('wayland-egl abi check', wayland_egl_abi_check)
|
||||||
|
|
||||||
nm_path = find_program('nm').full_path()
|
nm_path = find_program(['llvm-nm', 'nm']).full_path()
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'wayland-egl symbols check',
|
'wayland-egl symbols check',
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ config_h.set_quoted('PACKAGE', meson.project_name())
|
||||||
config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
|
config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
|
||||||
|
|
||||||
cc_args = []
|
cc_args = []
|
||||||
if host_machine.system() != 'freebsd'
|
if host_machine.system() not in ['freebsd', 'openbsd']
|
||||||
cc_args += ['-D_POSIX_C_SOURCE=200809L']
|
cc_args += ['-D_POSIX_C_SOURCE=200809L']
|
||||||
endif
|
endif
|
||||||
add_project_arguments(cc_args, language: 'c')
|
add_project_arguments(cc_args, language: 'c')
|
||||||
|
|
@ -69,7 +69,7 @@ endif
|
||||||
config_h.set10('HAVE_BROKEN_MSG_CMSG_CLOEXEC', have_broken_msg_cmsg_cloexec)
|
config_h.set10('HAVE_BROKEN_MSG_CMSG_CLOEXEC', have_broken_msg_cmsg_cloexec)
|
||||||
|
|
||||||
if get_option('libraries')
|
if get_option('libraries')
|
||||||
if host_machine.system() == 'freebsd'
|
if host_machine.system() in ['freebsd', 'openbsd']
|
||||||
# When building for FreeBSD, epoll(7) is provided by a userspace
|
# When building for FreeBSD, epoll(7) is provided by a userspace
|
||||||
# wrapper around kqueue(2).
|
# wrapper around kqueue(2).
|
||||||
epoll_dep = dependency('epoll-shim')
|
epoll_dep = dependency('epoll-shim')
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,11 @@ int
|
||||||
wl_os_socket_peercred(int sockfd, uid_t *uid, gid_t *gid, pid_t *pid)
|
wl_os_socket_peercred(int sockfd, uid_t *uid, gid_t *gid, pid_t *pid)
|
||||||
{
|
{
|
||||||
socklen_t len;
|
socklen_t len;
|
||||||
|
#if defined(__OpenBSD__)
|
||||||
|
struct sockpeercred ucred;
|
||||||
|
#else
|
||||||
struct ucred ucred;
|
struct ucred ucred;
|
||||||
|
#endif
|
||||||
|
|
||||||
len = sizeof(ucred);
|
len = sizeof(ucred);
|
||||||
if (getsockopt(sockfd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) < 0)
|
if (getsockopt(sockfd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) < 0)
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,33 @@ count_open_fds(void)
|
||||||
assert(error == 0 && "sysctl KERN_PROC_NFDS failed.");
|
assert(error == 0 && "sysctl KERN_PROC_NFDS failed.");
|
||||||
return nfds;
|
return nfds;
|
||||||
}
|
}
|
||||||
|
#elif defined(__OpenBSD__)
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* On OpenBSD, get file descriptor information using sysctl()
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
count_open_fds(void)
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
int mib[6];
|
||||||
|
size_t size;
|
||||||
|
|
||||||
|
mib[0] = CTL_KERN;
|
||||||
|
mib[1] = KERN_FILE;
|
||||||
|
mib[2] = KERN_FILE_BYPID;
|
||||||
|
mib[3] = getpid();
|
||||||
|
mib[4] = sizeof(struct kinfo_file);
|
||||||
|
mib[5] = 0;
|
||||||
|
|
||||||
|
/* find the size required to store all the entries */
|
||||||
|
error = sysctl(mib, 6, NULL, &size, NULL, 0);
|
||||||
|
assert(error != -1 && "sysctl KERN_FILE_BYPID failed.");
|
||||||
|
|
||||||
|
/* return the current number of entries */
|
||||||
|
return size / sizeof(struct kinfo_file);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
int
|
int
|
||||||
count_open_fds(void)
|
count_open_fds(void)
|
||||||
|
|
|
||||||
|
|
@ -308,6 +308,13 @@ is_debugger_attached(void)
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
static int
|
||||||
|
is_debugger_attached(void)
|
||||||
|
{
|
||||||
|
/* 0=debugger can't be determined */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue