mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
Lagom: Adjust AK, LibCore and LibTLS to build on MacOS
This commit is contained in:
parent
4e8de753c9
commit
9a4ee9aa1a
3 changed files with 19 additions and 3 deletions
|
@ -37,13 +37,17 @@
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
# include <sys/random.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
||||||
inline void fill_with_random(void* buffer, size_t length)
|
inline void fill_with_random(void* buffer, size_t length)
|
||||||
{
|
{
|
||||||
#if defined(__serenity__)
|
#if defined(__serenity__)
|
||||||
arc4random_buf(buffer, length);
|
arc4random_buf(buffer, length);
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__) or defined(__APPLE__)
|
||||||
int rc = getentropy(buffer, length);
|
int rc = getentropy(buffer, length);
|
||||||
(void)rc;
|
(void)rc;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -31,8 +31,9 @@
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#ifndef SOCK_NONBLOCK
|
#ifndef SOCK_NONBLOCK
|
||||||
#include <sys/ioctl.h>
|
# include <sys/ioctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
@ -111,12 +112,13 @@ bool LocalServer::listen(const String& address)
|
||||||
fcntl(m_fd, F_SETFD, FD_CLOEXEC);
|
fcntl(m_fd, F_SETFD, FD_CLOEXEC);
|
||||||
#endif
|
#endif
|
||||||
ASSERT(m_fd >= 0);
|
ASSERT(m_fd >= 0);
|
||||||
|
#ifndef __APPLE__
|
||||||
rc = fchmod(m_fd, 0600);
|
rc = fchmod(m_fd, 0600);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
perror("fchmod");
|
perror("fchmod");
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
auto socket_address = SocketAddress::local(address);
|
auto socket_address = SocketAddress::local(address);
|
||||||
auto un = socket_address.to_sockaddr_un();
|
auto un = socket_address.to_sockaddr_un();
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#include <LibCrypto/PK/Code/EMSA_PSS.h>
|
#include <LibCrypto/PK/Code/EMSA_PSS.h>
|
||||||
#include <LibTLS/TLSv12.h>
|
#include <LibTLS/TLSv12.h>
|
||||||
|
|
||||||
|
#ifndef SOCK_NONBLOCK
|
||||||
|
# include <sys/ioctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
//#define TLS_DEBUG
|
//#define TLS_DEBUG
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -701,7 +705,13 @@ TLSv12::TLSv12(Core::Object* parent, Version version)
|
||||||
m_context.version = version;
|
m_context.version = version;
|
||||||
m_context.is_server = false;
|
m_context.is_server = false;
|
||||||
m_context.tls_buffer = ByteBuffer::create_uninitialized(0);
|
m_context.tls_buffer = ByteBuffer::create_uninitialized(0);
|
||||||
|
#ifdef SOCK_NONBLOCK
|
||||||
int fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
|
int fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
|
||||||
|
#else
|
||||||
|
int fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
int option = 1;
|
||||||
|
ioctl(fd, FIONBIO, &option);
|
||||||
|
#endif
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
set_error(errno);
|
set_error(errno);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue