summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-09-26 16:37:23 -0500
committerLibravatar GitHub <noreply@github.com>2018-09-26 16:37:23 -0500
commitd00a581ae01beef7159e87cb1cf2ecd5c2c19ca3 (patch)
treeee7b21a8980b30a8524e44c43e0cce6319ba9b4a
parentMake libpam optional (diff)
parentMake sway/ipc-server.c POSIX 2001 compliant (diff)
downloadsway-d00a581ae01beef7159e87cb1cf2ecd5c2c19ca3.tar.gz
sway-d00a581ae01beef7159e87cb1cf2ecd5c2c19ca3.tar.zst
sway-d00a581ae01beef7159e87cb1cf2ecd5c2c19ca3.zip
Merge pull request #2715 from sghctoma/add-c11_source
Use _C11_SOURCE feature test macro on FreeBSD (fixes #2616)
-rw-r--r--meson.build4
-rw-r--r--sway/ipc-server.c13
2 files changed, 12 insertions, 5 deletions
diff --git a/meson.build b/meson.build
index 82e4a96f..76eaff20 100644
--- a/meson.build
+++ b/meson.build
@@ -22,6 +22,10 @@ datadir = get_option('datadir')
22sysconfdir = get_option('sysconfdir') 22sysconfdir = get_option('sysconfdir')
23prefix = get_option('prefix') 23prefix = get_option('prefix')
24 24
25if is_freebsd
26 add_project_arguments('-D_C11_SOURCE', language: 'c')
27endif
28
25swayidle_deps = [] 29swayidle_deps = []
26 30
27jsonc = dependency('json-c', version: '>=0.13') 31jsonc = dependency('json-c', version: '>=0.13')
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index 99959c97..2d915502 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -1,8 +1,5 @@
1// See https://i3wm.org/docs/ipc.html for protocol information 1// See https://i3wm.org/docs/ipc.html for protocol information
2#ifndef __FreeBSD__ 2#define _POSIX_C_SOURCE 200112L
3// Any value will hide SOCK_CLOEXEC on FreeBSD (__BSD_VISIBLE=0)
4#define _XOPEN_SOURCE 700
5#endif
6#ifdef __linux__ 3#ifdef __linux__
7#include <linux/input-event-codes.h> 4#include <linux/input-event-codes.h>
8#elif __FreeBSD__ 5#elif __FreeBSD__
@@ -89,10 +86,16 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
89} 86}
90 87
91void ipc_init(struct sway_server *server) { 88void ipc_init(struct sway_server *server) {
92 ipc_socket = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0); 89 ipc_socket = socket(AF_UNIX, SOCK_STREAM, 0);
93 if (ipc_socket == -1) { 90 if (ipc_socket == -1) {
94 sway_abort("Unable to create IPC socket"); 91 sway_abort("Unable to create IPC socket");
95 } 92 }
93 if (fcntl(ipc_socket, F_SETFD, FD_CLOEXEC) == -1) {
94 sway_abort("Unable to set CLOEXEC on IPC socket");
95 }
96 if (fcntl(ipc_socket, F_SETFL, O_NONBLOCK) == -1) {
97 sway_abort("Unable to set NONBLOCK on IPC socket");
98 }
96 99
97 ipc_sockaddr = ipc_user_sockaddr(); 100 ipc_sockaddr = ipc_user_sockaddr();
98 101