mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
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.
This commit is contained in:
parent
4fa99cdb4c
commit
9a8089b32a
5 changed files with 27 additions and 15 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue