8000 [3.12] gh-123978: Remove broken time.thread_time() on NetBSD (GH-1241… · python/cpython@829cdf0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 829cdf0

Browse files
[3.12] gh-123978: Remove broken time.thread_time() on NetBSD (GH-124116) (GH-124427)
(cherry picked from commit e670a11)
1 parent 6660d29 commit 829cdf0

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove broken :func:`time.thread_time` and :func:`time.thread_time_ns` on NetBSD.

Modules/timemodule.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,8 +1292,14 @@ _PyTime_GetProcessTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
12921292
#else
12931293

12941294
/* clock_gettime */
1295+
// gh-115714: Don't use CLOCK_PROCESS_CPUTIME_ID on WASI.
1296+
/* CLOCK_PROF is defined on NetBSD, but not supported.
1297+
* CLOCK_PROCESS_CPUTIME_ID is broken on NetBSD for the same reason as
1298+
* CLOCK_THREAD_CPUTIME_ID (see comment below).
1299+
*/
12951300
#if defined(HAVE_CLOCK_GETTIME) \
1296-
&& (defined(CLOCK_PROCESS_CPUTIME_ID) || defined(CLOCK_PROF))
1301+
&& (defined(CLOCK_PROCESS_CPUTIME_ID) || defined(CLOCK_PROF)) \
1302+
&& !defined(__NetBSD__)
12971303
struct timespec ts;
12981304

12991305
if (HAVE_CLOCK_GETTIME_RUNTIME) {
@@ -1499,9 +1505,16 @@ _PyTime_GetThreadTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
14991505
return 0;
15001506
}
15011507

1508+
/* CLOCK_THREAD_CPUTIME_ID is broken on NetBSD: the result of clock_gettime()
1509+
* includes the sleeping time, that defeats the purpose of the clock.
1510+
* Also, clock_getres() does not support it.
1511+
* https://github.com/python/cpython/issues/123978
1512+
* https://gnats.netbsd.org/57512
1513+
*/
15021514
#elif defined(HAVE_CLOCK_GETTIME) && \
1503-
defined(CLOCK_PROCESS_CPUTIME_ID) && \
1504-
!defined(__EMSCRIPTEN__) && !defined(__wasi__)
1515+
defined(CLOCK_THREAD_CPUTIME_ID) && \
1516+
!defined(__EMSCRIPTEN__) && !defined(__wasi__) && \
1517+
!defined(__NetBSD__)
15051518
#define HAVE_THREAD_TIME
15061519

15071520
#if defined(__APPLE__) && defined(__has_attribute) && __has_attribute(availability)

0 commit comments

Comments
 (0)
0