Issue #22117: Use the _PyTime_t API in _datetime.datetime() constructor

* Remove _PyTime_gettimeofday()
* Add _PyTime_GetSystemClock()
This commit is contained in:
Victor Stinner 2015-03-30 00:09:18 +02:00
parent 10915aa85c
commit 09e5cf28ae
4 changed files with 35 additions and 124 deletions

View file

@ -13,15 +13,6 @@ functions and constants
extern "C" {
#endif
#ifdef HAVE_GETTIMEOFDAY
typedef struct timeval _PyTime_timeval;
#else
typedef struct {
time_t tv_sec; /* seconds since Jan. 1, 1970 */
long tv_usec; /* and microseconds */
} _PyTime_timeval;
#endif
/* Structure used by time.get_clock_info() */
typedef struct {
const char *implementation;
@ -30,11 +21,6 @@ typedef struct {
double resolution;
} _Py_clock_info_t;
/* Similar to POSIX gettimeofday but cannot fail. If system gettimeofday
* fails or is not available, fall back to lower resolution clocks.
*/
PyAPI_FUNC(void) _PyTime_gettimeofday(_PyTime_timeval *tp);
typedef enum {
/* Round towards zero. */
_PyTime_ROUND_DOWN=0,
@ -133,6 +119,12 @@ PyAPI_FUNC(int) _PyTime_AsTimeval(_PyTime_t t,
PyAPI_FUNC(int) _PyTime_AsTimespec(_PyTime_t t, struct timespec *ts);
#endif
/* Get the current time from the system clock.
The function cannot fail. _PyTime_Init() ensures that the system clock
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.