@@ -1288,9 +1288,14 @@ py_process_time(time_module_state *state, PyTime_t *tp,
1288
1288
1289
1289
/* clock_gettime */
1290
1290
// gh-115714: Don't use CLOCK_PROCESS_CPUTIME_ID on WASI.
1291
+ /* CLOCK_PROF is defined on NetBSD, but not supported.
1292
+ * CLOCK_PROCESS_CPUTIME_ID is broken on NetBSD for the same reason as
1293
+ * CLOCK_THREAD_CPUTIME_ID (see comment below).
1294
+ */
1291
1295
#if defined(HAVE_CLOCK_GETTIME ) \
1292
1296
&& (defined(CLOCK_PROCESS_CPUTIME_ID ) || defined(CLOCK_PROF )) \
1293
- && !defined(__wasi__ )
1297
+ && !defined(__wasi__ ) \
1298
+ && !defined(__NetBSD__ )
1294
1299
struct timespec ts ;
1295
1300
1296
1301
if (HAVE_CLOCK_GETTIME_RUNTIME ) {
@@ -1483,9 +1488,16 @@ _PyTime_GetThreadTimeWithInfo(PyTime_t *tp, _Py_clock_info_t *info)
1483
1488
return 0 ;
1484
1489
}
1485
1490
1491
+ /* CLOCK_THREAD_CPUTIME_ID is broken on NetBSD: the result of clock_gettime()
1492
+ * includes the sleeping time, that defeats the purpose of the clock.
1493
+ * Also, clock_getres() does not support it.
1494
+ * https://github.com/python/cpython/issues/123978
1495
+ * https://gnats.netbsd.org/57512
1496
+ */
1486
1497
#elif defined(HAVE_CLOCK_GETTIME ) && \
1487
- defined(CLOCK_PROCESS_CPUTIME_ID ) && \
1488
- !defined(__EMSCRIPTEN__ ) && !defined(__wasi__ )
1498
+ defined(CLOCK_THREAD_CPUTIME_ID ) && \
1499
+ !defined(__EMSCRIPTEN__ ) && !defined(__wasi__ ) && \
1500
+ !defined(__NetBSD__ )
1489
1501
#define HAVE_THREAD_TIME
1490
1502
1491
1503
#if defined(__APPLE__ ) && _Py__has_attribute (availability )
0 commit comments