summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2021-09-15 12:26:43 (GMT)
committerGitHub <noreply@github.com>2021-09-15 12:26:43 (GMT)
commitb49263b698993cad2b8aaddc55cdeaa678412b30 (patch)
tree8425d73518fbddd840e28d8e1d072b05778104d2 /Include
parent40d2ac92f9a28a486156dafdbb613016bb1f6b98 (diff)
downloadcpython-b49263b698993cad2b8aaddc55cdeaa678412b30.zip
cpython-b49263b698993cad2b8aaddc55cdeaa678412b30.tar.gz
cpython-b49263b698993cad2b8aaddc55cdeaa678412b30.tar.bz2
bpo-21302: Add _PyTime_AsNanoseconds() (GH-28350)
Refactor pytime.c: * Add pytime_from_nanoseconds() and pytime_as_nanoseconds(), and use explicitly these functions * Add two empty lines between functions * PEP 7: add braces { ... } * C99: declare variables where they are set * Rename private functions to lowercase * Rename error_time_t_overflow() to pytime_time_t_overflow() * Rename win_perf_counter_frequency() to py_win_perf_counter_frequency() * py_get_monotonic_clock(): add an assertion to detect overflow when mach_absolute_time() unsigned uint64_t is casted to _PyTime_t (signed int64_t). _testcapi: use _PyTime_FromNanoseconds().
Diffstat (limited to 'Include')
-rw-r--r--Include/cpython/pytime.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/Include/cpython/pytime.h b/Include/cpython/pytime.h
index 56607d1..b045388 100644
--- a/Include/cpython/pytime.h
+++ b/Include/cpython/pytime.h
@@ -111,6 +111,9 @@ PyAPI_FUNC(_PyTime_t) _PyTime_AsMilliseconds(_PyTime_t t,
PyAPI_FUNC(_PyTime_t) _PyTime_AsMicroseconds(_PyTime_t t,
_PyTime_round_t round);
+/* Convert timestamp to a number of nanoseconds (10^-9 seconds). */
+PyAPI_FUNC(_PyTime_t) _PyTime_AsNanoseconds(_PyTime_t t);
+
/* Convert timestamp to a number of nanoseconds (10^-9 seconds) as a Python int
object. */
PyAPI_FUNC(PyObject *) _PyTime_AsNanosecondsObject(_PyTime_t t);