Merge 3.5 (monotonic)

This commit is contained in:
Victor Stinner 2015-09-03 00:15:23 +02:00
commit 5a682c9ca5
1 changed files with 3 additions and 13 deletions

View File

@ -601,12 +601,8 @@ _PyTime_GetSystemClockWithInfo(_PyTime_t *t, _Py_clock_info_t *info)
static int static int
pymonotonic_new(_PyTime_t *tp, _Py_clock_info_t *info, int raise) pymonotonic(_PyTime_t *tp, _Py_clock_info_t *info, int raise)
{ {
#ifdef Py_DEBUG
static int last_set = 0;
static _PyTime_t last = 0;
#endif
#if defined(MS_WINDOWS) #if defined(MS_WINDOWS)
ULONGLONG result; ULONGLONG result;
@ -697,12 +693,6 @@ pymonotonic_new(_PyTime_t *tp, _Py_clock_info_t *info, int raise)
} }
if (_PyTime_FromTimespec(tp, &ts, raise) < 0) if (_PyTime_FromTimespec(tp, &ts, raise) < 0)
return -1; return -1;
#endif
#ifdef Py_DEBUG
/* monotonic clock cannot go backward */
assert(!last_set || last <= *tp);
last = *tp;
last_set = 1;
#endif #endif
return 0; return 0;
} }
@ -711,7 +701,7 @@ _PyTime_t
_PyTime_GetMonotonicClock(void) _PyTime_GetMonotonicClock(void)
{ {
_PyTime_t t; _PyTime_t t;
if (pymonotonic_new(&t, NULL, 0) < 0) { if (pymonotonic(&t, NULL, 0) < 0) {
/* should not happen, _PyTime_Init() checked that monotonic clock at /* should not happen, _PyTime_Init() checked that monotonic clock at
startup */ startup */
assert(0); assert(0);
@ -725,7 +715,7 @@ _PyTime_GetMonotonicClock(void)
int int
_PyTime_GetMonotonicClockWithInfo(_PyTime_t *tp, _Py_clock_info_t *info) _PyTime_GetMonotonicClockWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
{ {
return pymonotonic_new(tp, info, 1); return pymonotonic(tp, info, 1);
} }
int int