diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-03-20 00:42:20 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-03-20 00:42:20 (GMT) |
commit | 9a8089b32adee874caefbe2a96096998625c5a78 (patch) | |
tree | bf91050cbe41ad7811a975acc3bab8ed4ee97c02 /Include | |
parent | 4fa99cdb4c5f53d6fa86ef223ae613cb1a8783f8 (diff) | |
download | cpython-9a8089b32adee874caefbe2a96096998625c5a78.zip cpython-9a8089b32adee874caefbe2a96096998625c5a78.tar.gz cpython-9a8089b32adee874caefbe2a96096998625c5a78.tar.bz2 |
Issue #23646: Enhance precision of time.sleep() and socket timeout when
interrupted by a signal
Add a new _PyTime_AddDouble() function and remove _PyTime_ADD_SECONDS() macro.
The _PyTime_ADD_SECONDS only supported an integer number of seconds, the
_PyTime_AddDouble() has subsecond resolution.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/pytime.h | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/Include/pytime.h b/Include/pytime.h index 7a14456..d46b17c 100644 --- a/Include/pytime.h +++ b/Include/pytime.h @@ -41,13 +41,6 @@ PyAPI_FUNC(int) _PyTime_gettimeofday_info( _PyTime_timeval *tp, _Py_clock_info_t *info); -#define _PyTime_ADD_SECONDS(tv, interval) \ -do { \ - tv.tv_usec += (long) (((long) interval - interval) * 1000000); \ - tv.tv_sec += (time_t) interval + (time_t) (tv.tv_usec / 1000000); \ - tv.tv_usec %= 1000000; \ -} while (0) - #define _PyTime_INTERVAL(tv_start, tv_end) \ ((tv_end.tv_sec - tv_start.tv_sec) + \ (tv_end.tv_usec - tv_start.tv_usec) * 0.000001) @@ -109,6 +102,11 @@ PyAPI_FUNC(int) _PyTime_monotonic_info( _PyTime_timeval *tp, _Py_clock_info_t *info); +/* Add interval seconds to tv */ +PyAPI_FUNC(void) +_PyTime_AddDouble(_PyTime_timeval *tv, double interval, + _PyTime_round_t round); + /* Initialize time. Return 0 on success, raise an exception and return -1 on error. */ PyAPI_FUNC(int) _PyTime_Init(void); |