Skip to content

Commit

Permalink
[3.8] bpo-35455: Fix thread_time for Solaris OS (GH-11118). (GH-23145)
Browse files Browse the repository at this point in the history
(cherry picked from commit 9568622)

Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
  • Loading branch information
kulikjak committed Nov 4, 2020
1 parent db4932e commit a12f459
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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.
17 changes: 17 additions & 0 deletions Modules/timemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,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
Expand Down

0 comments on commit a12f459

Please sign in to comment.