1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 19:55:10 +00:00

LibCore: Allow LibCore to be compiled on macOS host

Compiling LibCore on macOS is needed if one wants to compile host tools
(like IPCCompiler) on a non Linux host.
These changes could be possibly reverted once "event loop" functionality
and "base library" (Vector, String etc.) will be split in two separate libraries,
updating all relevant projects.
This commit is contained in:
Stefano Cristiano 2019-12-25 17:09:52 +01:00 committed by Andreas Kling
parent aab412bd85
commit 1222b94ab8
3 changed files with 30 additions and 0 deletions

View file

@ -2,6 +2,10 @@
#include <sys/socket.h>
#include <errno.h>
#ifndef SOCK_NONBLOCK
#include <sys/ioctl.h>
#endif
CLocalSocket::CLocalSocket(int fd, CObject* parent)
: CSocket(CSocket::Type::Local, parent)
{
@ -15,7 +19,16 @@ CLocalSocket::CLocalSocket(int fd, CObject* parent)
CLocalSocket::CLocalSocket(CObject* parent)
: CSocket(CSocket::Type::Local, parent)
{
#ifdef SOCK_NONBLOCK
int fd = socket(AF_LOCAL, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
#else
int fd = socket(AF_LOCAL, SOCK_STREAM, 0);
int option = 1;
ioctl(fd, FIONBIO, &option);
fcntl(fd, F_SETFD, FD_CLOEXEC);
#endif
if (fd < 0) {
set_error(errno);
} else {