build: Try to make Mac compilation more likely to succeed

I just switched all __linux to not _WIN32 in the hopes that Unix/Linux
API would be more likely to be found on Mac OS. This has not been
tested on Mac so it may or may not work.
This commit is contained in:
Joni Räsänen 2021-08-27 11:19:38 +03:00
parent 6011e2e52b
commit 3aedf8ccde
9 changed files with 16 additions and 16 deletions

View File

@ -75,7 +75,7 @@ static inline void win_get_last_error(void)
static inline void log_platform_error(const char *aux)
{
#ifdef __linux__
#ifndef _WIN32
if (aux) {
LOG_ERROR("%s: %s %d\n", aux, strerror(errno), errno);
} else {

View File

@ -21,7 +21,7 @@ typedef SSIZE_T ssize_t;
#endif
/* https://stackoverflow.com/questions/1537964/visual-c-equivalent-of-gccs-attribute-packed */
#if defined(__MINGW32__) || defined(__MINGW64__) || defined(__linux__)
#if defined(__MINGW32__) || defined(__MINGW64__) || defined(__GNUC__)
#define PACK(__Declaration__) __Declaration__ __attribute__((__packed__))
#else
#define PACK(__Declaration__) __pragma(pack(push, 1)) __Declaration__ __pragma(pack(pop))

View File

@ -6,7 +6,7 @@
#include "random.hh"
#include "util.hh"
#ifdef __linux__
#ifndef _WIN32
#include <errno.h>
#else
#define MSG_DONTWAIT 0

View File

@ -63,7 +63,7 @@ rtp_error_t uvgrtp::poll::poll(std::vector<uvgrtp::socket>& sockets, uint8_t *bu
return RTP_INVALID_VALUE;
}
#ifdef __linux__
#ifndef _WIN32
struct pollfd fds[uvgrtp::MULTICAST_MAX_PEERS];
int ret;

View File

@ -53,7 +53,7 @@ rtp_error_t uvgrtp::frame_queue::init_transaction()
active_ = new transaction_t;
active_->key = uvgrtp::random::generate_32();
#ifdef __linux__
#ifndef _WIN32
active_->headers = new struct mmsghdr[max_mcount_];
active_->chunks = new struct iovec[max_ccount_];
#else

View File

@ -53,7 +53,7 @@ namespace uvgrtp {
uvgrtp::frame::rtp_header rtp_common;
uvgrtp::frame::rtp_header *rtp_headers = nullptr;
#ifdef __linux__
#ifndef _WIN32
struct mmsghdr *headers = nullptr;
struct iovec *chunks = nullptr;
#else

View File

@ -31,10 +31,10 @@ rtp_error_t uvgrtp::random::init()
int uvgrtp::random::generate(void *buf, size_t n)
{
#ifdef __linux__
#ifndef _WIN32
#ifdef HAVE_GETRANDOM
return getrandom(buf, n, 0);
#else // HAVE_GETRANDOM
#else
// Replace with the syscall
int read = syscall(SYS_getrandom, buf, n, 0);
@ -52,7 +52,7 @@ int uvgrtp::random::generate(void *buf, size_t n)
return read;
#endif // HAVE_GETRANDOM
#else // __linux__
#else
if (n > UINT32_MAX)
{

View File

@ -4,7 +4,7 @@
#include "debug.hh"
#include "random.hh"
#ifdef __linux__
#ifndef _WIN32
#include <arpa/inet.h>
#include <unistd.h>
#endif

View File

@ -33,7 +33,7 @@ uvgrtp::socket::socket(int flags):
uvgrtp::socket::~socket()
{
#ifdef __linux__
#ifndef _WIN32
close(socket_);
#else
closesocket(socket_);
@ -153,7 +153,7 @@ rtp_error_t uvgrtp::socket::__sendto(sockaddr_in& addr, uint8_t *buf, size_t buf
{
int nsend = 0;
#ifdef __linux__
#ifndef _WIN32
if ((nsend = ::sendto(socket_, buf, buf_len, flags, (const struct sockaddr *)&addr, sizeof(addr_))) == -1) {
LOG_ERROR("Failed to send data: %s", strerror(errno));
@ -210,7 +210,7 @@ rtp_error_t uvgrtp::socket::__sendtov(
int flags, int *bytes_sent
)
{
#ifdef __linux__
#ifndef _WIN32
int sent_bytes = 0;
for (size_t i = 0; i < buffers.size(); ++i) {
@ -332,7 +332,7 @@ rtp_error_t uvgrtp::socket::__sendtov(
int flags, int *bytes_sent
)
{
#ifdef __linux__
#ifndef _WIN32
int sent_bytes = 0;
struct mmsghdr *hptr, *headers;
@ -493,7 +493,7 @@ rtp_error_t uvgrtp::socket::__recv(uint8_t *buf, size_t buf_len, int flags, int
return RTP_INVALID_VALUE;
}
#ifdef __linux__
#ifndef _WIN32
int32_t ret = ::recv(socket_, buf, buf_len, flags);
if (ret == -1) {
@ -553,7 +553,7 @@ rtp_error_t uvgrtp::socket::__recvfrom(uint8_t *buf, size_t buf_len, int flags,
if (sender)
len_ptr = &len;
#ifdef __linux__
#ifndef _WIN32
int32_t ret = ::recvfrom(socket_, buf, buf_len, flags, (struct sockaddr *)sender, len_ptr);
if (ret == -1) {