Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define OSX if TARGET_OS_OSX for convenience #1658

Merged
merged 4 commits into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,7 @@ if(WIN32)
message(STATUS "DETECTED SYSTEM: WINDOWS; WIN32=1; PTW32_STATIC_LIB=1")
add_definitions(-DWIN32=1 -DPTW32_STATIC_LIB=1)
elseif(DARWIN)
message(STATUS "DETECTED SYSTEM: DARWIN; OSX=1")
add_definitions(-DOSX=1)
message(STATUS "DETECTED SYSTEM: DARWIN")
elseif(BSD)
message(STATUS "DETECTED SYSTEM: BSD; BSD=1")
add_definitions(-DBSD=1)
Expand Down
4 changes: 2 additions & 2 deletions srtcore/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void CChannel::attach(UDPSOCKET udpsock, const sockaddr_any& udpsocks_addr)

void CChannel::setUDPSockOpt()
{
#if defined(BSD) || defined(OSX) || (TARGET_OS_IOS == 1) || (TARGET_OS_TV == 1)
#if defined(BSD) || TARGET_OS_MAC
// BSD system will fail setsockopt if the requested buffer size exceeds system maximum value
int maxsize = 64000;
if (0 != ::setsockopt(m_iSocket, SOL_SOCKET, SO_RCVBUF, (char*)&m_iRcvBufSize, sizeof(int)))
Expand Down Expand Up @@ -376,7 +376,7 @@ void CChannel::setUDPSockOpt()
#else
timeval tv;
tv.tv_sec = 0;
#if defined (BSD) || defined (OSX) || (TARGET_OS_IOS == 1) || (TARGET_OS_TV == 1)
#if defined (BSD) || TARGET_OS_MAC
// Known BSD bug as the day I wrote this code.
// A small time out value will cause the socket to block forever.
tv.tv_usec = 10000;
Expand Down
12 changes: 6 additions & 6 deletions srtcore/epoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ ENOMEM: There was insufficient memory to create the kernel object.
*/
if (localid < 0)
throw CUDTException(MJ_SETUP, MN_NONE, errno);
#elif defined(BSD) || defined(OSX) || (TARGET_OS_IOS == 1) || (TARGET_OS_TV == 1)
#elif defined(BSD) || TARGET_OS_MAC
localid = kqueue();
if (localid < 0)
throw CUDTException(MJ_SETUP, MN_NONE, errno);
Expand Down Expand Up @@ -216,7 +216,7 @@ int CEPoll::add_ssock(const int eid, const SYSSOCKET& s, const int* events)
ev.data.fd = s;
if (::epoll_ctl(p->second.m_iLocalID, EPOLL_CTL_ADD, s, &ev) < 0)
throw CUDTException();
#elif defined(BSD) || defined(OSX) || (TARGET_OS_IOS == 1) || (TARGET_OS_TV == 1)
#elif defined(BSD) || TARGET_OS_MAC
struct kevent ke[2];
int num = 0;

Expand Down Expand Up @@ -272,7 +272,7 @@ int CEPoll::remove_ssock(const int eid, const SYSSOCKET& s)
epoll_event ev; // ev is ignored, for compatibility with old Linux kernel only.
if (::epoll_ctl(p->second.m_iLocalID, EPOLL_CTL_DEL, s, &ev) < 0)
throw CUDTException();
#elif defined(BSD) || defined(OSX) || (TARGET_OS_IOS == 1) || (TARGET_OS_TV == 1)
#elif defined(BSD) || TARGET_OS_MAC
struct kevent ke;

//
Expand Down Expand Up @@ -391,7 +391,7 @@ int CEPoll::update_ssock(const int eid, const SYSSOCKET& s, const int* events)
ev.data.fd = s;
if (::epoll_ctl(p->second.m_iLocalID, EPOLL_CTL_MOD, s, &ev) < 0)
throw CUDTException();
#elif defined(BSD) || defined(OSX) || (TARGET_OS_IOS == 1) || (TARGET_OS_TV == 1)
#elif defined(BSD) || TARGET_OS_MAC
struct kevent ke[2];
int num = 0;

Expand Down Expand Up @@ -628,7 +628,7 @@ int CEPoll::wait(const int eid, set<SRTSOCKET>* readfds, set<SRTSOCKET>* writefd
}
HLOGC(ealog.Debug, log << "CEPoll::wait: LINUX: picking up " << (total - prev_total) << " ready fds.");

#elif defined(BSD) || defined(OSX) || (TARGET_OS_IOS == 1) || (TARGET_OS_TV == 1)
#elif defined(BSD) || TARGET_OS_MAC
struct timespec tmout = {0, 0};
const int max_events = ed.m_sLocals.size();
SRT_ASSERT(max_event > 0);
Expand Down Expand Up @@ -819,7 +819,7 @@ int CEPoll::release(const int eid)
#ifdef LINUX
// release local/system epoll descriptor
::close(i->second.m_iLocalID);
#elif defined(BSD) || defined(OSX) || (TARGET_OS_IOS == 1) || (TARGET_OS_TV == 1)
#elif defined(BSD) || TARGET_OS_MAC
::close(i->second.m_iLocalID);
#endif

Expand Down
1 change: 1 addition & 0 deletions srtcore/fec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*
*/

#include "platform_sys.h"

#include <string>
#include <map>
Expand Down
2 changes: 2 additions & 0 deletions srtcore/group.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "platform_sys.h"

#include <iterator>

#include "api.h"
Expand Down
1 change: 1 addition & 0 deletions srtcore/packetfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*
*/

#include "platform_sys.h"

#include <string>
#include <map>
Expand Down
1 change: 0 additions & 1 deletion srtcore/platform_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
#include "TargetConditionals.h"
#define __APPLE_USE_RFC_3542 /* IPV6_PKTINFO */


#ifdef SRT_IMPORT_TIME
#include <mach/mach_time.h>
#endif
Expand Down
2 changes: 2 additions & 0 deletions srtcore/srt_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ written by

// Prevents from misconfiguration through preprocessor.

#include "platform_sys.h"

#include <srt_compat.h>

#include <string.h>
Expand Down
1 change: 1 addition & 0 deletions srtcore/sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*/
#include "platform_sys.h"

#include <iomanip>
#include <stdexcept>
Expand Down
2 changes: 2 additions & 0 deletions srtcore/sync_cxx11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*/
#include "platform_sys.h"

#include <iomanip>
#include <math.h>
#include <stdexcept>
Expand Down
3 changes: 2 additions & 1 deletion srtcore/sync_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*/
#include "platform_sys.h"

#include <iomanip>
#include <math.h>
Expand All @@ -23,7 +24,7 @@
#define TIMING_USE_QPC
#include "win/wintime.h"
#include <sys/timeb.h>
#elif defined(OSX) || (TARGET_OS_OSX == 1) || (TARGET_OS_IOS == 1) || (TARGET_OS_TV == 1)
#elif TARGET_OS_MAC
#define TIMING_USE_MACH_ABS_TIME
#include <mach/mach_time.h>
#elif defined(ENABLE_MONOTONIC_CLOCK)
Expand Down