diff --git a/meson.build b/meson.build index b879df7b..79aa65e6 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() == 'linux' cc_args += ['-D_POSIX_C_SOURCE=200809L'] endif add_project_arguments(cc_args, language: 'c') @@ -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 cc.has_function('kqueue', prefix: '#include ') + # When building for BSD, epoll(7) is provided by a userspace # wrapper around kqueue(2). epoll_dep = dependency('epoll-shim') else diff --git a/src/scanner.c b/src/scanner.c index c512d231..2e9fa3ae 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -294,7 +294,7 @@ uppercase_dup(const char *src) u = xstrdup(src); for (i = 0; u[i]; i++) - u[i] = toupper(u[i]); + u[i] = toupper((unsigned char) u[i]); u[i] = '\0'; return u; @@ -354,7 +354,7 @@ desc_dump(char *desc, const char *fmt, ...) for (i = 0; desc[i]; ) { k = i; newlines = 0; - while (desc[i] && isspace(desc[i])) { + while (desc[i] && isspace((unsigned char) desc[i])) { if (desc[i] == '\n') newlines++; i++; @@ -363,7 +363,7 @@ desc_dump(char *desc, const char *fmt, ...) break; j = i; - while (desc[i] && !isspace(desc[i])) + while (desc[i] && !isspace((unsigned char) desc[i])) i++; if (newlines > 1) diff --git a/src/wayland-os.c b/src/wayland-os.c index a0db2e84..3ac0ab16 100644 --- a/src/wayland-os.c +++ b/src/wayland-os.c @@ -106,7 +106,25 @@ wl_os_socket_peercred(int sockfd, uid_t *uid, gid_t *gid, pid_t *pid) #endif return 0; } -#elif defined(SO_PEERCRED) +#elif defined(LOCAL_CREDS) /* NetBSD */ +#ifndef SOL_LOCAL /* Before NetBSD 10.0, SOL_LOCAL isn't defined */ +#define SOL_LOCAL (0) +#endif +int +wl_os_socket_peercred(int sockfd, uid_t *uid, gid_t *gid, pid_t *pid) +{ + socklen_t len; + struct sockcred ucred; + + len = sizeof(ucred); + if (getsockopt(sockfd, SOL_LOCAL, LOCAL_CREDS, &ucred, &len) < 0) + return -1; + *uid = ucred.sc_uid; + *gid = ucred.sc_gid; + *pid = ucred.sc_pid; + return 0; +} +#elif defined(SO_PEERCRED) /* Linux */ int wl_os_socket_peercred(int sockfd, uid_t *uid, gid_t *gid, pid_t *pid) { diff --git a/tests/test-runner.c b/tests/test-runner.c index d07dab15..1bfb0df4 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[])