Merge pull request #2715 from sghctoma/add-c11_source

Use _C11_SOURCE feature test macro on FreeBSD (fixes #2616)
This commit is contained in:
Drew DeVault 2018-09-26 16:37:23 -05:00 committed by GitHub
commit d00a581ae0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View file

@ -22,6 +22,10 @@ datadir = get_option('datadir')
sysconfdir = get_option('sysconfdir') sysconfdir = get_option('sysconfdir')
prefix = get_option('prefix') prefix = get_option('prefix')
if is_freebsd
add_project_arguments('-D_C11_SOURCE', language: 'c')
endif
swayidle_deps = [] swayidle_deps = []
jsonc = dependency('json-c', version: '>=0.13') jsonc = dependency('json-c', version: '>=0.13')

View file

@ -1,8 +1,5 @@
// See https://i3wm.org/docs/ipc.html for protocol information // See https://i3wm.org/docs/ipc.html for protocol information
#ifndef __FreeBSD__ #define _POSIX_C_SOURCE 200112L
// Any value will hide SOCK_CLOEXEC on FreeBSD (__BSD_VISIBLE=0)
#define _XOPEN_SOURCE 700
#endif
#ifdef __linux__ #ifdef __linux__
#include <linux/input-event-codes.h> #include <linux/input-event-codes.h>
#elif __FreeBSD__ #elif __FreeBSD__
@ -89,10 +86,16 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
} }
void ipc_init(struct sway_server *server) { void ipc_init(struct sway_server *server) {
ipc_socket = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0); ipc_socket = socket(AF_UNIX, SOCK_STREAM, 0);
if (ipc_socket == -1) { if (ipc_socket == -1) {
sway_abort("Unable to create IPC socket"); sway_abort("Unable to create IPC socket");
} }
if (fcntl(ipc_socket, F_SETFD, FD_CLOEXEC) == -1) {
sway_abort("Unable to set CLOEXEC on IPC socket");
}
if (fcntl(ipc_socket, F_SETFL, O_NONBLOCK) == -1) {
sway_abort("Unable to set NONBLOCK on IPC socket");
}
ipc_sockaddr = ipc_user_sockaddr(); ipc_sockaddr = ipc_user_sockaddr();