diff --git a/rpcs3/CMakeLists.txt b/rpcs3/CMakeLists.txt index 4e1e4c05ef..d8cc33bfe6 100644 --- a/rpcs3/CMakeLists.txt +++ b/rpcs3/CMakeLists.txt @@ -8,6 +8,7 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/git-version.cmake) # Check for a sufficient compiler and set build options include(ConfigureCompiler) +include(CheckFunctionExists) set(ADDITIONAL_LIBS "") if(CMAKE_SYSTEM MATCHES "Linux") diff --git a/rpcs3/Emu/CMakeLists.txt b/rpcs3/Emu/CMakeLists.txt index bfd6c0319f..d6c669fc2a 100644 --- a/rpcs3/Emu/CMakeLists.txt +++ b/rpcs3/Emu/CMakeLists.txt @@ -505,6 +505,13 @@ target_link_libraries(rpcs3_emu 3rdparty::span 3rdparty::xxhash ) +if(APPLE) + check_function_exists(clock_gettime HAVE_CLOCK_GETTIME) + if (${HAVE_CLOCK_GETTIME}) + target_compile_definitions(rpcs3_emu PUBLIC -DHAVE_CLOCK_GETTIME) + endif() +endif() + if(USE_PRECOMPILED_HEADERS) if(COMMAND target_precompile_headers) diff --git a/rpcs3/Emu/Cell/lv2/sys_time.cpp b/rpcs3/Emu/Cell/lv2/sys_time.cpp index 2302406ac1..4e60536912 100644 --- a/rpcs3/Emu/Cell/lv2/sys_time.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_time.cpp @@ -44,13 +44,12 @@ const auto s_time_aux_info = []() -> time_aux_info_t #elif __APPLE__ // XXX only supports a single timer +#if !defined(HAVE_CLOCK_GETTIME) #define TIMER_ABSTIME -1 // The opengroup spec isn't clear on the mapping from REALTIME to CALENDAR being appropriate or not. // http://pubs.opengroup.org/onlinepubs/009695299/basedefs/time.h.html -#ifndef CLOCK_REALTIME #define CLOCK_REALTIME 1 // #define CALENDAR_CLOCK 1 from mach/clock_types.h #define CLOCK_MONOTONIC 0 // #define SYSTEM_CLOCK 0 -#endif // the mach kernel uses struct mach_timespec, so struct timespec is loaded from for compatability // struct timespec { time_t tv_sec; long tv_nsec; }; @@ -103,6 +102,7 @@ static int clock_gettime(int clk_id, struct timespec* tp) return retval; } +#endif #endif