diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-03-29 22:25:38 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-03-29 22:25:38 (GMT) |
commit | 1bd18ba9a78c58b817564637f1937c2bc3920ecd (patch) | |
tree | ae6d3c09de3e60d3581c8b75705c01478c88b8c1 /Include | |
parent | 09e5cf28aef05ad07bf885c1b732eb567470199a (diff) | |
download | cpython-1bd18ba9a78c58b817564637f1937c2bc3920ecd.zip cpython-1bd18ba9a78c58b817564637f1937c2bc3920ecd.tar.gz cpython-1bd18ba9a78c58b817564637f1937c2bc3920ecd.tar.bz2 |
Issue #22117: Cleanup pytime.c/.h
Diffstat (limited to 'Include')
-rw-r--r-- | Include/pytime.h | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/Include/pytime.h b/Include/pytime.h index 919ba30..b872774 100644 --- a/Include/pytime.h +++ b/Include/pytime.h @@ -13,13 +13,16 @@ functions and constants extern "C" { #endif -/* Structure used by time.get_clock_info() */ -typedef struct { - const char *implementation; - int monotonic; - int adjustable; - double resolution; -} _Py_clock_info_t; +#ifdef PY_INT64_T +/* _PyTime_t: Python timestamp with subsecond precision. It can be used to + store a duration, and so indirectly a date (related to another date, like + UNIX epoch). */ +typedef PY_INT64_T _PyTime_t; +#define _PyTime_MIN PY_LLONG_MIN +#define _PyTime_MAX PY_LLONG_MAX +#else +# error "_PyTime_t need signed 64-bit integer type" +#endif typedef enum { /* Round towards zero. */ @@ -32,12 +35,6 @@ typedef enum { _PyTime_ROUND_FLOOR } _PyTime_round_t; -/* Convert a number of seconds, int or float, to time_t. */ -PyAPI_FUNC(int) _PyTime_ObjectToTime_t( - PyObject *obj, - time_t *sec, - _PyTime_round_t); - /* Convert a time_t to a PyLong. */ PyAPI_FUNC(PyObject *) _PyLong_FromTime_t( time_t sec); @@ -46,6 +43,12 @@ PyAPI_FUNC(PyObject *) _PyLong_FromTime_t( PyAPI_FUNC(time_t) _PyLong_AsTime_t( PyObject *obj); +/* Convert a number of seconds, int or float, to time_t. */ +PyAPI_FUNC(int) _PyTime_ObjectToTime_t( + PyObject *obj, + time_t *sec, + _PyTime_round_t); + /* Convert a number of seconds, int or float, to a timeval structure. usec is in the range [0; 999999] and rounded towards zero. For example, -1.2 is converted to (-2, 800000). */ @@ -64,22 +67,6 @@ PyAPI_FUNC(int) _PyTime_ObjectToTimespec( long *nsec, _PyTime_round_t); -/* Initialize time. - Return 0 on success, raise an exception and return -1 on error. */ -PyAPI_FUNC(int) _PyTime_Init(void); - -/****************** NEW _PyTime_t API **********************/ - -#ifdef PY_INT64_T -/* _PyTime_t: Python timestamp with subsecond precision. It can be used to - store a duration, and so indirectly a date (related to another date, like - UNIX epoch). */ -typedef PY_INT64_T _PyTime_t; -#define _PyTime_MIN PY_LLONG_MIN -#define _PyTime_MAX PY_LLONG_MAX -#else -# 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); @@ -125,14 +112,6 @@ PyAPI_FUNC(int) _PyTime_AsTimespec(_PyTime_t t, struct timespec *ts); works. */ PyAPI_FUNC(_PyTime_t) _PyTime_GetSystemClock(void); -/* Get the current time from the system clock. - * Fill clock information if info is not NULL. - * Raise an exception and return -1 on error, return 0 on success. - */ -PyAPI_FUNC(int) _PyTime_GetSystemClockWithInfo( - _PyTime_t *t, - _Py_clock_info_t *info); - /* 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 @@ -142,6 +121,23 @@ PyAPI_FUNC(int) _PyTime_GetSystemClockWithInfo( is available and works. */ PyAPI_FUNC(_PyTime_t) _PyTime_GetMonotonicClock(void); + +/* Structure used by time.get_clock_info() */ +typedef struct { + const char *implementation; + int monotonic; + int adjustable; + double resolution; +} _Py_clock_info_t; + +/* Get the current time from the system clock. + * Fill clock information if info is not NULL. + * Raise an exception and return -1 on error, return 0 on success. + */ +PyAPI_FUNC(int) _PyTime_GetSystemClockWithInfo( + _PyTime_t *t, + _Py_clock_info_t *info); + /* 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 @@ -155,6 +151,10 @@ PyAPI_FUNC(int) _PyTime_GetMonotonicClockWithInfo( _Py_clock_info_t *info); +/* Initialize time. + Return 0 on success, raise an exception and return -1 on error. */ +PyAPI_FUNC(int) _PyTime_Init(void); + #ifdef __cplusplus } #endif |