From 9a8089b32adee874caefbe2a96096998625c5a78 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 20 Mar 2015 01:42:20 +0100 Subject: 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. --- Include/pytime.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'Include/pytime.h') diff --git a/Include/pytime.h b/Include/pytime.h index 7a14456d3f..d46b17c629 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); -- cgit v1.2.1