summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-03-27 21:27:24 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-03-27 21:27:24 (GMT)
commit4bfb460d883bd224b61a0e7403a09ea093947890 (patch)
tree7555350c57b3d6145b08dba3ef242d721d84413a /Include
parent52d1493c0ccf04aed23f3db9a720ca24f2d19f13 (diff)
downloadcpython-4bfb460d883bd224b61a0e7403a09ea093947890.zip
cpython-4bfb460d883bd224b61a0e7403a09ea093947890.tar.gz
cpython-4bfb460d883bd224b61a0e7403a09ea093947890.tar.bz2
Issue #22117: time.monotonic() now uses the new _PyTime_t API
* Add _PyTime_FromNanoseconds() * Add _PyTime_AsSecondsDouble() * Add unit tests for _PyTime_AsSecondsDouble()
Diffstat (limited to 'Include')
-rw-r--r--Include/pytime.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/Include/pytime.h b/Include/pytime.h
index 78e4ae9..9446b33 100644
--- a/Include/pytime.h
+++ b/Include/pytime.h
@@ -119,12 +119,18 @@ typedef PY_INT64_T _PyTime_t;
# error "_PyTime_t need signed 64-bit integer type"
#endif
+/* Create a timestamp from a number of nanoseconds (C long). */
+PyAPI_FUNC(_PyTime_t) _PyTime_FromNanoseconds(PY_LONG_LONG ns);
+
/* Convert a Python float or int to a timetamp.
Raise an exception and return -1 on error, return 0 on success. */
PyAPI_FUNC(int) _PyTime_FromSecondsObject(_PyTime_t *t,
PyObject *obj,
_PyTime_round_t round);
+/* Convert a timestamp to a number of seconds as a C double. */
+PyAPI_FUNC(double) _PyTime_AsSecondsDouble(_PyTime_t t);
+
/* Convert timestamp to a number of milliseconds (10^-3 seconds). */
PyAPI_FUNC(_PyTime_t) _PyTime_AsMilliseconds(_PyTime_t t,
_PyTime_round_t round);
@@ -133,7 +139,8 @@ PyAPI_FUNC(_PyTime_t) _PyTime_AsMilliseconds(_PyTime_t t,
object. */
PyAPI_FUNC(PyObject *) _PyTime_AsNanosecondsObject(_PyTime_t t);
-/* Convert a timestamp to a timeval structure. */
+/* Convert a timestamp to a timeval structure (microsecond resolution).
+ Raise an exception and return -1 on error, return 0 on success. */
PyAPI_FUNC(int) _PyTime_AsTimeval(_PyTime_t t,
struct timeval *tv,
_PyTime_round_t round);
@@ -147,6 +154,18 @@ PyAPI_FUNC(int) _PyTime_AsTimeval(_PyTime_t t,
is available and works. */
PyAPI_FUNC(_PyTime_t) _PyTime_GetMonotonicClock(void);
+/* Get the time of a monotonic clock, i.e. a clock that cannot go backwards.
+ The clock is not affected by system clock updates. The reference point of
+ the returned value is undefined, so that only the difference between the
+ results of consecutive calls is valid.
+
+ Fill info (if set) with information of the function used to get the time.
+
+ Return 0 on success, raise an exception and return -1 on error. */
+PyAPI_FUNC(int) _PyTime_GetMonotonicClockWithInfo(
+ _PyTime_t *t,
+ _Py_clock_info_t *info);
+
#ifdef __cplusplus
}