1212#  include  <winsock2.h>            // struct timeval 
1313#endif 
1414
15- #if  defined(__APPLE__ )
15+ #if  defined(__APPLE__ )  &&  !defined( CLOCK_MONOTONIC_RAW ) 
1616#  include  <mach/mach_time.h>      // mach_absolute_time(), mach_timebase_info() 
1717
1818#if  defined(__APPLE__ ) &&  defined(__has_builtin )
@@ -933,7 +933,7 @@ py_get_system_clock(PyTime_t *tp, _Py_clock_info_t *info, int raise_exc)
933933    struct  timespec  ts ;
934934#endif 
935935
936- #if  !defined(HAVE_CLOCK_GETTIME ) ||  defined(__APPLE__ )
936+ #if  !defined(HAVE_CLOCK_GETTIME ) ||  ( defined(__APPLE__ )  &&  !defined( CLOCK_MONOTONIC_RAW ) )
937937    struct  timeval  tv ;
938938#endif 
939939
@@ -1090,7 +1090,7 @@ py_get_win_perf_counter(PyTime_t *tp, _Py_clock_info_t *info, int raise_exc)
10901090#endif   // MS_WINDOWS 
10911091
10921092
1093- #ifdef    __APPLE__ 
1093+ #if   defined( __APPLE__ )  &&  !defined( CLOCK_MONOTONIC_RAW ) 
10941094static  PyStatus 
10951095py_mach_timebase_info (_PyTimeFraction  * base )
10961096{
@@ -1125,7 +1125,7 @@ _PyTime_Init(struct _Py_time_runtime_state *state)
11251125{
11261126#ifdef  MS_WINDOWS 
11271127    return  py_win_perf_counter_frequency (& state -> base );
1128- #elif  defined(__APPLE__ )
1128+ #elif  defined(__APPLE__ )  &&  !defined( CLOCK_MONOTONIC_RAW ) 
11291129    return  py_mach_timebase_info (& state -> base );
11301130#else 
11311131    return  PyStatus_Ok ();
@@ -1146,7 +1146,7 @@ py_get_monotonic_clock(PyTime_t *tp, _Py_clock_info_t *info, int raise_exc)
11461146    if  (py_get_win_perf_counter (tp , info , raise_exc ) <  0 ) {
11471147        return  -1 ;
11481148    }
1149- #elif  defined(__APPLE__ )
1149+ #elif  defined(__APPLE__ )  &&  !defined( CLOCK_MONOTONIC_RAW ) 
11501150    if  (info ) {
11511151        info -> implementation  =  "mach_absolute_time()" ;
11521152        info -> resolution  =  _PyTimeFraction_Resolution (& _PyRuntime .time .base );
@@ -1185,6 +1185,9 @@ py_get_monotonic_clock(PyTime_t *tp, _Py_clock_info_t *info, int raise_exc)
11851185#ifdef  CLOCK_HIGHRES 
11861186    const  clockid_t  clk_id  =  CLOCK_HIGHRES ;
11871187    const  char  * implementation  =  "clock_gettime(CLOCK_HIGHRES)" ;
1188+ #elif  defined(__APPLE__ ) &&  defined(CLOCK_MONOTONIC_RAW )
1189+     const  clockid_t  clk_id  =  CLOCK_MONOTONIC_RAW ;
1190+     const  char  * implementation  =  "clock_gettime(CLOCK_MONOTONIC_RAW)" ;
11881191#else 
11891192    const  clockid_t  clk_id  =  CLOCK_MONOTONIC ;
11901193    const  char  * implementation  =  "clock_gettime(CLOCK_MONOTONIC)" ;
0 commit comments