@@ -1330,9 +1330,14 @@ py_process_time(time_module_state *state, PyTime_t *tp,
1330
1330
1331
1331
/* clock_gettime */
1332
1332
// gh-115714: Don't use CLOCK_PROCESS_CPUTIME_ID on WASI.
1333
+ /* CLOCK_PROF is defined on NetBSD, but not supported.
1334
+ * CLOCK_PROCESS_CPUTIME_ID is broken on NetBSD for the same reason as
1335
+ * CLOCK_THREAD_CPUTIME_ID (see comment below).
1336
+ */
1333
1337
#if defined(HAVE_CLOCK_GETTIME ) \
1334
1338
&& (defined(CLOCK_PROCESS_CPUTIME_ID ) || defined(CLOCK_PROF )) \
1335
- && !defined(__wasi__ )
1339
+ && !defined(__wasi__ ) \
1340
+ && !defined(__NetBSD__ )
1336
1341
struct timespec ts ;
1337
1342
1338
1343
if (HAVE_CLOCK_GETTIME_RUNTIME ) {
@@ -1525,9 +1530,16 @@ _PyTime_GetThreadTimeWithInfo(PyTime_t *tp, _Py_clock_info_t *info)
1525
1530
return 0 ;
1526
1531
}
1527
1532
1533
+ /* CLOCK_THREAD_CPUTIME_ID is broken on NetBSD: the result of clock_gettime()
1534
+ * includes the sleeping time, that defeats the purpose of the clock.
1535
+ * Also, clock_getres() does not support it.
1536
+ * https://github.com/python/cpython/issues/123978
1537
+ * https://gnats.netbsd.org/57512
1538
+ */
1528
1539
#elif defined(HAVE_CLOCK_GETTIME ) && \
1529
- defined(CLOCK_PROCESS_CPUTIME_ID ) && \
1530
- !defined(__EMSCRIPTEN__ ) && !defined(__wasi__ )
1540
+ defined(CLOCK_THREAD_CPUTIME_ID ) && \
1541
+ !defined(__EMSCRIPTEN__ ) && !defined(__wasi__ ) && \
1542
+ !defined(__NetBSD__ )
1531
1543
#define HAVE_THREAD_TIME
1532
1544
1533
1545
#if defined(__APPLE__ ) && defined(__has_attribute ) && __has_attribute (availability )
0 commit comments