Annotation of pkgsrc/lang/python39/patches/patch-Python_pytime.c, revision 1.1

1.1     ! sjmulder    1: $NetBSD$
        !             2: 
        !             3: Support for macOS 11 and Apple Silicon (ARM). Backported from:
        !             4: https://github.com/python/cpython/pull/22855
        !             5: 
        !             6: --- Python/pytime.c.orig       2020-10-05 15:07:58.000000000 +0000
        !             7: +++ Python/pytime.c
        !             8: @@ -5,6 +5,12 @@
        !             9:  
        !            10:  #if defined(__APPLE__)
        !            11:  #include <mach/mach_time.h>   /* mach_absolute_time(), mach_timebase_info() */
        !            12: +
        !            13: +#if defined(__APPLE__) && defined(__has_builtin) 
        !            14: +#  if __has_builtin(__builtin_available)
        !            15: +#    define HAVE_CLOCK_GETTIME_RUNTIME __builtin_available(macOS 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *)
        !            16: +#  endif
        !            17: +#endif
        !            18:  #endif
        !            19:  
        !            20:  #define _PyTime_check_mul_overflow(a, b) \
        !            21: @@ -683,15 +689,22 @@ pygettimeofday(_PyTime_t *tp, _Py_clock_
        !            22:  
        !            23:  #else   /* MS_WINDOWS */
        !            24:      int err;
        !            25: -#ifdef HAVE_CLOCK_GETTIME
        !            26: +#if defined(HAVE_CLOCK_GETTIME)
        !            27:      struct timespec ts;
        !            28: -#else
        !            29: +#endif
        !            30: +
        !            31: +#if !defined(HAVE_CLOCK_GETTIME) || defined(__APPLE__)
        !            32:      struct timeval tv;
        !            33:  #endif
        !            34:  
        !            35:      assert(info == NULL || raise);
        !            36:  
        !            37:  #ifdef HAVE_CLOCK_GETTIME
        !            38: +
        !            39: +#ifdef HAVE_CLOCK_GETTIME_RUNTIME
        !            40: +    if (HAVE_CLOCK_GETTIME_RUNTIME) {
        !            41: +#endif
        !            42: +
        !            43:      err = clock_gettime(CLOCK_REALTIME, &ts);
        !            44:      if (err) {
        !            45:          if (raise) {
        !            46: @@ -715,7 +728,14 @@ pygettimeofday(_PyTime_t *tp, _Py_clock_
        !            47:              info->resolution = 1e-9;
        !            48:          }
        !            49:      }
        !            50: -#else   /* HAVE_CLOCK_GETTIME */
        !            51: +
        !            52: +#ifdef HAVE_CLOCK_GETTIME_RUNTIME
        !            53: +    } else { 
        !            54: +#endif
        !            55: +
        !            56: +#endif
        !            57: +
        !            58: +#if !defined(HAVE_CLOCK_GETTIME) || defined(HAVE_CLOCK_GETTIME_RUNTIME)
        !            59:  
        !            60:       /* test gettimeofday() */
        !            61:      err = gettimeofday(&tv, (struct timezone *)NULL);
        !            62: @@ -735,6 +755,11 @@ pygettimeofday(_PyTime_t *tp, _Py_clock_
        !            63:          info->monotonic = 0;
        !            64:          info->adjustable = 1;
        !            65:      }
        !            66: +
        !            67: +#if defined(HAVE_CLOCK_GETTIME_RUNTIME) && defined(HAVE_CLOCK_GETTIME)
        !            68: +    } /* end of availibity block */
        !            69: +#endif
        !            70: +
        !            71:  #endif   /* !HAVE_CLOCK_GETTIME */
        !            72:  #endif   /* !MS_WINDOWS */
        !            73:      return 0;

CVSweb <webmaster@jp.NetBSD.org>