Skip to content

Commit

Permalink
Add OpenBSD defines
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac Connor committed Sep 11, 2023
1 parent eab3285 commit f7731d7
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/net/BufferWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ int BufferWriter::Send(SOCKET sockfd, int timeout)
}
}
else if (ret < 0) {
#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__)
#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
if (errno == EINTR || errno == EAGAIN)
#elif defined(WIN32) || defined(_WIN32)
int error = WSAGetLastError();
Expand Down
4 changes: 2 additions & 2 deletions src/net/EventLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void EventLoop::Loop()
{
#if defined(__linux) || defined(__linux__)
std::shared_ptr<TaskScheduler> task_scheduler_ptr(new EpollTaskScheduler(n));
#elif defined(WIN32) || defined(_WIN32) || defined(__FreeBSD__)
#elif defined(WIN32) || defined(_WIN32) || defined(__FreeBSD__) || defined(__OpenBSD__)
std::shared_ptr<TaskScheduler> task_scheduler_ptr(new SelectTaskScheduler(n));
#endif
task_schedulers_.push_back(task_scheduler_ptr);
Expand All @@ -73,7 +73,7 @@ void EventLoop::Loop()

for (auto iter : threads_)
{
#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__)
#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)

#elif defined(WIN32) || defined(_WIN32)
switch (priority)
Expand Down
2 changes: 1 addition & 1 deletion src/net/NetInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using namespace xop;

std::string NetInterface::GetLocalIPAddress()
{
#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__)
#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
SOCKET sockfd = 0;
char buf[512] = { 0 };
struct ifconf ifconf;
Expand Down
8 changes: 4 additions & 4 deletions src/net/Pipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ bool Pipe::Create()

SocketUtil::SetNonBlock(pipe_fd_[0]);
SocketUtil::SetNonBlock(pipe_fd_[1]);
#elif defined(__linux) || defined(__linux__) || defined(__FreeBSD__)
#elif defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
if (pipe2(pipe_fd_, O_NONBLOCK | O_CLOEXEC) < 0) {
return false;
}
Expand All @@ -68,7 +68,7 @@ int Pipe::Write(void *buf, int len)
{
#if defined(WIN32) || defined(_WIN32)
return ::send(pipe_fd_[1], (char *)buf, len, 0);
#elif defined(__linux) || defined(__linux__) || defined(__FreeBSD__)
#elif defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
return ::write(pipe_fd_[1], buf, len);
#endif
}
Expand All @@ -77,7 +77,7 @@ int Pipe::Read(void *buf, int len)
{
#if defined(WIN32) || defined(_WIN32)
return recv(pipe_fd_[0], (char *)buf, len, 0);
#elif defined(__linux) || defined(__linux__) || defined(__FreeBSD__)
#elif defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
return ::read(pipe_fd_[0], buf, len);
#endif
}
Expand All @@ -87,7 +87,7 @@ void Pipe::Close()
#if defined(WIN32) || defined(_WIN32)
closesocket(pipe_fd_[0]);
closesocket(pipe_fd_[1]);
#elif defined(__linux) || defined(__linux__) || defined(__FreeBSD__)
#elif defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
::close(pipe_fd_[0]);
::close(pipe_fd_[1]);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/net/SelectTaskScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ bool SelectTaskScheduler::HandleEvent(int timeout)
struct timeval tv = { timeout/1000, timeout%1000*1000 };
int ret = select((int)maxfd_+1, &fd_read, &fd_write, &fd_exp, &tv);
if (ret < 0) {
#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__)
#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
if(errno == EINTR) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/net/SelectTaskScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <mutex>
#include <unordered_map>

#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__)
#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#include <sys/select.h>
#include <sys/time.h>
#include <sys/types.h>
Expand Down
2 changes: 1 addition & 1 deletion src/net/Socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifndef XOP_SOCKET_H
#define XOP_SOCKET_H

#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__)
#if defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined (__OpenBSD__)
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
Expand Down

0 comments on commit f7731d7

Please sign in to comment.