Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-123978: Remove broken time.thread_time() on NetBSD #124116

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove broken :func:`time.thread_time` and :func:`time.thread_time_ns` on NetBSD.
18 changes: 15 additions & 3 deletions Modules/timemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1288,9 +1288,14 @@ py_process_time(time_module_state *state, PyTime_t *tp,

/* clock_gettime */
// gh-115714: Don't use CLOCK_PROCESS_CPUTIME_ID on WASI.
/* CLOCK_PROF is defined on NetBSD, but not supported.
* CLOCK_PROCESS_CPUTIME_ID is broken on NetBSD for the same reason as
* CLOCK_THREAD_CPUTIME_ID (see comment below).
*/
#if defined(HAVE_CLOCK_GETTIME) \
&& (defined(CLOCK_PROCESS_CPUTIME_ID) || defined(CLOCK_PROF)) \
&& !defined(__wasi__)
&& !defined(__wasi__) \
&& !defined(__NetBSD__)
struct timespec ts;

if (HAVE_CLOCK_GETTIME_RUNTIME) {
Expand Down Expand Up @@ -1483,9 +1488,16 @@ _PyTime_GetThreadTimeWithInfo(PyTime_t *tp, _Py_clock_info_t *info)
return 0;
}

/* CLOCK_THREAD_CPUTIME_ID is broken on NetBSD: the result of clock_gettime()
* includes the sleeping time, that defeats the purpose of the clock.
* Also, clock_getres() does not support it.
* https://github.com/python/cpython/issues/123978
* https://gnats.netbsd.org/57512
*/
#elif defined(HAVE_CLOCK_GETTIME) && \
serhiy-storchaka marked this conversation as resolved.
Show resolved Hide resolved
defined(CLOCK_PROCESS_CPUTIME_ID) && \
!defined(__EMSCRIPTEN__) && !defined(__wasi__)
defined(CLOCK_THREAD_CPUTIME_ID) && \
!defined(__EMSCRIPTEN__) && !defined(__wasi__) && \
!defined(__NetBSD__)
#define HAVE_THREAD_TIME

#if defined(__APPLE__) && _Py__has_attribute(availability)
Expand Down
Loading