Skip to content

Commit af40a06

Browse files
committed
bpo-30183: Fixes HP-UX cc compilation error in pytime.c
HP-UX does not support the CLOCK_MONOTONIC identifier, and will fail to compile: "Python/pytime.c", line 723: error python#2020: identifier "CLOCK_MONOTONIC" is undefined const clockid_t clk_id = CLOCK_MONOTONIC; Add a new section for __hpux that calls 'gethrtime()' instead of 'clock_gettime()'.
1 parent 6c991bd commit af40a06

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Python/pytime.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,27 @@ pymonotonic(_PyTime_t *tp, _Py_clock_info_t *info, int raise)
693693
info->adjustable = 0;
694694
}
695695

696+
#elif defined(__hpux)
697+
hrtime_t time;
698+
699+
time = gethrtime();
700+
if (time == -1) {
701+
if (raise) {
702+
PyErr_SetFromErrno(PyExc_OSError);
703+
return -1;
704+
}
705+
return -1;
706+
}
707+
708+
*tp = time;
709+
710+
if (info) {
711+
info->implementation = "gethrtime()";
712+
info->resolution = 1e-9;
713+
info->monotonic = 1;
714+
info->adjustable = 0;
715+
}
716+
696717
#else
697718
struct timespec ts;
698719
#ifdef CLOCK_HIGHRES

0 commit comments

Comments
 (0)