diff options
author | Miss Skeleton (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-11-04 13:16:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-04 13:16:28 (GMT) |
commit | 72bb4c6c1fc5f5209819a2e62d55475ddc888192 (patch) | |
tree | b8f3e4c7403c0dce5ac4acca23ed3b9bd5b33fd1 | |
parent | e899c016ecb508e943a0b77d6aa8f0063b39c678 (diff) | |
download | cpython-72bb4c6c1fc5f5209819a2e62d55475ddc888192.zip cpython-72bb4c6c1fc5f5209819a2e62d55475ddc888192.tar.gz cpython-72bb4c6c1fc5f5209819a2e62d55475ddc888192.tar.bz2 |
bpo-35455: Fix thread_time for Solaris OS (GH-11118) (GH-23130)
(cherry picked from commit 9568622c9983b682b2a2a7bacfd3c341028ea099)
Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
-rw-r--r-- | Misc/NEWS.d/next/Library/2020-11-02-14-10-48.bpo-35455.Q1xTIo.rst | 3 | ||||
-rw-r--r-- | Modules/timemodule.c | 17 |
2 files changed, 20 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Library/2020-11-02-14-10-48.bpo-35455.Q1xTIo.rst b/Misc/NEWS.d/next/Library/2020-11-02-14-10-48.bpo-35455.Q1xTIo.rst new file mode 100644 index 0000000..e72c7d2 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-11-02-14-10-48.bpo-35455.Q1xTIo.rst @@ -0,0 +1,3 @@ +On Solaris, :func:`~time.thread_time` is now implemented with +``gethrvtime()`` because ``clock_gettime(CLOCK_THREAD_CPUTIME_ID)`` is not +always available. Patch by Jakub Kulik. diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 8a4d149..eb192c5 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -1371,6 +1371,23 @@ _PyTime_GetThreadTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info) return 0; } +#elif defined(__sun) && defined(__SVR4) +#define HAVE_THREAD_TIME +static int +_PyTime_GetThreadTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info) +{ + /* bpo-35455: On Solaris, CLOCK_THREAD_CPUTIME_ID clock is not always + available; use gethrvtime() to substitute this functionality. */ + if (info) { + info->implementation = "gethrvtime()"; + info->resolution = 1e-9; + info->monotonic = 1; + info->adjustable = 0; + } + *tp = _PyTime_FromNanoseconds(gethrvtime()); + return 0; +} + #elif defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_PROCESS_CPUTIME_ID) #define HAVE_THREAD_TIME static int |