diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-08-29 14:31:59 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-08-29 14:31:59 (GMT) |
commit | 0011124dc235fb9af1a80acf3df7edd8816c0a9d (patch) | |
tree | b4c63644aa1fecc1a3ad188da1a73a9f2812c380 /Include/pytime.h | |
parent | 7efb83393cbe08924682c6852e94d3c4a4033c34 (diff) | |
download | cpython-0011124dc235fb9af1a80acf3df7edd8816c0a9d.zip cpython-0011124dc235fb9af1a80acf3df7edd8816c0a9d.tar.gz cpython-0011124dc235fb9af1a80acf3df7edd8816c0a9d.tar.bz2 |
Issue #22043: _PyTime_Init() now checks if the system clock works.
Other changes:
* The whole _PyTime API is private (not defined if Py_LIMITED_API is set)
* _PyTime_gettimeofday_info() also returns -1 on error
* Simplify PyTime_gettimeofday(): only use clock_gettime(CLOCK_REALTIME) or
gettimeofday() on UNIX. Don't fallback to ftime() or time() anymore.
Diffstat (limited to 'Include/pytime.h')
-rw-r--r-- | Include/pytime.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Include/pytime.h b/Include/pytime.h index b0fc6d0..14e9596 100644 --- a/Include/pytime.h +++ b/Include/pytime.h @@ -13,6 +13,8 @@ functions and constants extern "C" { #endif +#ifndef Py_LIMITED_API + #ifdef HAVE_GETTIMEOFDAY typedef struct timeval _PyTime_timeval; #else @@ -37,7 +39,7 @@ PyAPI_FUNC(void) _PyTime_gettimeofday(_PyTime_timeval *tp); /* Similar to _PyTime_gettimeofday() but retrieve also information on the * clock used to get the current time. */ -PyAPI_FUNC(void) _PyTime_gettimeofday_info( +PyAPI_FUNC(int) _PyTime_gettimeofday_info( _PyTime_timeval *tp, _Py_clock_info_t *info); @@ -52,8 +54,6 @@ do { \ ((tv_end.tv_sec - tv_start.tv_sec) + \ (tv_end.tv_usec - tv_start.tv_usec) * 0.000001) -#ifndef Py_LIMITED_API - typedef enum { /* Round towards zero. */ _PyTime_ROUND_DOWN=0, @@ -92,10 +92,11 @@ PyAPI_FUNC(int) _PyTime_ObjectToTimespec( time_t *sec, long *nsec, _PyTime_round_t); -#endif -/* Dummy to force linking. */ -PyAPI_FUNC(void) _PyTime_Init(void); +/* Initialize time. + Return 0 on success, raise an exception and return -1 on error. */ +PyAPI_FUNC(int) _PyTime_Init(void); +#endif /* Py_LIMITED_API */ #ifdef __cplusplus } |