mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-26 06:59:52 -05:00
Add FreeBSD compatibility
This commit is contained in:
parent
c39bfe7f84
commit
a5fe9aa736
17 changed files with 283 additions and 13 deletions
|
|
@ -1,4 +1,8 @@
|
|||
#define _XOPEN_SOURCE 700
|
||||
#ifdef __FreeBSD__
|
||||
// for SOCK_CLOEXEC
|
||||
#define __BSD_VISIBLE 1
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
|
@ -65,9 +69,12 @@ static bool open_sockets(int socks[2], int display) {
|
|||
|
||||
mkdir(socket_dir, 0777);
|
||||
|
||||
// TODO: non-linux apparently want another format
|
||||
#ifdef __linux__
|
||||
addr.sun_path[0] = 0;
|
||||
path_size = snprintf(addr.sun_path + 1, sizeof(addr.sun_path) - 1, socket_fmt, display);
|
||||
#else
|
||||
path_size = snprintf(addr.sun_path, sizeof(addr.sun_path), socket_fmt, display);
|
||||
#endif
|
||||
socks[0] = open_socket(&addr, path_size);
|
||||
if (socks[0] < 0) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
#define _XOPEN_SOURCE 700
|
||||
#define _DEFAULT_SOURCE
|
||||
#ifdef __FreeBSD__
|
||||
// for SOCK_CLOEXEC
|
||||
#define __BSD_VISIBLE 1
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
|
@ -17,6 +21,14 @@
|
|||
#include "sockets.h"
|
||||
#include "xwm.h"
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
static inline int clearenv(void) {
|
||||
extern char **environ;
|
||||
environ[0] = NULL;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void safe_close(int fd) {
|
||||
if (fd >= 0) {
|
||||
close(fd);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue