Skip to content

Commit 9568622

Browse files
authored
bpo-35455: Fix thread_time for Solaris OS (GH-11118)
1 parent 45df61f commit 9568622

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
On Solaris, :func:`~time.thread_time` is now implemented with
2+
``gethrvtime()`` because ``clock_gettime(CLOCK_THREAD_CPUTIME_ID)`` is not
3+
always available. Patch by Jakub Kulik.

Modules/timemodule.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,6 +1371,23 @@ _PyTime_GetThreadTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
13711371
return 0;
13721372
}
13731373

1374+
#elif defined(__sun) && defined(__SVR4)
1375+
#define HAVE_THREAD_TIME
1376+
static int
1377+
_PyTime_GetThreadTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
1378+
{
1379+
/* bpo-35455: On Solaris, CLOCK_THREAD_CPUTIME_ID clock is not always
1380+
available; use gethrvtime() to substitute this functionality. */
1381+
if (info) {
1382+
info->implementation = "gethrvtime()";
1383+
info->resolution = 1e-9;
1384+
info->monotonic = 1;
1385+
info->adjustable = 0;
1386+
}
1387+
*tp = _PyTime_FromNanoseconds(gethrvtime());
1388+
return 0;
1389+
}
1390+
13741391
#elif defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_PROCESS_CPUTIME_ID)
13751392
#define HAVE_THREAD_TIME
13761393
static int

0 commit comments

Comments
 (0)