diff --git a/egl/meson.build b/egl/meson.build index 76c6ee21..5c62ac1e 100644 --- a/egl/meson.build +++ b/egl/meson.build @@ -13,7 +13,7 @@ if get_option('tests') wayland_egl_abi_check = executable('wayland-egl-abi-check', 'wayland-egl-abi-check.c') 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( 'wayland-egl symbols check', diff --git a/meson.build b/meson.build index b879df7b..431ebb7e 100644 --- a/meson.build +++ b/meson.build @@ -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 ['freebsd', 'openbsd'] cc_args += ['-D_POSIX_C_SOURCE=200809L'] endif 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) 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 # wrapper around kqueue(2). epoll_dep = dependency('epoll-shim') diff --git a/src/wayland-os.c b/src/wayland-os.c index a0db2e84..f00ead4b 100644 --- a/src/wayland-os.c +++ b/src/wayland-os.c @@ -111,7 +111,11 @@ int wl_os_socket_peercred(int sockfd, uid_t *uid, gid_t *gid, pid_t *pid) { socklen_t len; +#if defined(__OpenBSD__) + struct sockpeercred ucred; +#else struct ucred ucred; +#endif len = sizeof(ucred); if (getsockopt(sockfd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) < 0) diff --git a/tests/test-helpers.c b/tests/test-helpers.c index 35357445..1af813bb 100644 --- a/tests/test-helpers.c +++ b/tests/test-helpers.c @@ -61,6 +61,33 @@ count_open_fds(void) assert(error == 0 && "sysctl KERN_PROC_NFDS failed."); return nfds; } +#elif defined(__OpenBSD__) +#include + +/* + * 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 int count_open_fds(void) diff --git a/tests/test-runner.c b/tests/test-runner.c index ea2715e6..9a50d1dd 100644 --- a/tests/test-runner.c +++ b/tests/test-runner.c @@ -308,6 +308,13 @@ is_debugger_attached(void) return rc; } +#else +static int +is_debugger_attached(void) +{ + /* 0=debugger can't be determined */ + return 0; +} #endif int main(int argc, char *argv[])