Skip to content

Commit

Permalink
Merge pull request #1523 from dpogue/osx-10.5-fixes
Browse files Browse the repository at this point in the history
Mac OS X 10.5 compiler fixes
  • Loading branch information
Hoikas authored Nov 8, 2023
2 parents 4247e4b + cba2861 commit 9a175fe
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ if(APPLE)
if (PLASMA_MAC_UNIVERSAL)
set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD)")
endif()

if(CMAKE_SYSTEM_VERSION VERSION_LESS 10) # Darwin 10 == Mac OS X 10.6
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
endif()
endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
endif(APPLE)

Expand Down
2 changes: 1 addition & 1 deletion Sources/Plasma/CoreLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ set(CoreLib_SOURCES
plLoadMask.cpp
plProduct.cpp
plViewTransform.cpp
hsWindows.cpp
$<$<PLATFORM_ID:Windows>:hsWindows.cpp>
)

if(CMAKE_USE_WIN32_THREADS_INIT)
Expand Down
4 changes: 0 additions & 4 deletions Sources/Plasma/CoreLib/hsWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/

#ifdef HS_BUILD_FOR_WIN32

#include "HeadSpin.h"
#include "hsWindows.h"
#include <combaseapi.h>
Expand Down Expand Up @@ -93,5 +91,3 @@ const RTL_OSVERSIONINFOEXW& hsGetWindowsVersion()
}
return s_WinVer;
}

#endif
4 changes: 4 additions & 0 deletions Sources/Plasma/PubUtilLib/plAudio/plAudioSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ ST::string kDefaultDeviceMagic = ST_LITERAL("(Default Device)");
#define MAX_NUM_SOURCES 128
#define UPDATE_TIME_MS 100

#ifndef ALC_ALL_DEVICES_SPECIFIER
# define ALC_ALL_DEVICES_SPECIFIER 0x1013
#endif

plProfile_CreateTimer("EAX Update", "Sound", SoundEAXUpdate);
plProfile_CreateTimer("Soft Update", "Sound", SoundSoftUpdate);
plProfile_CreateCounter("Max Sounds", "Sound", SoundMaxNum);
Expand Down
24 changes: 20 additions & 4 deletions Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <cmath>
#include <string_theory/format>

#ifdef HS_BUILD_FOR_APPLE
# include <AvailabilityMacros.h>
# include <sys/time.h>
#endif

#include "plUnifiedTime.h"

#include "hsStream.h"
Expand Down Expand Up @@ -107,10 +112,21 @@ void plUnifiedTime::ToCurrentTime()
struct timespec ts;

#if defined(HS_BUILD_FOR_APPLE)
// timespec_get is only supported since macOS 10.15,
// but clock_gettime exists since macOS 10.12.
int res = clock_gettime(CLOCK_REALTIME, &ts);
hsAssert(res == 0, "clock_gettime failed");
#if defined(HAVE_BUILTIN_AVAILABLE) && MAC_OS_X_VERSION_MIN_REQUIRED >= 101500
if (__builtin_available(macOS 10.15, *)) {
// timespec_get is only supported since macOS 10.15
int res = timespec_get(&ts, TIME_UTC);
hsAssert(res != 0, "timespec_get failed");
} else
#endif
{
struct timeval tv;
int res = gettimeofday(&tv, nullptr);
hsAssert(res == 0, "gettimeofday failed");

ts.tv_sec = tv.tv_sec;
ts.tv_nsec = tv.tv_usec * 1000;
}
#else
int res = timespec_get(&ts, TIME_UTC);
hsAssert(res != 0, "timespec_get failed");
Expand Down

0 comments on commit 9a175fe

Please sign in to comment.