mirror of https://github.com/python/cpython
gh-110850: Replace _PyTime_t with PyTime_t (#115719)
Run command: sed -i -e 's!\<_PyTime_t\>!PyTime_t!g' $(find -name "*.c" -o -name "*.h")
This commit is contained in:
parent
0749244d13
commit
9af80ec83d
|
@ -11,7 +11,7 @@ extern "C" {
|
|||
|
||||
#include "pycore_lock.h" // PyMutex
|
||||
#include "pycore_hashtable.h" // _Py_hashtable_t
|
||||
#include "pycore_time.h" // _PyTime_t
|
||||
#include "pycore_time.h" // PyTime_t
|
||||
|
||||
extern int _PyImport_IsInitialized(PyInterpreterState *);
|
||||
|
||||
|
@ -103,7 +103,7 @@ struct _import_state {
|
|||
/* diagnostic info in PyImport_ImportModuleLevelObject() */
|
||||
struct {
|
||||
int import_level;
|
||||
_PyTime_t accumulated;
|
||||
PyTime_t accumulated;
|
||||
int header;
|
||||
} find_and_load;
|
||||
};
|
||||
|
|
|
@ -13,7 +13,7 @@ extern "C" {
|
|||
# error "this header requires Py_BUILD_CORE define"
|
||||
#endif
|
||||
|
||||
#include "pycore_time.h" // _PyTime_t
|
||||
#include "pycore_time.h" // PyTime_t
|
||||
|
||||
|
||||
// A mutex that occupies one byte. The lock can be zero initialized.
|
||||
|
@ -113,7 +113,7 @@ typedef enum _PyLockFlags {
|
|||
// Lock a mutex with an optional timeout and additional options. See
|
||||
// _PyLockFlags for details.
|
||||
extern PyLockStatus
|
||||
_PyMutex_LockTimed(PyMutex *m, _PyTime_t timeout_ns, _PyLockFlags flags);
|
||||
_PyMutex_LockTimed(PyMutex *m, PyTime_t timeout_ns, _PyLockFlags flags);
|
||||
|
||||
// Lock a mutex with aditional options. See _PyLockFlags for details.
|
||||
static inline void
|
||||
|
@ -146,7 +146,7 @@ PyAPI_FUNC(void) PyEvent_Wait(PyEvent *evt);
|
|||
// Wait for the event to be set, or until the timeout expires. If the event is
|
||||
// already set, then this returns immediately. Returns 1 if the event was set,
|
||||
// and 0 if the timeout expired or thread was interrupted.
|
||||
PyAPI_FUNC(int) PyEvent_WaitTimed(PyEvent *evt, _PyTime_t timeout_ns);
|
||||
PyAPI_FUNC(int) PyEvent_WaitTimed(PyEvent *evt, PyTime_t timeout_ns);
|
||||
|
||||
|
||||
// _PyRawMutex implements a word-sized mutex that that does not depend on the
|
||||
|
|
|
@ -18,7 +18,7 @@ extern "C" {
|
|||
# error "this header requires Py_BUILD_CORE define"
|
||||
#endif
|
||||
|
||||
#include "pycore_time.h" // _PyTime_t
|
||||
#include "pycore_time.h" // PyTime_t
|
||||
|
||||
|
||||
enum {
|
||||
|
@ -61,7 +61,7 @@ enum {
|
|||
// }
|
||||
PyAPI_FUNC(int)
|
||||
_PyParkingLot_Park(const void *address, const void *expected,
|
||||
size_t address_size, _PyTime_t timeout_ns,
|
||||
size_t address_size, PyTime_t timeout_ns,
|
||||
void *park_arg, int detach);
|
||||
|
||||
// Callback for _PyParkingLot_Unpark:
|
||||
|
|
|
@ -96,7 +96,7 @@ extern void _PyThread_AfterFork(struct _pythread_runtime_state *state);
|
|||
|
||||
|
||||
// unset: -1 seconds, in nanoseconds
|
||||
#define PyThread_UNSET_TIMEOUT ((_PyTime_t)(-1 * 1000 * 1000 * 1000))
|
||||
#define PyThread_UNSET_TIMEOUT ((PyTime_t)(-1 * 1000 * 1000 * 1000))
|
||||
|
||||
// Exported for the _xxinterpchannels module.
|
||||
PyAPI_FUNC(int) PyThread_ParseTimeoutArg(
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#endif
|
||||
|
||||
#include "pycore_pythread.h" // _POSIX_SEMAPHORES
|
||||
#include "pycore_time.h" // _PyTime_t
|
||||
#include "pycore_time.h" // PyTime_t
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
|
@ -48,7 +48,7 @@ typedef struct _PySemaphore {
|
|||
// If `detach` is true, then the thread will detach/release the GIL while
|
||||
// sleeping.
|
||||
PyAPI_FUNC(int)
|
||||
_PySemaphore_Wait(_PySemaphore *sema, _PyTime_t timeout_ns, int detach);
|
||||
_PySemaphore_Wait(_PySemaphore *sema, PyTime_t timeout_ns, int detach);
|
||||
|
||||
// Wakes up a single thread waiting on sema. Note that _PySemaphore_Wakeup()
|
||||
// can be called before _PySemaphore_Wait().
|
||||
|
|
|
@ -62,7 +62,7 @@ extern "C" {
|
|||
struct timeval;
|
||||
#endif
|
||||
|
||||
typedef PyTime_t _PyTime_t;
|
||||
typedef PyTime_t PyTime_t;
|
||||
#define _SIZEOF_PYTIME_T 8
|
||||
|
||||
typedef enum {
|
||||
|
@ -130,69 +130,69 @@ PyAPI_FUNC(int) _PyTime_ObjectToTimespec(
|
|||
|
||||
// Create a timestamp from a number of seconds.
|
||||
// Export for '_socket' shared extension.
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_FromSeconds(int seconds);
|
||||
PyAPI_FUNC(PyTime_t) _PyTime_FromSeconds(int seconds);
|
||||
|
||||
// Create a timestamp from a number of seconds in double.
|
||||
// Export for '_socket' shared extension.
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_FromSecondsDouble(double seconds, _PyTime_round_t round);
|
||||
PyAPI_FUNC(PyTime_t) _PyTime_FromSecondsDouble(double seconds, _PyTime_round_t round);
|
||||
|
||||
// Macro to create a timestamp from a number of seconds, no integer overflow.
|
||||
// Only use the macro for small values, prefer _PyTime_FromSeconds().
|
||||
#define _PYTIME_FROMSECONDS(seconds) \
|
||||
((_PyTime_t)(seconds) * (1000 * 1000 * 1000))
|
||||
((PyTime_t)(seconds) * (1000 * 1000 * 1000))
|
||||
|
||||
// Create a timestamp from a number of nanoseconds.
|
||||
// Export for '_testinternalcapi' shared extension.
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_FromNanoseconds(_PyTime_t ns);
|
||||
PyAPI_FUNC(PyTime_t) _PyTime_FromNanoseconds(PyTime_t ns);
|
||||
|
||||
// Create a timestamp from a number of microseconds.
|
||||
// Clamp to [PyTime_MIN; PyTime_MAX] on overflow.
|
||||
extern _PyTime_t _PyTime_FromMicrosecondsClamp(_PyTime_t us);
|
||||
extern PyTime_t _PyTime_FromMicrosecondsClamp(PyTime_t us);
|
||||
|
||||
// Create a timestamp from nanoseconds (Python int).
|
||||
// Export for '_lsprof' shared extension.
|
||||
PyAPI_FUNC(int) _PyTime_FromNanosecondsObject(_PyTime_t *t,
|
||||
PyAPI_FUNC(int) _PyTime_FromNanosecondsObject(PyTime_t *t,
|
||||
PyObject *obj);
|
||||
|
||||
// Convert a number of seconds (Python float or int) to a timestamp.
|
||||
// Raise an exception and return -1 on error, return 0 on success.
|
||||
// Export for '_socket' shared extension.
|
||||
PyAPI_FUNC(int) _PyTime_FromSecondsObject(_PyTime_t *t,
|
||||
PyAPI_FUNC(int) _PyTime_FromSecondsObject(PyTime_t *t,
|
||||
PyObject *obj,
|
||||
_PyTime_round_t round);
|
||||
|
||||
// Convert a number of milliseconds (Python float or int, 10^-3) to a timestamp.
|
||||
// Raise an exception and return -1 on error, return 0 on success.
|
||||
// Export for 'select' shared extension.
|
||||
PyAPI_FUNC(int) _PyTime_FromMillisecondsObject(_PyTime_t *t,
|
||||
PyAPI_FUNC(int) _PyTime_FromMillisecondsObject(PyTime_t *t,
|
||||
PyObject *obj,
|
||||
_PyTime_round_t round);
|
||||
|
||||
// Convert timestamp to a number of milliseconds (10^-3 seconds).
|
||||
// Export for '_ssl' shared extension.
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_AsMilliseconds(_PyTime_t t,
|
||||
PyAPI_FUNC(PyTime_t) _PyTime_AsMilliseconds(PyTime_t t,
|
||||
_PyTime_round_t round);
|
||||
|
||||
// Convert timestamp to a number of microseconds (10^-6 seconds).
|
||||
// Export for '_queue' shared extension.
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_AsMicroseconds(_PyTime_t t,
|
||||
PyAPI_FUNC(PyTime_t) _PyTime_AsMicroseconds(PyTime_t t,
|
||||
_PyTime_round_t round);
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
// Convert timestamp to a number of 100 nanoseconds (10^-7 seconds).
|
||||
extern _PyTime_t _PyTime_As100Nanoseconds(_PyTime_t t,
|
||||
extern PyTime_t _PyTime_As100Nanoseconds(PyTime_t t,
|
||||
_PyTime_round_t round);
|
||||
#endif
|
||||
|
||||
// Convert timestamp to a number of nanoseconds (10^-9 seconds) as a Python int
|
||||
// object.
|
||||
// Export for '_testinternalcapi' shared extension.
|
||||
PyAPI_FUNC(PyObject*) _PyTime_AsNanosecondsObject(_PyTime_t t);
|
||||
PyAPI_FUNC(PyObject*) _PyTime_AsNanosecondsObject(PyTime_t t);
|
||||
|
||||
#ifndef MS_WINDOWS
|
||||
// Create a timestamp from a timeval structure.
|
||||
// Raise an exception and return -1 on overflow, return 0 on success.
|
||||
extern int _PyTime_FromTimeval(_PyTime_t *tp, struct timeval *tv);
|
||||
extern int _PyTime_FromTimeval(PyTime_t *tp, struct timeval *tv);
|
||||
#endif
|
||||
|
||||
// Convert a timestamp to a timeval structure (microsecond resolution).
|
||||
|
@ -200,14 +200,14 @@ extern int _PyTime_FromTimeval(_PyTime_t *tp, struct timeval *tv);
|
|||
// Raise an exception and return -1 if the conversion overflowed,
|
||||
// return 0 on success.
|
||||
// Export for 'select' shared extension.
|
||||
PyAPI_FUNC(int) _PyTime_AsTimeval(_PyTime_t t,
|
||||
PyAPI_FUNC(int) _PyTime_AsTimeval(PyTime_t t,
|
||||
struct timeval *tv,
|
||||
_PyTime_round_t round);
|
||||
|
||||
// Similar to _PyTime_AsTimeval() but don't raise an exception on overflow.
|
||||
// On overflow, clamp tv_sec to _PyTime_t min/max.
|
||||
// On overflow, clamp tv_sec to PyTime_t min/max.
|
||||
// Export for 'select' shared extension.
|
||||
PyAPI_FUNC(void) _PyTime_AsTimeval_clamp(_PyTime_t t,
|
||||
PyAPI_FUNC(void) _PyTime_AsTimeval_clamp(PyTime_t t,
|
||||
struct timeval *tv,
|
||||
_PyTime_round_t round);
|
||||
|
||||
|
@ -219,7 +219,7 @@ PyAPI_FUNC(void) _PyTime_AsTimeval_clamp(_PyTime_t t,
|
|||
// return 0 on success.
|
||||
// Export for '_datetime' shared extension.
|
||||
PyAPI_FUNC(int) _PyTime_AsTimevalTime_t(
|
||||
_PyTime_t t,
|
||||
PyTime_t t,
|
||||
time_t *secs,
|
||||
int *us,
|
||||
_PyTime_round_t round);
|
||||
|
@ -227,23 +227,23 @@ PyAPI_FUNC(int) _PyTime_AsTimevalTime_t(
|
|||
#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_KQUEUE)
|
||||
// Create a timestamp from a timespec structure.
|
||||
// Raise an exception and return -1 on overflow, return 0 on success.
|
||||
extern int _PyTime_FromTimespec(_PyTime_t *tp, const struct timespec *ts);
|
||||
extern int _PyTime_FromTimespec(PyTime_t *tp, const struct timespec *ts);
|
||||
|
||||
// Convert a timestamp to a timespec structure (nanosecond resolution).
|
||||
// tv_nsec is always positive.
|
||||
// Raise an exception and return -1 on error, return 0 on success.
|
||||
// Export for '_testinternalcapi' shared extension.
|
||||
PyAPI_FUNC(int) _PyTime_AsTimespec(_PyTime_t t, struct timespec *ts);
|
||||
PyAPI_FUNC(int) _PyTime_AsTimespec(PyTime_t t, struct timespec *ts);
|
||||
|
||||
// Similar to _PyTime_AsTimespec() but don't raise an exception on overflow.
|
||||
// On overflow, clamp tv_sec to _PyTime_t min/max.
|
||||
// On overflow, clamp tv_sec to PyTime_t min/max.
|
||||
// Export for '_testinternalcapi' shared extension.
|
||||
PyAPI_FUNC(void) _PyTime_AsTimespec_clamp(_PyTime_t t, struct timespec *ts);
|
||||
PyAPI_FUNC(void) _PyTime_AsTimespec_clamp(PyTime_t t, struct timespec *ts);
|
||||
#endif
|
||||
|
||||
|
||||
// Compute t1 + t2. Clamp to [PyTime_MIN; PyTime_MAX] on overflow.
|
||||
extern _PyTime_t _PyTime_Add(_PyTime_t t1, _PyTime_t t2);
|
||||
extern PyTime_t _PyTime_Add(PyTime_t t1, PyTime_t t2);
|
||||
|
||||
// Structure used by time.get_clock_info()
|
||||
typedef struct {
|
||||
|
@ -262,13 +262,13 @@ typedef struct {
|
|||
// Use _PyTime_GetSystemClockWithInfo or the public PyTime_Time() to check
|
||||
// for failure.
|
||||
// Export for '_random' shared extension.
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_GetSystemClock(void);
|
||||
PyAPI_FUNC(PyTime_t) _PyTime_GetSystemClock(void);
|
||||
|
||||
// Get the current time from the system clock.
|
||||
// On success, set *t and *info (if not NULL), and return 0.
|
||||
// On error, raise an exception and return -1.
|
||||
extern int _PyTime_GetSystemClockWithInfo(
|
||||
_PyTime_t *t,
|
||||
PyTime_t *t,
|
||||
_Py_clock_info_t *info);
|
||||
|
||||
// Get the time of a monotonic clock, i.e. a clock that cannot go backwards.
|
||||
|
@ -283,7 +283,7 @@ extern int _PyTime_GetSystemClockWithInfo(
|
|||
// Use _PyTime_GetMonotonicClockWithInfo or the public PyTime_Monotonic()
|
||||
// to check for failure.
|
||||
// Export for '_random' shared extension.
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_GetMonotonicClock(void);
|
||||
PyAPI_FUNC(PyTime_t) _PyTime_GetMonotonicClock(void);
|
||||
|
||||
// Get the time of a monotonic clock, i.e. a clock that cannot go backwards.
|
||||
// The clock is not affected by system clock updates. The reference point of
|
||||
|
@ -295,7 +295,7 @@ PyAPI_FUNC(_PyTime_t) _PyTime_GetMonotonicClock(void);
|
|||
// Return 0 on success, raise an exception and return -1 on error.
|
||||
// Export for '_testsinglephase' shared extension.
|
||||
PyAPI_FUNC(int) _PyTime_GetMonotonicClockWithInfo(
|
||||
_PyTime_t *t,
|
||||
PyTime_t *t,
|
||||
_Py_clock_info_t *info);
|
||||
|
||||
|
||||
|
@ -319,7 +319,7 @@ PyAPI_FUNC(int) _PyTime_gmtime(time_t t, struct tm *tm);
|
|||
// Use _PyTime_GetPerfCounterWithInfo() or the public PyTime_PerfCounter
|
||||
// to check for failure.
|
||||
// Export for '_lsprof' shared extension.
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_GetPerfCounter(void);
|
||||
PyAPI_FUNC(PyTime_t) _PyTime_GetPerfCounter(void);
|
||||
|
||||
|
||||
// Get the performance counter: clock with the highest available resolution to
|
||||
|
@ -329,7 +329,7 @@ PyAPI_FUNC(_PyTime_t) _PyTime_GetPerfCounter(void);
|
|||
//
|
||||
// Return 0 on success, raise an exception and return -1 on error.
|
||||
extern int _PyTime_GetPerfCounterWithInfo(
|
||||
_PyTime_t *t,
|
||||
PyTime_t *t,
|
||||
_Py_clock_info_t *info);
|
||||
|
||||
// Alias for backward compatibility
|
||||
|
@ -343,19 +343,19 @@ extern int _PyTime_GetPerfCounterWithInfo(
|
|||
// Create a deadline.
|
||||
// Pseudo code: _PyTime_GetMonotonicClock() + timeout.
|
||||
// Export for '_ssl' shared extension.
|
||||
PyAPI_FUNC(_PyTime_t) _PyDeadline_Init(_PyTime_t timeout);
|
||||
PyAPI_FUNC(PyTime_t) _PyDeadline_Init(PyTime_t timeout);
|
||||
|
||||
// Get remaining time from a deadline.
|
||||
// Pseudo code: deadline - _PyTime_GetMonotonicClock().
|
||||
// Export for '_ssl' shared extension.
|
||||
PyAPI_FUNC(_PyTime_t) _PyDeadline_Get(_PyTime_t deadline);
|
||||
PyAPI_FUNC(PyTime_t) _PyDeadline_Get(PyTime_t deadline);
|
||||
|
||||
|
||||
// --- _PyTimeFraction -------------------------------------------------------
|
||||
|
||||
typedef struct {
|
||||
_PyTime_t numer;
|
||||
_PyTime_t denom;
|
||||
PyTime_t numer;
|
||||
PyTime_t denom;
|
||||
} _PyTimeFraction;
|
||||
|
||||
// Set a fraction.
|
||||
|
@ -363,13 +363,13 @@ typedef struct {
|
|||
// Return -1 if the fraction is invalid.
|
||||
extern int _PyTimeFraction_Set(
|
||||
_PyTimeFraction *frac,
|
||||
_PyTime_t numer,
|
||||
_PyTime_t denom);
|
||||
PyTime_t numer,
|
||||
PyTime_t denom);
|
||||
|
||||
// Compute ticks * frac.numer / frac.denom.
|
||||
// Clamp to [_PyTime_MIN; _PyTime_MAX] on overflow.
|
||||
extern _PyTime_t _PyTimeFraction_Mul(
|
||||
_PyTime_t ticks,
|
||||
extern PyTime_t _PyTimeFraction_Mul(
|
||||
PyTime_t ticks,
|
||||
const _PyTimeFraction *frac);
|
||||
|
||||
// Compute a clock resolution: frac.numer / frac.denom / 1e9.
|
||||
|
|
|
@ -5131,7 +5131,7 @@ datetime_from_timestamp(PyObject *cls, TM_FUNC f, PyObject *timestamp,
|
|||
static PyObject *
|
||||
datetime_best_possible(PyObject *cls, TM_FUNC f, PyObject *tzinfo)
|
||||
{
|
||||
_PyTime_t ts = _PyTime_GetSystemClock();
|
||||
PyTime_t ts = _PyTime_GetSystemClock();
|
||||
time_t secs;
|
||||
int us;
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ struct _ProfilerEntry;
|
|||
/* represents a function called from another function */
|
||||
typedef struct _ProfilerSubEntry {
|
||||
rotating_node_t header;
|
||||
_PyTime_t tt;
|
||||
_PyTime_t it;
|
||||
PyTime_t tt;
|
||||
PyTime_t it;
|
||||
long callcount;
|
||||
long recursivecallcount;
|
||||
long recursionLevel;
|
||||
|
@ -28,8 +28,8 @@ typedef struct _ProfilerSubEntry {
|
|||
typedef struct _ProfilerEntry {
|
||||
rotating_node_t header;
|
||||
PyObject *userObj; /* PyCodeObject, or a descriptive str for builtins */
|
||||
_PyTime_t tt; /* total time in this entry */
|
||||
_PyTime_t it; /* inline time in this entry (not in subcalls) */
|
||||
PyTime_t tt; /* total time in this entry */
|
||||
PyTime_t it; /* inline time in this entry (not in subcalls) */
|
||||
long callcount; /* how many times this was called */
|
||||
long recursivecallcount; /* how many times called recursively */
|
||||
long recursionLevel;
|
||||
|
@ -37,8 +37,8 @@ typedef struct _ProfilerEntry {
|
|||
} ProfilerEntry;
|
||||
|
||||
typedef struct _ProfilerContext {
|
||||
_PyTime_t t0;
|
||||
_PyTime_t subt;
|
||||
PyTime_t t0;
|
||||
PyTime_t subt;
|
||||
struct _ProfilerContext *previous;
|
||||
ProfilerEntry *ctxEntry;
|
||||
} ProfilerContext;
|
||||
|
@ -84,7 +84,7 @@ _lsprof_get_state(PyObject *module)
|
|||
|
||||
/*** External Timers ***/
|
||||
|
||||
static _PyTime_t CallExternalTimer(ProfilerObject *pObj)
|
||||
static PyTime_t CallExternalTimer(ProfilerObject *pObj)
|
||||
{
|
||||
PyObject *o = _PyObject_CallNoArgs(pObj->externalTimer);
|
||||
if (o == NULL) {
|
||||
|
@ -92,7 +92,7 @@ static _PyTime_t CallExternalTimer(ProfilerObject *pObj)
|
|||
return 0;
|
||||
}
|
||||
|
||||
_PyTime_t result;
|
||||
PyTime_t result;
|
||||
int err;
|
||||
if (pObj->externalTimerUnit > 0.0) {
|
||||
/* interpret the result as an integer that will be scaled
|
||||
|
@ -101,7 +101,7 @@ static _PyTime_t CallExternalTimer(ProfilerObject *pObj)
|
|||
}
|
||||
else {
|
||||
/* interpret the result as a double measured in seconds.
|
||||
As the profiler works with _PyTime_t internally
|
||||
As the profiler works with PyTime_t internally
|
||||
we convert it to a large integer */
|
||||
err = _PyTime_FromSecondsObject(&result, o, _PyTime_ROUND_FLOOR);
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ static _PyTime_t CallExternalTimer(ProfilerObject *pObj)
|
|||
return result;
|
||||
}
|
||||
|
||||
static inline _PyTime_t
|
||||
static inline PyTime_t
|
||||
call_timer(ProfilerObject *pObj)
|
||||
{
|
||||
if (pObj->externalTimer != NULL) {
|
||||
|
@ -311,8 +311,8 @@ initContext(ProfilerObject *pObj, ProfilerContext *self, ProfilerEntry *entry)
|
|||
static void
|
||||
Stop(ProfilerObject *pObj, ProfilerContext *self, ProfilerEntry *entry)
|
||||
{
|
||||
_PyTime_t tt = call_timer(pObj) - self->t0;
|
||||
_PyTime_t it = tt - self->subt;
|
||||
PyTime_t tt = call_timer(pObj) - self->t0;
|
||||
PyTime_t it = tt - self->subt;
|
||||
if (self->previous)
|
||||
self->previous->subt += tt;
|
||||
pObj->currentProfilerContext = self->previous;
|
||||
|
@ -557,7 +557,7 @@ _lsprof_Profiler_getstats_impl(ProfilerObject *self, PyTypeObject *cls)
|
|||
return NULL;
|
||||
}
|
||||
if (!self->externalTimer || self->externalTimerUnit == 0.0) {
|
||||
_PyTime_t onesec = _PyTime_FromSeconds(1);
|
||||
PyTime_t onesec = _PyTime_FromSeconds(1);
|
||||
collect.factor = (double)1 / onesec;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "pycore_ceval.h" // Py_MakePendingCalls()
|
||||
#include "pycore_moduleobject.h" // _PyModule_GetState()
|
||||
#include "pycore_parking_lot.h"
|
||||
#include "pycore_time.h" // _PyTime_t
|
||||
#include "pycore_time.h" // PyTime_t
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h> // offsetof()
|
||||
|
@ -372,13 +372,13 @@ _queue_SimpleQueue_get_impl(simplequeueobject *self, PyTypeObject *cls,
|
|||
int block, PyObject *timeout_obj)
|
||||
/*[clinic end generated code: output=5c2cca914cd1e55b input=f7836c65e5839c51]*/
|
||||
{
|
||||
_PyTime_t endtime = 0;
|
||||
PyTime_t endtime = 0;
|
||||
|
||||
// XXX Use PyThread_ParseTimeoutArg().
|
||||
|
||||
if (block != 0 && !Py_IsNone(timeout_obj)) {
|
||||
/* With timeout */
|
||||
_PyTime_t timeout;
|
||||
PyTime_t timeout;
|
||||
if (_PyTime_FromSecondsObject(&timeout,
|
||||
timeout_obj, _PyTime_ROUND_CEILING) < 0) {
|
||||
return NULL;
|
||||
|
|
|
@ -369,7 +369,7 @@ class _ssl.SSLSession "PySSLSession *" "get_state_type(type)->PySSLSession_Type"
|
|||
|
||||
#include "clinic/_ssl.c.h"
|
||||
|
||||
static int PySSL_select(PySocketSockObject *s, int writing, _PyTime_t timeout);
|
||||
static int PySSL_select(PySocketSockObject *s, int writing, PyTime_t timeout);
|
||||
|
||||
static int PySSL_set_owner(PySSLSocket *, PyObject *, void *);
|
||||
static int PySSL_set_session(PySSLSocket *, PyObject *, void *);
|
||||
|
@ -963,7 +963,7 @@ _ssl__SSLSocket_do_handshake_impl(PySSLSocket *self)
|
|||
_PySSLError err;
|
||||
int sockstate, nonblocking;
|
||||
PySocketSockObject *sock = GET_SOCKET(self);
|
||||
_PyTime_t timeout, deadline = 0;
|
||||
PyTime_t timeout, deadline = 0;
|
||||
int has_timeout;
|
||||
|
||||
if (sock) {
|
||||
|
@ -2273,12 +2273,12 @@ PySSL_dealloc(PySSLSocket *self)
|
|||
*/
|
||||
|
||||
static int
|
||||
PySSL_select(PySocketSockObject *s, int writing, _PyTime_t timeout)
|
||||
PySSL_select(PySocketSockObject *s, int writing, PyTime_t timeout)
|
||||
{
|
||||
int rc;
|
||||
#ifdef HAVE_POLL
|
||||
struct pollfd pollfd;
|
||||
_PyTime_t ms;
|
||||
PyTime_t ms;
|
||||
#else
|
||||
int nfds;
|
||||
fd_set fds;
|
||||
|
@ -2357,7 +2357,7 @@ _ssl__SSLSocket_write_impl(PySSLSocket *self, Py_buffer *b)
|
|||
_PySSLError err;
|
||||
int nonblocking;
|
||||
PySocketSockObject *sock = GET_SOCKET(self);
|
||||
_PyTime_t timeout, deadline = 0;
|
||||
PyTime_t timeout, deadline = 0;
|
||||
int has_timeout;
|
||||
|
||||
if (sock != NULL) {
|
||||
|
@ -2495,7 +2495,7 @@ _ssl__SSLSocket_read_impl(PySSLSocket *self, Py_ssize_t len,
|
|||
_PySSLError err;
|
||||
int nonblocking;
|
||||
PySocketSockObject *sock = GET_SOCKET(self);
|
||||
_PyTime_t timeout, deadline = 0;
|
||||
PyTime_t timeout, deadline = 0;
|
||||
int has_timeout;
|
||||
|
||||
if (!group_right_1 && len < 0) {
|
||||
|
@ -2627,7 +2627,7 @@ _ssl__SSLSocket_shutdown_impl(PySSLSocket *self)
|
|||
int sockstate, nonblocking, ret;
|
||||
int zeros = 0;
|
||||
PySocketSockObject *sock = GET_SOCKET(self);
|
||||
_PyTime_t timeout, deadline = 0;
|
||||
PyTime_t timeout, deadline = 0;
|
||||
int has_timeout;
|
||||
|
||||
if (sock != NULL) {
|
||||
|
|
|
@ -16,7 +16,7 @@ test_pytime_fromseconds(PyObject *self, PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, "i", &seconds)) {
|
||||
return NULL;
|
||||
}
|
||||
_PyTime_t ts = _PyTime_FromSeconds(seconds);
|
||||
PyTime_t ts = _PyTime_FromSeconds(seconds);
|
||||
return _PyTime_AsNanosecondsObject(ts);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ test_pytime_fromsecondsobject(PyObject *self, PyObject *args)
|
|||
if (check_time_rounding(round) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
_PyTime_t ts;
|
||||
PyTime_t ts;
|
||||
if (_PyTime_FromSecondsObject(&ts, obj, round) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ test_PyTime_AsTimeval(PyObject *self, PyObject *args)
|
|||
if (check_time_rounding(round) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
if (_PyTime_FromNanosecondsObject(&t, obj) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ test_PyTime_AsTimeval_clamp(PyObject *self, PyObject *args)
|
|||
if (check_time_rounding(round) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
if (_PyTime_FromNanosecondsObject(&t, obj) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ test_PyTime_AsTimespec(PyObject *self, PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, "O", &obj)) {
|
||||
return NULL;
|
||||
}
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
if (_PyTime_FromNanosecondsObject(&t, obj) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ test_PyTime_AsTimespec_clamp(PyObject *self, PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, "O", &obj)) {
|
||||
return NULL;
|
||||
}
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
if (_PyTime_FromNanosecondsObject(&t, obj) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -148,15 +148,15 @@ test_PyTime_AsMilliseconds(PyObject *self, PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, "Oi", &obj, &round)) {
|
||||
return NULL;
|
||||
}
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
if (_PyTime_FromNanosecondsObject(&t, obj) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (check_time_rounding(round) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
_PyTime_t ms = _PyTime_AsMilliseconds(t, round);
|
||||
_PyTime_t ns = _PyTime_FromNanoseconds(ms);
|
||||
PyTime_t ms = _PyTime_AsMilliseconds(t, round);
|
||||
PyTime_t ns = _PyTime_FromNanoseconds(ms);
|
||||
return _PyTime_AsNanosecondsObject(ns);
|
||||
}
|
||||
|
||||
|
@ -168,15 +168,15 @@ test_PyTime_AsMicroseconds(PyObject *self, PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, "Oi", &obj, &round)) {
|
||||
return NULL;
|
||||
}
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
if (_PyTime_FromNanosecondsObject(&t, obj) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (check_time_rounding(round) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
_PyTime_t us = _PyTime_AsMicroseconds(t, round);
|
||||
_PyTime_t ns = _PyTime_FromNanoseconds(us);
|
||||
PyTime_t us = _PyTime_AsMicroseconds(t, round);
|
||||
PyTime_t ns = _PyTime_FromNanoseconds(us);
|
||||
return _PyTime_AsNanosecondsObject(ns);
|
||||
}
|
||||
|
||||
|
|
|
@ -289,7 +289,7 @@ _testinternalcapi_benchmark_locks_impl(PyObject *module,
|
|||
goto exit;
|
||||
}
|
||||
|
||||
_PyTime_t start = _PyTime_GetMonotonicClock();
|
||||
PyTime_t start = _PyTime_GetMonotonicClock();
|
||||
|
||||
for (Py_ssize_t i = 0; i < num_threads; i++) {
|
||||
thread_data[i].bench_data = &bench_data;
|
||||
|
@ -306,7 +306,7 @@ _testinternalcapi_benchmark_locks_impl(PyObject *module,
|
|||
}
|
||||
|
||||
Py_ssize_t total_iters = bench_data.total_iters;
|
||||
_PyTime_t end = _PyTime_GetMonotonicClock();
|
||||
PyTime_t end = _PyTime_GetMonotonicClock();
|
||||
|
||||
// Return the total number of acquisitions and the number of acquisitions
|
||||
// for each thread.
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
//#include <time.h>
|
||||
#include "Python.h"
|
||||
#include "pycore_namespace.h" // _PyNamespace_New()
|
||||
#include "pycore_time.h" // _PyTime_t
|
||||
#include "pycore_time.h" // PyTime_t
|
||||
|
||||
|
||||
typedef struct {
|
||||
_PyTime_t initialized;
|
||||
PyTime_t initialized;
|
||||
PyObject *error;
|
||||
PyObject *int_const;
|
||||
PyObject *str_const;
|
||||
|
@ -67,15 +67,15 @@ clear_state(module_state *state)
|
|||
}
|
||||
|
||||
static int
|
||||
_set_initialized(_PyTime_t *initialized)
|
||||
_set_initialized(PyTime_t *initialized)
|
||||
{
|
||||
/* We go strictly monotonic to ensure each time is unique. */
|
||||
_PyTime_t prev;
|
||||
PyTime_t prev;
|
||||
if (_PyTime_GetMonotonicClockWithInfo(&prev, NULL) != 0) {
|
||||
return -1;
|
||||
}
|
||||
/* We do a busy sleep since the interval should be super short. */
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
do {
|
||||
if (_PyTime_GetMonotonicClockWithInfo(&t, NULL) != 0) {
|
||||
return -1;
|
||||
|
|
|
@ -235,14 +235,14 @@ lock_dealloc(lockobject *self)
|
|||
}
|
||||
|
||||
static inline PyLockStatus
|
||||
acquire_timed(PyThread_type_lock lock, _PyTime_t timeout)
|
||||
acquire_timed(PyThread_type_lock lock, PyTime_t timeout)
|
||||
{
|
||||
return PyThread_acquire_lock_timed_with_retries(lock, timeout);
|
||||
}
|
||||
|
||||
static int
|
||||
lock_acquire_parse_args(PyObject *args, PyObject *kwds,
|
||||
_PyTime_t *timeout)
|
||||
PyTime_t *timeout)
|
||||
{
|
||||
char *kwlist[] = {"blocking", "timeout", NULL};
|
||||
int blocking = 1;
|
||||
|
@ -253,7 +253,7 @@ lock_acquire_parse_args(PyObject *args, PyObject *kwds,
|
|||
|
||||
// XXX Use PyThread_ParseTimeoutArg().
|
||||
|
||||
const _PyTime_t unset_timeout = _PyTime_FromSeconds(-1);
|
||||
const PyTime_t unset_timeout = _PyTime_FromSeconds(-1);
|
||||
*timeout = unset_timeout;
|
||||
|
||||
if (timeout_obj
|
||||
|
@ -274,7 +274,7 @@ lock_acquire_parse_args(PyObject *args, PyObject *kwds,
|
|||
if (!blocking)
|
||||
*timeout = 0;
|
||||
else if (*timeout != unset_timeout) {
|
||||
_PyTime_t microseconds;
|
||||
PyTime_t microseconds;
|
||||
|
||||
microseconds = _PyTime_AsMicroseconds(*timeout, _PyTime_ROUND_TIMEOUT);
|
||||
if (microseconds > PY_TIMEOUT_MAX) {
|
||||
|
@ -289,7 +289,7 @@ lock_acquire_parse_args(PyObject *args, PyObject *kwds,
|
|||
static PyObject *
|
||||
lock_PyThread_acquire_lock(lockobject *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
_PyTime_t timeout;
|
||||
PyTime_t timeout;
|
||||
if (lock_acquire_parse_args(args, kwds, &timeout) < 0)
|
||||
return NULL;
|
||||
|
||||
|
@ -501,7 +501,7 @@ rlock_is_owned_by(rlockobject *self, PyThread_ident_t tid)
|
|||
static PyObject *
|
||||
rlock_acquire(rlockobject *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
_PyTime_t timeout;
|
||||
PyTime_t timeout;
|
||||
PyThread_ident_t tid;
|
||||
PyLockStatus r = PY_LOCK_ACQUIRED;
|
||||
|
||||
|
|
|
@ -623,7 +623,7 @@ cancel_dump_traceback_later(void)
|
|||
#define SEC_TO_US (1000 * 1000)
|
||||
|
||||
static char*
|
||||
format_timeout(_PyTime_t us)
|
||||
format_timeout(PyTime_t us)
|
||||
{
|
||||
unsigned long sec, min, hour;
|
||||
char buffer[100];
|
||||
|
@ -656,7 +656,7 @@ faulthandler_dump_traceback_later(PyObject *self,
|
|||
{
|
||||
static char *kwlist[] = {"timeout", "repeat", "file", "exit", NULL};
|
||||
PyObject *timeout_obj;
|
||||
_PyTime_t timeout, timeout_us;
|
||||
PyTime_t timeout, timeout_us;
|
||||
int repeat = 0;
|
||||
PyObject *file = NULL;
|
||||
int fd;
|
||||
|
|
|
@ -10410,7 +10410,7 @@ build_itimerspec(const struct itimerspec* curr_value)
|
|||
static PyObject *
|
||||
build_itimerspec_ns(const struct itimerspec* curr_value)
|
||||
{
|
||||
_PyTime_t value, interval;
|
||||
PyTime_t value, interval;
|
||||
if (_PyTime_FromTimespec(&value, &curr_value->it_value) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "Python.h"
|
||||
#include "pycore_fileutils.h" // _Py_set_inheritable()
|
||||
#include "pycore_import.h" // _PyImport_GetModuleAttrString()
|
||||
#include "pycore_time.h" // _PyTime_t
|
||||
#include "pycore_time.h" // PyTime_t
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h> // offsetof()
|
||||
|
@ -297,7 +297,7 @@ select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist,
|
|||
struct timeval tv, *tvp;
|
||||
int imax, omax, emax, max;
|
||||
int n;
|
||||
_PyTime_t timeout, deadline = 0;
|
||||
PyTime_t timeout, deadline = 0;
|
||||
|
||||
if (timeout_obj == Py_None)
|
||||
tvp = (struct timeval *)NULL;
|
||||
|
@ -619,7 +619,7 @@ select_poll_poll_impl(pollObject *self, PyObject *timeout_obj)
|
|||
PyObject *result_list = NULL;
|
||||
int poll_result, i, j;
|
||||
PyObject *value = NULL, *num = NULL;
|
||||
_PyTime_t timeout = -1, ms = -1, deadline = 0;
|
||||
PyTime_t timeout = -1, ms = -1, deadline = 0;
|
||||
int async_err = 0;
|
||||
|
||||
if (timeout_obj != Py_None) {
|
||||
|
@ -946,7 +946,7 @@ select_devpoll_poll_impl(devpollObject *self, PyObject *timeout_obj)
|
|||
PyObject *result_list = NULL;
|
||||
int poll_result, i;
|
||||
PyObject *value, *num1, *num2;
|
||||
_PyTime_t timeout, ms, deadline = 0;
|
||||
PyTime_t timeout, ms, deadline = 0;
|
||||
|
||||
if (self->fd_devpoll < 0)
|
||||
return devpoll_err_closed();
|
||||
|
@ -1559,7 +1559,7 @@ select_epoll_poll_impl(pyEpoll_Object *self, PyObject *timeout_obj,
|
|||
int nfds, i;
|
||||
PyObject *elist = NULL, *etuple = NULL;
|
||||
struct epoll_event *evs = NULL;
|
||||
_PyTime_t timeout = -1, ms = -1, deadline = 0;
|
||||
PyTime_t timeout = -1, ms = -1, deadline = 0;
|
||||
|
||||
if (self->epfd < 0)
|
||||
return pyepoll_err_closed();
|
||||
|
@ -2242,7 +2242,7 @@ select_kqueue_control_impl(kqueue_queue_Object *self, PyObject *changelist,
|
|||
struct kevent *chl = NULL;
|
||||
struct timespec timeoutspec;
|
||||
struct timespec *ptimeoutspec;
|
||||
_PyTime_t timeout, deadline = 0;
|
||||
PyTime_t timeout, deadline = 0;
|
||||
_selectstate *state = _selectstate_by_type(Py_TYPE(self));
|
||||
|
||||
if (self->kqfd < 0)
|
||||
|
|
|
@ -173,7 +173,7 @@ timeval_from_double(PyObject *obj, struct timeval *tv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
if (_PyTime_FromSecondsObject(&t, obj, _PyTime_ROUND_CEILING) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -1207,7 +1207,7 @@ signal_sigtimedwait_impl(PyObject *module, sigset_t sigset,
|
|||
PyObject *timeout_obj)
|
||||
/*[clinic end generated code: output=59c8971e8ae18a64 input=87fd39237cf0b7ba]*/
|
||||
{
|
||||
_PyTime_t timeout;
|
||||
PyTime_t timeout;
|
||||
if (_PyTime_FromSecondsObject(&timeout,
|
||||
timeout_obj, _PyTime_ROUND_CEILING) < 0)
|
||||
return NULL;
|
||||
|
@ -1217,7 +1217,7 @@ signal_sigtimedwait_impl(PyObject *module, sigset_t sigset,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
_PyTime_t deadline = _PyDeadline_Init(timeout);
|
||||
PyTime_t deadline = _PyDeadline_Init(timeout);
|
||||
siginfo_t si;
|
||||
|
||||
do {
|
||||
|
|
|
@ -547,7 +547,7 @@ typedef struct _socket_state {
|
|||
PyObject *socket_gaierror;
|
||||
|
||||
/* Default timeout for new sockets */
|
||||
_PyTime_t defaulttimeout;
|
||||
PyTime_t defaulttimeout;
|
||||
|
||||
#if defined(HAVE_ACCEPT) || defined(HAVE_ACCEPT4)
|
||||
#if defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC)
|
||||
|
@ -772,13 +772,13 @@ internal_setblocking(PySocketSockObject *s, int block)
|
|||
}
|
||||
|
||||
static int
|
||||
internal_select(PySocketSockObject *s, int writing, _PyTime_t interval,
|
||||
internal_select(PySocketSockObject *s, int writing, PyTime_t interval,
|
||||
int connect)
|
||||
{
|
||||
int n;
|
||||
#ifdef HAVE_POLL
|
||||
struct pollfd pollfd;
|
||||
_PyTime_t ms;
|
||||
PyTime_t ms;
|
||||
#else
|
||||
fd_set fds, efds;
|
||||
struct timeval tv, *tvp;
|
||||
|
@ -888,10 +888,10 @@ sock_call_ex(PySocketSockObject *s,
|
|||
void *data,
|
||||
int connect,
|
||||
int *err,
|
||||
_PyTime_t timeout)
|
||||
PyTime_t timeout)
|
||||
{
|
||||
int has_timeout = (timeout > 0);
|
||||
_PyTime_t deadline = 0;
|
||||
PyTime_t deadline = 0;
|
||||
int deadline_initialized = 0;
|
||||
int res;
|
||||
|
||||
|
@ -905,7 +905,7 @@ sock_call_ex(PySocketSockObject *s,
|
|||
runs asynchronously. */
|
||||
if (has_timeout || connect) {
|
||||
if (has_timeout) {
|
||||
_PyTime_t interval;
|
||||
PyTime_t interval;
|
||||
|
||||
if (deadline_initialized) {
|
||||
/* recompute the timeout */
|
||||
|
@ -3011,13 +3011,13 @@ Returns True if socket is in blocking mode, or False if it\n\
|
|||
is in non-blocking mode.");
|
||||
|
||||
static int
|
||||
socket_parse_timeout(_PyTime_t *timeout, PyObject *timeout_obj)
|
||||
socket_parse_timeout(PyTime_t *timeout, PyObject *timeout_obj)
|
||||
{
|
||||
#ifdef MS_WINDOWS
|
||||
struct timeval tv;
|
||||
#endif
|
||||
#ifndef HAVE_POLL
|
||||
_PyTime_t ms;
|
||||
PyTime_t ms;
|
||||
#endif
|
||||
int overflow = 0;
|
||||
|
||||
|
@ -3060,7 +3060,7 @@ socket_parse_timeout(_PyTime_t *timeout, PyObject *timeout_obj)
|
|||
static PyObject *
|
||||
sock_settimeout(PySocketSockObject *s, PyObject *arg)
|
||||
{
|
||||
_PyTime_t timeout;
|
||||
PyTime_t timeout;
|
||||
|
||||
if (socket_parse_timeout(&timeout, arg) < 0)
|
||||
return NULL;
|
||||
|
@ -4382,8 +4382,8 @@ sock_sendall(PySocketSockObject *s, PyObject *args)
|
|||
Py_buffer pbuf;
|
||||
struct sock_send ctx;
|
||||
int has_timeout = (s->sock_timeout > 0);
|
||||
_PyTime_t timeout = s->sock_timeout;
|
||||
_PyTime_t deadline = 0;
|
||||
PyTime_t timeout = s->sock_timeout;
|
||||
PyTime_t deadline = 0;
|
||||
int deadline_initialized = 0;
|
||||
PyObject *res = NULL;
|
||||
|
||||
|
@ -6931,7 +6931,7 @@ When the socket module is first imported, the default is None.");
|
|||
static PyObject *
|
||||
socket_setdefaulttimeout(PyObject *self, PyObject *arg)
|
||||
{
|
||||
_PyTime_t timeout;
|
||||
PyTime_t timeout;
|
||||
|
||||
if (socket_parse_timeout(&timeout, arg) < 0)
|
||||
return NULL;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Socket module header file */
|
||||
|
||||
#include "pycore_time.h" // _PyTime_t
|
||||
#include "pycore_time.h" // PyTime_t
|
||||
|
||||
/* Includes needed for the sockaddr_* symbols below */
|
||||
#ifndef MS_WINDOWS
|
||||
|
@ -324,7 +324,7 @@ typedef struct {
|
|||
PyObject *(*errorhandler)(void); /* Error handler; checks
|
||||
errno, returns NULL and
|
||||
sets a Python exception */
|
||||
_PyTime_t sock_timeout; /* Operation timeout in seconds;
|
||||
PyTime_t sock_timeout; /* Operation timeout in seconds;
|
||||
0.0 means non-blocking */
|
||||
struct _socket_state *state;
|
||||
} PySocketSockObject;
|
||||
|
|
|
@ -70,7 +70,7 @@ module time
|
|||
|
||||
|
||||
/* Forward declarations */
|
||||
static int pysleep(_PyTime_t timeout);
|
||||
static int pysleep(PyTime_t timeout);
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
@ -95,7 +95,7 @@ get_time_state(PyObject *module)
|
|||
|
||||
|
||||
static PyObject*
|
||||
_PyFloat_FromPyTime(_PyTime_t t)
|
||||
_PyFloat_FromPyTime(PyTime_t t)
|
||||
{
|
||||
double d = _PyTime_AsSecondsDouble(t);
|
||||
return PyFloat_FromDouble(d);
|
||||
|
@ -103,7 +103,7 @@ _PyFloat_FromPyTime(_PyTime_t t)
|
|||
|
||||
|
||||
static int
|
||||
get_system_time(_PyTime_t *t)
|
||||
get_system_time(PyTime_t *t)
|
||||
{
|
||||
// Avoid _PyTime_GetSystemClock() which silently ignores errors.
|
||||
return _PyTime_GetSystemClockWithInfo(t, NULL);
|
||||
|
@ -113,7 +113,7 @@ get_system_time(_PyTime_t *t)
|
|||
static PyObject *
|
||||
time_time(PyObject *self, PyObject *unused)
|
||||
{
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
if (get_system_time(&t) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ Fractions of a second may be present if the system clock provides them.");
|
|||
static PyObject *
|
||||
time_time_ns(PyObject *self, PyObject *unused)
|
||||
{
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
if (get_system_time(&t) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ Return the current time in nanoseconds since the Epoch.");
|
|||
#endif
|
||||
|
||||
static int
|
||||
py_clock(time_module_state *state, _PyTime_t *tp, _Py_clock_info_t *info)
|
||||
py_clock(time_module_state *state, PyTime_t *tp, _Py_clock_info_t *info)
|
||||
{
|
||||
_PyTimeFraction *base = &state->clock_base;
|
||||
|
||||
|
@ -171,7 +171,7 @@ py_clock(time_module_state *state, _PyTime_t *tp, _Py_clock_info_t *info)
|
|||
"or its value cannot be represented");
|
||||
return -1;
|
||||
}
|
||||
_PyTime_t ns = _PyTimeFraction_Mul(ticks, base);
|
||||
PyTime_t ns = _PyTimeFraction_Mul(ticks, base);
|
||||
*tp = _PyTime_FromNanoseconds(ns);
|
||||
return 0;
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ time_clock_gettime_ns_impl(PyObject *module, clockid_t clk_id)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
if (_PyTime_FromTimespec(&t, &ts) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ time_clock_settime(PyObject *self, PyObject *args)
|
|||
{
|
||||
int clk_id;
|
||||
PyObject *obj;
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
struct timespec tp;
|
||||
int ret;
|
||||
|
||||
|
@ -307,7 +307,7 @@ time_clock_settime_ns(PyObject *self, PyObject *args)
|
|||
{
|
||||
int clk_id;
|
||||
PyObject *obj;
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
struct timespec ts;
|
||||
int ret;
|
||||
|
||||
|
@ -402,7 +402,7 @@ time_sleep(PyObject *self, PyObject *timeout_obj)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
_PyTime_t timeout;
|
||||
PyTime_t timeout;
|
||||
if (_PyTime_FromSecondsObject(&timeout, timeout_obj, _PyTime_ROUND_TIMEOUT))
|
||||
return NULL;
|
||||
if (timeout < 0) {
|
||||
|
@ -1156,7 +1156,7 @@ should not be relied on.");
|
|||
|
||||
|
||||
static int
|
||||
get_monotonic(_PyTime_t *t)
|
||||
get_monotonic(PyTime_t *t)
|
||||
{
|
||||
// Avoid _PyTime_GetMonotonicClock() which silently ignores errors.
|
||||
return _PyTime_GetMonotonicClockWithInfo(t, NULL);
|
||||
|
@ -1166,7 +1166,7 @@ get_monotonic(_PyTime_t *t)
|
|||
static PyObject *
|
||||
time_monotonic(PyObject *self, PyObject *unused)
|
||||
{
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
if (get_monotonic(&t) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1181,7 +1181,7 @@ Monotonic clock, cannot go backward.");
|
|||
static PyObject *
|
||||
time_monotonic_ns(PyObject *self, PyObject *unused)
|
||||
{
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
if (get_monotonic(&t) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1195,7 +1195,7 @@ Monotonic clock, cannot go backward, as nanoseconds.");
|
|||
|
||||
|
||||
static int
|
||||
get_perf_counter(_PyTime_t *t)
|
||||
get_perf_counter(PyTime_t *t)
|
||||
{
|
||||
// Avoid _PyTime_GetPerfCounter() which silently ignores errors.
|
||||
return _PyTime_GetPerfCounterWithInfo(t, NULL);
|
||||
|
@ -1205,7 +1205,7 @@ get_perf_counter(_PyTime_t *t)
|
|||
static PyObject *
|
||||
time_perf_counter(PyObject *self, PyObject *unused)
|
||||
{
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
if (get_perf_counter(&t) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1221,7 +1221,7 @@ Performance counter for benchmarking.");
|
|||
static PyObject *
|
||||
time_perf_counter_ns(PyObject *self, PyObject *unused)
|
||||
{
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
if (get_perf_counter(&t) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1236,7 +1236,7 @@ Performance counter for benchmarking as nanoseconds.");
|
|||
|
||||
#ifdef HAVE_TIMES
|
||||
static int
|
||||
process_time_times(time_module_state *state, _PyTime_t *tp,
|
||||
process_time_times(time_module_state *state, PyTime_t *tp,
|
||||
_Py_clock_info_t *info)
|
||||
{
|
||||
_PyTimeFraction *base = &state->times_base;
|
||||
|
@ -1253,7 +1253,7 @@ process_time_times(time_module_state *state, _PyTime_t *tp,
|
|||
info->adjustable = 0;
|
||||
}
|
||||
|
||||
_PyTime_t ns;
|
||||
PyTime_t ns;
|
||||
ns = _PyTimeFraction_Mul(process.tms_utime, base);
|
||||
ns += _PyTimeFraction_Mul(process.tms_stime, base);
|
||||
*tp = _PyTime_FromNanoseconds(ns);
|
||||
|
@ -1263,14 +1263,14 @@ process_time_times(time_module_state *state, _PyTime_t *tp,
|
|||
|
||||
|
||||
static int
|
||||
py_process_time(time_module_state *state, _PyTime_t *tp,
|
||||
py_process_time(time_module_state *state, PyTime_t *tp,
|
||||
_Py_clock_info_t *info)
|
||||
{
|
||||
#if defined(MS_WINDOWS)
|
||||
HANDLE process;
|
||||
FILETIME creation_time, exit_time, kernel_time, user_time;
|
||||
ULARGE_INTEGER large;
|
||||
_PyTime_t ktime, utime, t;
|
||||
PyTime_t ktime, utime, t;
|
||||
BOOL ok;
|
||||
|
||||
process = GetCurrentProcess();
|
||||
|
@ -1343,7 +1343,7 @@ py_process_time(time_module_state *state, _PyTime_t *tp,
|
|||
struct rusage ru;
|
||||
|
||||
if (getrusage(RUSAGE_SELF, &ru) == 0) {
|
||||
_PyTime_t utime, stime;
|
||||
PyTime_t utime, stime;
|
||||
|
||||
if (info) {
|
||||
info->implementation = "getrusage(RUSAGE_SELF)";
|
||||
|
@ -1359,7 +1359,7 @@ py_process_time(time_module_state *state, _PyTime_t *tp,
|
|||
return -1;
|
||||
}
|
||||
|
||||
_PyTime_t total = utime + stime;
|
||||
PyTime_t total = utime + stime;
|
||||
*tp = total;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1386,7 +1386,7 @@ static PyObject *
|
|||
time_process_time(PyObject *module, PyObject *unused)
|
||||
{
|
||||
time_module_state *state = get_time_state(module);
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
if (py_process_time(state, &t, NULL) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1402,7 +1402,7 @@ static PyObject *
|
|||
time_process_time_ns(PyObject *module, PyObject *unused)
|
||||
{
|
||||
time_module_state *state = get_time_state(module);
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
if (py_process_time(state, &t, NULL) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1419,12 +1419,12 @@ sum of the kernel and user-space CPU time.");
|
|||
#if defined(MS_WINDOWS)
|
||||
#define HAVE_THREAD_TIME
|
||||
static int
|
||||
_PyTime_GetThreadTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
|
||||
_PyTime_GetThreadTimeWithInfo(PyTime_t *tp, _Py_clock_info_t *info)
|
||||
{
|
||||
HANDLE thread;
|
||||
FILETIME creation_time, exit_time, kernel_time, user_time;
|
||||
ULARGE_INTEGER large;
|
||||
_PyTime_t ktime, utime, t;
|
||||
PyTime_t ktime, utime, t;
|
||||
BOOL ok;
|
||||
|
||||
thread = GetCurrentThread();
|
||||
|
@ -1459,7 +1459,7 @@ _PyTime_GetThreadTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
|
|||
#elif defined(_AIX)
|
||||
#define HAVE_THREAD_TIME
|
||||
static int
|
||||
_PyTime_GetThreadTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
|
||||
_PyTime_GetThreadTimeWithInfo(PyTime_t *tp, _Py_clock_info_t *info)
|
||||
{
|
||||
/* bpo-40192: On AIX, thread_cputime() is preferred: it has nanosecond
|
||||
resolution, whereas clock_gettime(CLOCK_THREAD_CPUTIME_ID)
|
||||
|
@ -1483,7 +1483,7 @@ _PyTime_GetThreadTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
|
|||
#elif defined(__sun) && defined(__SVR4)
|
||||
#define HAVE_THREAD_TIME
|
||||
static int
|
||||
_PyTime_GetThreadTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
|
||||
_PyTime_GetThreadTimeWithInfo(PyTime_t *tp, _Py_clock_info_t *info)
|
||||
{
|
||||
/* bpo-35455: On Solaris, CLOCK_THREAD_CPUTIME_ID clock is not always
|
||||
available; use gethrvtime() to substitute this functionality. */
|
||||
|
@ -1504,7 +1504,7 @@ _PyTime_GetThreadTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
|
|||
|
||||
#if defined(__APPLE__) && defined(__has_attribute) && __has_attribute(availability)
|
||||
static int
|
||||
_PyTime_GetThreadTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
|
||||
_PyTime_GetThreadTimeWithInfo(PyTime_t *tp, _Py_clock_info_t *info)
|
||||
__attribute__((availability(macos, introduced=10.12)))
|
||||
__attribute__((availability(ios, introduced=10.0)))
|
||||
__attribute__((availability(tvos, introduced=10.0)))
|
||||
|
@ -1512,7 +1512,7 @@ _PyTime_GetThreadTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
|
|||
#endif
|
||||
|
||||
static int
|
||||
_PyTime_GetThreadTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
|
||||
_PyTime_GetThreadTimeWithInfo(PyTime_t *tp, _Py_clock_info_t *info)
|
||||
{
|
||||
struct timespec ts;
|
||||
const clockid_t clk_id = CLOCK_THREAD_CPUTIME_ID;
|
||||
|
@ -1554,7 +1554,7 @@ _PyTime_GetThreadTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
|
|||
static PyObject *
|
||||
time_thread_time(PyObject *self, PyObject *unused)
|
||||
{
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
if (_PyTime_GetThreadTimeWithInfo(&t, NULL) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1569,7 +1569,7 @@ Thread time for profiling: sum of the kernel and user-space CPU time.");
|
|||
static PyObject *
|
||||
time_thread_time_ns(PyObject *self, PyObject *unused)
|
||||
{
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
if (_PyTime_GetThreadTimeWithInfo(&t, NULL) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1595,7 +1595,7 @@ time_get_clock_info(PyObject *module, PyObject *args)
|
|||
char *name;
|
||||
_Py_clock_info_t info;
|
||||
PyObject *obj = NULL, *dict, *ns;
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:get_clock_info", &name)) {
|
||||
return NULL;
|
||||
|
@ -2174,7 +2174,7 @@ PyInit_time(void)
|
|||
// On error, raise an exception and return -1.
|
||||
// On success, return 0.
|
||||
static int
|
||||
pysleep(_PyTime_t timeout)
|
||||
pysleep(PyTime_t timeout)
|
||||
{
|
||||
assert(timeout >= 0);
|
||||
|
||||
|
@ -2186,7 +2186,7 @@ pysleep(_PyTime_t timeout)
|
|||
#else
|
||||
struct timeval timeout_tv;
|
||||
#endif
|
||||
_PyTime_t deadline, monotonic;
|
||||
PyTime_t deadline, monotonic;
|
||||
int err = 0;
|
||||
|
||||
if (get_monotonic(&monotonic) < 0) {
|
||||
|
@ -2255,7 +2255,7 @@ pysleep(_PyTime_t timeout)
|
|||
|
||||
return 0;
|
||||
#else // MS_WINDOWS
|
||||
_PyTime_t timeout_100ns = _PyTime_As100Nanoseconds(timeout,
|
||||
PyTime_t timeout_100ns = _PyTime_As100Nanoseconds(timeout,
|
||||
_PyTime_ROUND_CEILING);
|
||||
|
||||
// Maintain Windows Sleep() semantics for time.sleep(0)
|
||||
|
|
|
@ -1285,7 +1285,7 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason)
|
|||
PyGC_Head unreachable; /* non-problematic unreachable trash */
|
||||
PyGC_Head finalizers; /* objects with, & reachable from, __del__ */
|
||||
PyGC_Head *gc;
|
||||
_PyTime_t t1 = 0; /* initialize to prevent a compiler warning */
|
||||
PyTime_t t1 = 0; /* initialize to prevent a compiler warning */
|
||||
GCState *gcstate = &tstate->interp->gc;
|
||||
|
||||
// gc_collect_main() must not be called before _PyGC_Init
|
||||
|
|
|
@ -1071,7 +1071,7 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason)
|
|||
int i;
|
||||
Py_ssize_t m = 0; /* # objects collected */
|
||||
Py_ssize_t n = 0; /* # unreachable objects that couldn't be collected */
|
||||
_PyTime_t t1 = 0; /* initialize to prevent a compiler warning */
|
||||
PyTime_t t1 = 0; /* initialize to prevent a compiler warning */
|
||||
GCState *gcstate = &tstate->interp->gc;
|
||||
|
||||
// gc_collect_main() must not be called before _PyGC_Init
|
||||
|
|
|
@ -2719,7 +2719,7 @@ import_find_and_load(PyThreadState *tstate, PyObject *abs_name)
|
|||
#define import_level FIND_AND_LOAD(interp).import_level
|
||||
#define accumulated FIND_AND_LOAD(interp).accumulated
|
||||
|
||||
_PyTime_t t1 = 0, accumulated_copy = accumulated;
|
||||
PyTime_t t1 = 0, accumulated_copy = accumulated;
|
||||
|
||||
PyObject *sys_path = PySys_GetObject("path");
|
||||
PyObject *sys_meta_path = PySys_GetObject("meta_path");
|
||||
|
@ -2762,7 +2762,7 @@ import_find_and_load(PyThreadState *tstate, PyObject *abs_name)
|
|||
mod != NULL);
|
||||
|
||||
if (import_time) {
|
||||
_PyTime_t cum = _PyTime_GetPerfCounter() - t1;
|
||||
PyTime_t cum = _PyTime_GetPerfCounter() - t1;
|
||||
|
||||
import_level--;
|
||||
fprintf(stderr, "import time: %9ld | %10ld | %*s%s\n",
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
// If a thread waits on a lock for longer than TIME_TO_BE_FAIR_NS (1 ms), then
|
||||
// the unlocking thread directly hands off ownership of the lock. This avoids
|
||||
// starvation.
|
||||
static const _PyTime_t TIME_TO_BE_FAIR_NS = 1000*1000;
|
||||
static const PyTime_t TIME_TO_BE_FAIR_NS = 1000*1000;
|
||||
|
||||
// Spin for a bit before parking the thread. This is only enabled for
|
||||
// `--disable-gil` builds because it is unlikely to be helpful if the GIL is
|
||||
|
@ -30,7 +30,7 @@ static const int MAX_SPIN_COUNT = 0;
|
|||
struct mutex_entry {
|
||||
// The time after which the unlocking thread should hand off lock ownership
|
||||
// directly to the waiting thread. Written by the waiting thread.
|
||||
_PyTime_t time_to_be_fair;
|
||||
PyTime_t time_to_be_fair;
|
||||
|
||||
// Set to 1 if the lock was handed off. Written by the unlocking thread.
|
||||
int handed_off;
|
||||
|
@ -53,7 +53,7 @@ _PyMutex_LockSlow(PyMutex *m)
|
|||
}
|
||||
|
||||
PyLockStatus
|
||||
_PyMutex_LockTimed(PyMutex *m, _PyTime_t timeout, _PyLockFlags flags)
|
||||
_PyMutex_LockTimed(PyMutex *m, PyTime_t timeout, _PyLockFlags flags)
|
||||
{
|
||||
uint8_t v = _Py_atomic_load_uint8_relaxed(&m->v);
|
||||
if ((v & _Py_LOCKED) == 0) {
|
||||
|
@ -65,8 +65,8 @@ _PyMutex_LockTimed(PyMutex *m, _PyTime_t timeout, _PyLockFlags flags)
|
|||
return PY_LOCK_FAILURE;
|
||||
}
|
||||
|
||||
_PyTime_t now = _PyTime_GetMonotonicClock();
|
||||
_PyTime_t endtime = 0;
|
||||
PyTime_t now = _PyTime_GetMonotonicClock();
|
||||
PyTime_t endtime = 0;
|
||||
if (timeout > 0) {
|
||||
endtime = _PyTime_Add(now, timeout);
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ mutex_unpark(PyMutex *m, struct mutex_entry *entry, int has_more_waiters)
|
|||
{
|
||||
uint8_t v = 0;
|
||||
if (entry) {
|
||||
_PyTime_t now = _PyTime_GetMonotonicClock();
|
||||
PyTime_t now = _PyTime_GetMonotonicClock();
|
||||
int should_be_fair = now > entry->time_to_be_fair;
|
||||
|
||||
entry->handed_off = should_be_fair;
|
||||
|
@ -274,7 +274,7 @@ PyEvent_Wait(PyEvent *evt)
|
|||
}
|
||||
|
||||
int
|
||||
PyEvent_WaitTimed(PyEvent *evt, _PyTime_t timeout_ns)
|
||||
PyEvent_WaitTimed(PyEvent *evt, PyTime_t timeout_ns)
|
||||
{
|
||||
for (;;) {
|
||||
uint8_t v = _Py_atomic_load_uint8(&evt->v);
|
||||
|
|
|
@ -91,7 +91,7 @@ _PySemaphore_Destroy(_PySemaphore *sema)
|
|||
}
|
||||
|
||||
static int
|
||||
_PySemaphore_PlatformWait(_PySemaphore *sema, _PyTime_t timeout)
|
||||
_PySemaphore_PlatformWait(_PySemaphore *sema, PyTime_t timeout)
|
||||
{
|
||||
int res;
|
||||
#if defined(MS_WINDOWS)
|
||||
|
@ -119,13 +119,13 @@ _PySemaphore_PlatformWait(_PySemaphore *sema, _PyTime_t timeout)
|
|||
struct timespec ts;
|
||||
|
||||
#if defined(CLOCK_MONOTONIC) && defined(HAVE_SEM_CLOCKWAIT)
|
||||
_PyTime_t deadline = _PyTime_Add(_PyTime_GetMonotonicClock(), timeout);
|
||||
PyTime_t deadline = _PyTime_Add(_PyTime_GetMonotonicClock(), timeout);
|
||||
|
||||
_PyTime_AsTimespec_clamp(deadline, &ts);
|
||||
|
||||
err = sem_clockwait(&sema->platform_sem, CLOCK_MONOTONIC, &ts);
|
||||
#else
|
||||
_PyTime_t deadline = _PyTime_Add(_PyTime_GetSystemClock(), timeout);
|
||||
PyTime_t deadline = _PyTime_Add(_PyTime_GetSystemClock(), timeout);
|
||||
|
||||
_PyTime_AsTimespec_clamp(deadline, &ts);
|
||||
|
||||
|
@ -162,7 +162,7 @@ _PySemaphore_PlatformWait(_PySemaphore *sema, _PyTime_t timeout)
|
|||
_PyTime_AsTimespec_clamp(timeout, &ts);
|
||||
err = pthread_cond_timedwait_relative_np(&sema->cond, &sema->mutex, &ts);
|
||||
#else
|
||||
_PyTime_t deadline = _PyTime_Add(_PyTime_GetSystemClock(), timeout);
|
||||
PyTime_t deadline = _PyTime_Add(_PyTime_GetSystemClock(), timeout);
|
||||
_PyTime_AsTimespec_clamp(deadline, &ts);
|
||||
|
||||
err = pthread_cond_timedwait(&sema->cond, &sema->mutex, &ts);
|
||||
|
@ -188,7 +188,7 @@ _PySemaphore_PlatformWait(_PySemaphore *sema, _PyTime_t timeout)
|
|||
}
|
||||
|
||||
int
|
||||
_PySemaphore_Wait(_PySemaphore *sema, _PyTime_t timeout, int detach)
|
||||
_PySemaphore_Wait(_PySemaphore *sema, PyTime_t timeout, int detach)
|
||||
{
|
||||
PyThreadState *tstate = NULL;
|
||||
if (detach) {
|
||||
|
@ -283,7 +283,7 @@ atomic_memcmp(const void *addr, const void *expected, size_t addr_size)
|
|||
|
||||
int
|
||||
_PyParkingLot_Park(const void *addr, const void *expected, size_t size,
|
||||
_PyTime_t timeout_ns, void *park_arg, int detach)
|
||||
PyTime_t timeout_ns, void *park_arg, int detach)
|
||||
{
|
||||
struct wait_entry wait = {
|
||||
.park_arg = park_arg,
|
||||
|
|
|
@ -2072,7 +2072,7 @@ stop_the_world(struct _stoptheworld_state *stw)
|
|||
break;
|
||||
}
|
||||
|
||||
_PyTime_t wait_ns = 1000*1000; // 1ms (arbitrary, may need tuning)
|
||||
PyTime_t wait_ns = 1000*1000; // 1ms (arbitrary, may need tuning)
|
||||
if (PyEvent_WaitTimed(&stw->stop_event, wait_ns)) {
|
||||
assert(stw->thread_countdown == 0);
|
||||
break;
|
||||
|
|
304
Python/pytime.c
304
Python/pytime.c
|
@ -1,5 +1,5 @@
|
|||
#include "Python.h"
|
||||
#include "pycore_time.h" // _PyTime_t
|
||||
#include "pycore_time.h" // PyTime_t
|
||||
|
||||
#include <time.h> // gmtime_r()
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
|
@ -51,18 +51,18 @@
|
|||
#endif
|
||||
|
||||
#if PyTime_MIN + PyTime_MAX != -1
|
||||
# error "_PyTime_t is not a two's complement integer type"
|
||||
# error "PyTime_t is not a two's complement integer type"
|
||||
#endif
|
||||
|
||||
|
||||
static _PyTime_t
|
||||
_PyTime_GCD(_PyTime_t x, _PyTime_t y)
|
||||
static PyTime_t
|
||||
_PyTime_GCD(PyTime_t x, PyTime_t y)
|
||||
{
|
||||
// Euclidean algorithm
|
||||
assert(x >= 1);
|
||||
assert(y >= 1);
|
||||
while (y != 0) {
|
||||
_PyTime_t tmp = y;
|
||||
PyTime_t tmp = y;
|
||||
y = x % y;
|
||||
x = tmp;
|
||||
}
|
||||
|
@ -72,13 +72,13 @@ _PyTime_GCD(_PyTime_t x, _PyTime_t y)
|
|||
|
||||
|
||||
int
|
||||
_PyTimeFraction_Set(_PyTimeFraction *frac, _PyTime_t numer, _PyTime_t denom)
|
||||
_PyTimeFraction_Set(_PyTimeFraction *frac, PyTime_t numer, PyTime_t denom)
|
||||
{
|
||||
if (numer < 1 || denom < 1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
_PyTime_t gcd = _PyTime_GCD(numer, denom);
|
||||
PyTime_t gcd = _PyTime_GCD(numer, denom);
|
||||
frac->numer = numer / gcd;
|
||||
frac->denom = denom / gcd;
|
||||
return 0;
|
||||
|
@ -104,29 +104,29 @@ static void
|
|||
pytime_overflow(void)
|
||||
{
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"timestamp too large to convert to C _PyTime_t");
|
||||
"timestamp too large to convert to C PyTime_t");
|
||||
}
|
||||
|
||||
|
||||
static inline _PyTime_t
|
||||
pytime_from_nanoseconds(_PyTime_t t)
|
||||
static inline PyTime_t
|
||||
pytime_from_nanoseconds(PyTime_t t)
|
||||
{
|
||||
// _PyTime_t is a number of nanoseconds
|
||||
// PyTime_t is a number of nanoseconds
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
static inline _PyTime_t
|
||||
pytime_as_nanoseconds(_PyTime_t t)
|
||||
static inline PyTime_t
|
||||
pytime_as_nanoseconds(PyTime_t t)
|
||||
{
|
||||
// _PyTime_t is a number of nanoseconds: see pytime_from_nanoseconds()
|
||||
// PyTime_t is a number of nanoseconds: see pytime_from_nanoseconds()
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
// Compute t1 + t2. Clamp to [PyTime_MIN; PyTime_MAX] on overflow.
|
||||
static inline int
|
||||
pytime_add(_PyTime_t *t1, _PyTime_t t2)
|
||||
pytime_add(PyTime_t *t1, PyTime_t t2)
|
||||
{
|
||||
if (t2 > 0 && *t1 > PyTime_MAX - t2) {
|
||||
*t1 = PyTime_MAX;
|
||||
|
@ -143,8 +143,8 @@ pytime_add(_PyTime_t *t1, _PyTime_t t2)
|
|||
}
|
||||
|
||||
|
||||
_PyTime_t
|
||||
_PyTime_Add(_PyTime_t t1, _PyTime_t t2)
|
||||
PyTime_t
|
||||
_PyTime_Add(PyTime_t t1, PyTime_t t2)
|
||||
{
|
||||
(void)pytime_add(&t1, t2);
|
||||
return t1;
|
||||
|
@ -152,7 +152,7 @@ _PyTime_Add(_PyTime_t t1, _PyTime_t t2)
|
|||
|
||||
|
||||
static inline int
|
||||
pytime_mul_check_overflow(_PyTime_t a, _PyTime_t b)
|
||||
pytime_mul_check_overflow(PyTime_t a, PyTime_t b)
|
||||
{
|
||||
if (b != 0) {
|
||||
assert(b > 0);
|
||||
|
@ -166,7 +166,7 @@ pytime_mul_check_overflow(_PyTime_t a, _PyTime_t b)
|
|||
|
||||
// Compute t * k. Clamp to [PyTime_MIN; PyTime_MAX] on overflow.
|
||||
static inline int
|
||||
pytime_mul(_PyTime_t *t, _PyTime_t k)
|
||||
pytime_mul(PyTime_t *t, PyTime_t k)
|
||||
{
|
||||
assert(k >= 0);
|
||||
if (pytime_mul_check_overflow(*t, k)) {
|
||||
|
@ -181,19 +181,19 @@ pytime_mul(_PyTime_t *t, _PyTime_t k)
|
|||
|
||||
|
||||
// Compute t * k. Clamp to [PyTime_MIN; PyTime_MAX] on overflow.
|
||||
static inline _PyTime_t
|
||||
_PyTime_Mul(_PyTime_t t, _PyTime_t k)
|
||||
static inline PyTime_t
|
||||
_PyTime_Mul(PyTime_t t, PyTime_t k)
|
||||
{
|
||||
(void)pytime_mul(&t, k);
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
_PyTime_t
|
||||
_PyTimeFraction_Mul(_PyTime_t ticks, const _PyTimeFraction *frac)
|
||||
PyTime_t
|
||||
_PyTimeFraction_Mul(PyTime_t ticks, const _PyTimeFraction *frac)
|
||||
{
|
||||
const _PyTime_t mul = frac->numer;
|
||||
const _PyTime_t div = frac->denom;
|
||||
const PyTime_t mul = frac->numer;
|
||||
const PyTime_t div = frac->denom;
|
||||
|
||||
if (div == 1) {
|
||||
// Fast-path taken by mach_absolute_time() with 1/1 time base.
|
||||
|
@ -205,7 +205,7 @@ _PyTimeFraction_Mul(_PyTime_t ticks, const _PyTimeFraction *frac)
|
|||
|
||||
(ticks * mul) / div == (ticks / div) * mul + (ticks % div) * mul / div
|
||||
*/
|
||||
_PyTime_t intpart, remaining;
|
||||
PyTime_t intpart, remaining;
|
||||
intpart = ticks / div;
|
||||
ticks %= div;
|
||||
remaining = _PyTime_Mul(ticks, mul) / div;
|
||||
|
@ -247,17 +247,17 @@ _PyLong_FromTime_t(time_t t)
|
|||
}
|
||||
|
||||
|
||||
// Convert _PyTime_t to time_t.
|
||||
// Convert PyTime_t to time_t.
|
||||
// Return 0 on success. Return -1 and clamp the value on overflow.
|
||||
static int
|
||||
_PyTime_AsTime_t(_PyTime_t t, time_t *t2)
|
||||
_PyTime_AsTime_t(PyTime_t t, time_t *t2)
|
||||
{
|
||||
#if SIZEOF_TIME_T < _SIZEOF_PYTIME_T
|
||||
if ((_PyTime_t)PY_TIME_T_MAX < t) {
|
||||
if ((PyTime_t)PY_TIME_T_MAX < t) {
|
||||
*t2 = PY_TIME_T_MAX;
|
||||
return -1;
|
||||
}
|
||||
if (t < (_PyTime_t)PY_TIME_T_MIN) {
|
||||
if (t < (PyTime_t)PY_TIME_T_MIN) {
|
||||
*t2 = PY_TIME_T_MIN;
|
||||
return -1;
|
||||
}
|
||||
|
@ -268,17 +268,17 @@ _PyTime_AsTime_t(_PyTime_t t, time_t *t2)
|
|||
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
// Convert _PyTime_t to long.
|
||||
// Convert PyTime_t to long.
|
||||
// Return 0 on success. Return -1 and clamp the value on overflow.
|
||||
static int
|
||||
_PyTime_AsLong(_PyTime_t t, long *t2)
|
||||
_PyTime_AsLong(PyTime_t t, long *t2)
|
||||
{
|
||||
#if SIZEOF_LONG < _SIZEOF_PYTIME_T
|
||||
if ((_PyTime_t)LONG_MAX < t) {
|
||||
if ((PyTime_t)LONG_MAX < t) {
|
||||
*t2 = LONG_MAX;
|
||||
return -1;
|
||||
}
|
||||
if (t < (_PyTime_t)LONG_MIN) {
|
||||
if (t < (PyTime_t)LONG_MIN) {
|
||||
*t2 = LONG_MIN;
|
||||
return -1;
|
||||
}
|
||||
|
@ -453,16 +453,16 @@ _PyTime_ObjectToTimeval(PyObject *obj, time_t *sec, long *usec,
|
|||
}
|
||||
|
||||
|
||||
_PyTime_t
|
||||
PyTime_t
|
||||
_PyTime_FromSeconds(int seconds)
|
||||
{
|
||||
/* ensure that integer overflow cannot happen, int type should have 32
|
||||
bits, whereas _PyTime_t type has at least 64 bits (SEC_TO_NS takes 30
|
||||
bits, whereas PyTime_t type has at least 64 bits (SEC_TO_NS takes 30
|
||||
bits). */
|
||||
static_assert(INT_MAX <= PyTime_MAX / SEC_TO_NS, "_PyTime_t overflow");
|
||||
static_assert(INT_MIN >= PyTime_MIN / SEC_TO_NS, "_PyTime_t underflow");
|
||||
static_assert(INT_MAX <= PyTime_MAX / SEC_TO_NS, "PyTime_t overflow");
|
||||
static_assert(INT_MIN >= PyTime_MIN / SEC_TO_NS, "PyTime_t underflow");
|
||||
|
||||
_PyTime_t t = (_PyTime_t)seconds;
|
||||
PyTime_t t = (PyTime_t)seconds;
|
||||
assert((t >= 0 && t <= PyTime_MAX / SEC_TO_NS)
|
||||
|| (t < 0 && t >= PyTime_MIN / SEC_TO_NS));
|
||||
t *= SEC_TO_NS;
|
||||
|
@ -470,23 +470,23 @@ _PyTime_FromSeconds(int seconds)
|
|||
}
|
||||
|
||||
|
||||
_PyTime_t
|
||||
_PyTime_FromNanoseconds(_PyTime_t ns)
|
||||
PyTime_t
|
||||
_PyTime_FromNanoseconds(PyTime_t ns)
|
||||
{
|
||||
return pytime_from_nanoseconds(ns);
|
||||
}
|
||||
|
||||
|
||||
_PyTime_t
|
||||
_PyTime_FromMicrosecondsClamp(_PyTime_t us)
|
||||
PyTime_t
|
||||
_PyTime_FromMicrosecondsClamp(PyTime_t us)
|
||||
{
|
||||
_PyTime_t ns = _PyTime_Mul(us, US_TO_NS);
|
||||
PyTime_t ns = _PyTime_Mul(us, US_TO_NS);
|
||||
return pytime_from_nanoseconds(ns);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_PyTime_FromNanosecondsObject(_PyTime_t *tp, PyObject *obj)
|
||||
_PyTime_FromNanosecondsObject(PyTime_t *tp, PyObject *obj)
|
||||
{
|
||||
|
||||
if (!PyLong_Check(obj)) {
|
||||
|
@ -495,8 +495,8 @@ _PyTime_FromNanosecondsObject(_PyTime_t *tp, PyObject *obj)
|
|||
return -1;
|
||||
}
|
||||
|
||||
static_assert(sizeof(long long) == sizeof(_PyTime_t),
|
||||
"_PyTime_t is not long long");
|
||||
static_assert(sizeof(long long) == sizeof(PyTime_t),
|
||||
"PyTime_t is not long long");
|
||||
long long nsec = PyLong_AsLongLong(obj);
|
||||
if (nsec == -1 && PyErr_Occurred()) {
|
||||
if (PyErr_ExceptionMatches(PyExc_OverflowError)) {
|
||||
|
@ -505,7 +505,7 @@ _PyTime_FromNanosecondsObject(_PyTime_t *tp, PyObject *obj)
|
|||
return -1;
|
||||
}
|
||||
|
||||
_PyTime_t t = (_PyTime_t)nsec;
|
||||
PyTime_t t = (PyTime_t)nsec;
|
||||
*tp = pytime_from_nanoseconds(t);
|
||||
return 0;
|
||||
}
|
||||
|
@ -513,13 +513,13 @@ _PyTime_FromNanosecondsObject(_PyTime_t *tp, PyObject *obj)
|
|||
|
||||
#ifdef HAVE_CLOCK_GETTIME
|
||||
static int
|
||||
pytime_fromtimespec(_PyTime_t *tp, const struct timespec *ts, int raise_exc)
|
||||
pytime_fromtimespec(PyTime_t *tp, const struct timespec *ts, int raise_exc)
|
||||
{
|
||||
_PyTime_t t, tv_nsec;
|
||||
PyTime_t t, tv_nsec;
|
||||
|
||||
static_assert(sizeof(ts->tv_sec) <= sizeof(_PyTime_t),
|
||||
"timespec.tv_sec is larger than _PyTime_t");
|
||||
t = (_PyTime_t)ts->tv_sec;
|
||||
static_assert(sizeof(ts->tv_sec) <= sizeof(PyTime_t),
|
||||
"timespec.tv_sec is larger than PyTime_t");
|
||||
t = (PyTime_t)ts->tv_sec;
|
||||
|
||||
int res1 = pytime_mul(&t, SEC_TO_NS);
|
||||
|
||||
|
@ -536,7 +536,7 @@ pytime_fromtimespec(_PyTime_t *tp, const struct timespec *ts, int raise_exc)
|
|||
}
|
||||
|
||||
int
|
||||
_PyTime_FromTimespec(_PyTime_t *tp, const struct timespec *ts)
|
||||
_PyTime_FromTimespec(PyTime_t *tp, const struct timespec *ts)
|
||||
{
|
||||
return pytime_fromtimespec(tp, ts, 1);
|
||||
}
|
||||
|
@ -545,15 +545,15 @@ _PyTime_FromTimespec(_PyTime_t *tp, const struct timespec *ts)
|
|||
|
||||
#ifndef MS_WINDOWS
|
||||
static int
|
||||
pytime_fromtimeval(_PyTime_t *tp, struct timeval *tv, int raise_exc)
|
||||
pytime_fromtimeval(PyTime_t *tp, struct timeval *tv, int raise_exc)
|
||||
{
|
||||
static_assert(sizeof(tv->tv_sec) <= sizeof(_PyTime_t),
|
||||
"timeval.tv_sec is larger than _PyTime_t");
|
||||
_PyTime_t t = (_PyTime_t)tv->tv_sec;
|
||||
static_assert(sizeof(tv->tv_sec) <= sizeof(PyTime_t),
|
||||
"timeval.tv_sec is larger than PyTime_t");
|
||||
PyTime_t t = (PyTime_t)tv->tv_sec;
|
||||
|
||||
int res1 = pytime_mul(&t, SEC_TO_NS);
|
||||
|
||||
_PyTime_t usec = (_PyTime_t)tv->tv_usec * US_TO_NS;
|
||||
PyTime_t usec = (PyTime_t)tv->tv_usec * US_TO_NS;
|
||||
int res2 = pytime_add(&t, usec);
|
||||
|
||||
*tp = pytime_from_nanoseconds(t);
|
||||
|
@ -567,7 +567,7 @@ pytime_fromtimeval(_PyTime_t *tp, struct timeval *tv, int raise_exc)
|
|||
|
||||
|
||||
int
|
||||
_PyTime_FromTimeval(_PyTime_t *tp, struct timeval *tv)
|
||||
_PyTime_FromTimeval(PyTime_t *tp, struct timeval *tv)
|
||||
{
|
||||
return pytime_fromtimeval(tp, tv, 1);
|
||||
}
|
||||
|
@ -575,7 +575,7 @@ _PyTime_FromTimeval(_PyTime_t *tp, struct timeval *tv)
|
|||
|
||||
|
||||
static int
|
||||
pytime_from_double(_PyTime_t *tp, double value, _PyTime_round_t round,
|
||||
pytime_from_double(PyTime_t *tp, double value, _PyTime_round_t round,
|
||||
long unit_to_ns)
|
||||
{
|
||||
/* volatile avoids optimization changing how numbers are rounded */
|
||||
|
@ -591,7 +591,7 @@ pytime_from_double(_PyTime_t *tp, double value, _PyTime_round_t round,
|
|||
pytime_time_t_overflow();
|
||||
return -1;
|
||||
}
|
||||
_PyTime_t ns = (_PyTime_t)d;
|
||||
PyTime_t ns = (PyTime_t)d;
|
||||
|
||||
*tp = pytime_from_nanoseconds(ns);
|
||||
return 0;
|
||||
|
@ -599,7 +599,7 @@ pytime_from_double(_PyTime_t *tp, double value, _PyTime_round_t round,
|
|||
|
||||
|
||||
static int
|
||||
pytime_from_object(_PyTime_t *tp, PyObject *obj, _PyTime_round_t round,
|
||||
pytime_from_object(PyTime_t *tp, PyObject *obj, _PyTime_round_t round,
|
||||
long unit_to_ns)
|
||||
{
|
||||
if (PyFloat_Check(obj)) {
|
||||
|
@ -620,9 +620,9 @@ pytime_from_object(_PyTime_t *tp, PyObject *obj, _PyTime_round_t round,
|
|||
return -1;
|
||||
}
|
||||
|
||||
static_assert(sizeof(long long) <= sizeof(_PyTime_t),
|
||||
"_PyTime_t is smaller than long long");
|
||||
_PyTime_t ns = (_PyTime_t)sec;
|
||||
static_assert(sizeof(long long) <= sizeof(PyTime_t),
|
||||
"PyTime_t is smaller than long long");
|
||||
PyTime_t ns = (PyTime_t)sec;
|
||||
if (pytime_mul(&ns, unit_to_ns) < 0) {
|
||||
pytime_overflow();
|
||||
return -1;
|
||||
|
@ -635,14 +635,14 @@ pytime_from_object(_PyTime_t *tp, PyObject *obj, _PyTime_round_t round,
|
|||
|
||||
|
||||
int
|
||||
_PyTime_FromSecondsObject(_PyTime_t *tp, PyObject *obj, _PyTime_round_t round)
|
||||
_PyTime_FromSecondsObject(PyTime_t *tp, PyObject *obj, _PyTime_round_t round)
|
||||
{
|
||||
return pytime_from_object(tp, obj, round, SEC_TO_NS);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_PyTime_FromMillisecondsObject(_PyTime_t *tp, PyObject *obj, _PyTime_round_t round)
|
||||
_PyTime_FromMillisecondsObject(PyTime_t *tp, PyObject *obj, _PyTime_round_t round)
|
||||
{
|
||||
return pytime_from_object(tp, obj, round, MS_TO_NS);
|
||||
}
|
||||
|
@ -658,7 +658,7 @@ PyTime_AsSecondsDouble(PyTime_t t)
|
|||
if (ns % SEC_TO_NS == 0) {
|
||||
/* Divide using integers to avoid rounding issues on the integer part.
|
||||
1e-9 cannot be stored exactly in IEEE 64-bit. */
|
||||
_PyTime_t secs = ns / SEC_TO_NS;
|
||||
PyTime_t secs = ns / SEC_TO_NS;
|
||||
d = (double)secs;
|
||||
}
|
||||
else {
|
||||
|
@ -670,18 +670,18 @@ PyTime_AsSecondsDouble(PyTime_t t)
|
|||
|
||||
|
||||
PyObject *
|
||||
_PyTime_AsNanosecondsObject(_PyTime_t t)
|
||||
_PyTime_AsNanosecondsObject(PyTime_t t)
|
||||
{
|
||||
_PyTime_t ns = pytime_as_nanoseconds(t);
|
||||
static_assert(sizeof(long long) >= sizeof(_PyTime_t),
|
||||
"_PyTime_t is larger than long long");
|
||||
PyTime_t ns = pytime_as_nanoseconds(t);
|
||||
static_assert(sizeof(long long) >= sizeof(PyTime_t),
|
||||
"PyTime_t is larger than long long");
|
||||
return PyLong_FromLongLong((long long)ns);
|
||||
}
|
||||
|
||||
_PyTime_t
|
||||
PyTime_t
|
||||
_PyTime_FromSecondsDouble(double seconds, _PyTime_round_t round)
|
||||
{
|
||||
_PyTime_t tp;
|
||||
PyTime_t tp;
|
||||
if(pytime_from_double(&tp, seconds, round, SEC_TO_NS) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -689,14 +689,14 @@ _PyTime_FromSecondsDouble(double seconds, _PyTime_round_t round)
|
|||
}
|
||||
|
||||
|
||||
static _PyTime_t
|
||||
pytime_divide_round_up(const _PyTime_t t, const _PyTime_t k)
|
||||
static PyTime_t
|
||||
pytime_divide_round_up(const PyTime_t t, const PyTime_t k)
|
||||
{
|
||||
assert(k > 1);
|
||||
if (t >= 0) {
|
||||
// Don't use (t + k - 1) / k to avoid integer overflow
|
||||
// if t is equal to PyTime_MAX
|
||||
_PyTime_t q = t / k;
|
||||
PyTime_t q = t / k;
|
||||
if (t % k) {
|
||||
q += 1;
|
||||
}
|
||||
|
@ -705,7 +705,7 @@ pytime_divide_round_up(const _PyTime_t t, const _PyTime_t k)
|
|||
else {
|
||||
// Don't use (t - (k - 1)) / k to avoid integer overflow
|
||||
// if t is equals to PyTime_MIN.
|
||||
_PyTime_t q = t / k;
|
||||
PyTime_t q = t / k;
|
||||
if (t % k) {
|
||||
q -= 1;
|
||||
}
|
||||
|
@ -714,15 +714,15 @@ pytime_divide_round_up(const _PyTime_t t, const _PyTime_t k)
|
|||
}
|
||||
|
||||
|
||||
static _PyTime_t
|
||||
pytime_divide(const _PyTime_t t, const _PyTime_t k,
|
||||
static PyTime_t
|
||||
pytime_divide(const PyTime_t t, const PyTime_t k,
|
||||
const _PyTime_round_t round)
|
||||
{
|
||||
assert(k > 1);
|
||||
if (round == _PyTime_ROUND_HALF_EVEN) {
|
||||
_PyTime_t x = t / k;
|
||||
_PyTime_t r = t % k;
|
||||
_PyTime_t abs_r = Py_ABS(r);
|
||||
PyTime_t x = t / k;
|
||||
PyTime_t r = t % k;
|
||||
PyTime_t abs_r = Py_ABS(r);
|
||||
if (abs_r > k / 2 || (abs_r == k / 2 && (Py_ABS(x) & 1))) {
|
||||
if (t >= 0) {
|
||||
x++;
|
||||
|
@ -761,12 +761,12 @@ pytime_divide(const _PyTime_t t, const _PyTime_t k,
|
|||
// Return 0 on success.
|
||||
// Return -1 on underflow and store (PyTime_MIN, 0) in (pq, pr).
|
||||
static int
|
||||
pytime_divmod(const _PyTime_t t, const _PyTime_t k,
|
||||
_PyTime_t *pq, _PyTime_t *pr)
|
||||
pytime_divmod(const PyTime_t t, const PyTime_t k,
|
||||
PyTime_t *pq, PyTime_t *pr)
|
||||
{
|
||||
assert(k > 1);
|
||||
_PyTime_t q = t / k;
|
||||
_PyTime_t r = t % k;
|
||||
PyTime_t q = t / k;
|
||||
PyTime_t r = t % k;
|
||||
if (r < 0) {
|
||||
if (q == PyTime_MIN) {
|
||||
*pq = PyTime_MIN;
|
||||
|
@ -785,39 +785,39 @@ pytime_divmod(const _PyTime_t t, const _PyTime_t k,
|
|||
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
_PyTime_t
|
||||
_PyTime_As100Nanoseconds(_PyTime_t t, _PyTime_round_t round)
|
||||
PyTime_t
|
||||
_PyTime_As100Nanoseconds(PyTime_t t, _PyTime_round_t round)
|
||||
{
|
||||
_PyTime_t ns = pytime_as_nanoseconds(t);
|
||||
PyTime_t ns = pytime_as_nanoseconds(t);
|
||||
return pytime_divide(ns, NS_TO_100NS, round);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
_PyTime_t
|
||||
_PyTime_AsMicroseconds(_PyTime_t t, _PyTime_round_t round)
|
||||
PyTime_t
|
||||
_PyTime_AsMicroseconds(PyTime_t t, _PyTime_round_t round)
|
||||
{
|
||||
_PyTime_t ns = pytime_as_nanoseconds(t);
|
||||
PyTime_t ns = pytime_as_nanoseconds(t);
|
||||
return pytime_divide(ns, NS_TO_US, round);
|
||||
}
|
||||
|
||||
|
||||
_PyTime_t
|
||||
_PyTime_AsMilliseconds(_PyTime_t t, _PyTime_round_t round)
|
||||
PyTime_t
|
||||
_PyTime_AsMilliseconds(PyTime_t t, _PyTime_round_t round)
|
||||
{
|
||||
_PyTime_t ns = pytime_as_nanoseconds(t);
|
||||
PyTime_t ns = pytime_as_nanoseconds(t);
|
||||
return pytime_divide(ns, NS_TO_MS, round);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
pytime_as_timeval(_PyTime_t t, _PyTime_t *ptv_sec, int *ptv_usec,
|
||||
pytime_as_timeval(PyTime_t t, PyTime_t *ptv_sec, int *ptv_usec,
|
||||
_PyTime_round_t round)
|
||||
{
|
||||
_PyTime_t ns = pytime_as_nanoseconds(t);
|
||||
_PyTime_t us = pytime_divide(ns, US_TO_NS, round);
|
||||
PyTime_t ns = pytime_as_nanoseconds(t);
|
||||
PyTime_t us = pytime_divide(ns, US_TO_NS, round);
|
||||
|
||||
_PyTime_t tv_sec, tv_usec;
|
||||
PyTime_t tv_sec, tv_usec;
|
||||
int res = pytime_divmod(us, SEC_TO_US, &tv_sec, &tv_usec);
|
||||
*ptv_sec = tv_sec;
|
||||
*ptv_usec = (int)tv_usec;
|
||||
|
@ -826,10 +826,10 @@ pytime_as_timeval(_PyTime_t t, _PyTime_t *ptv_sec, int *ptv_usec,
|
|||
|
||||
|
||||
static int
|
||||
pytime_as_timeval_struct(_PyTime_t t, struct timeval *tv,
|
||||
pytime_as_timeval_struct(PyTime_t t, struct timeval *tv,
|
||||
_PyTime_round_t round, int raise_exc)
|
||||
{
|
||||
_PyTime_t tv_sec;
|
||||
PyTime_t tv_sec;
|
||||
int tv_usec;
|
||||
int res = pytime_as_timeval(t, &tv_sec, &tv_usec, round);
|
||||
int res2;
|
||||
|
@ -853,24 +853,24 @@ pytime_as_timeval_struct(_PyTime_t t, struct timeval *tv,
|
|||
|
||||
|
||||
int
|
||||
_PyTime_AsTimeval(_PyTime_t t, struct timeval *tv, _PyTime_round_t round)
|
||||
_PyTime_AsTimeval(PyTime_t t, struct timeval *tv, _PyTime_round_t round)
|
||||
{
|
||||
return pytime_as_timeval_struct(t, tv, round, 1);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_PyTime_AsTimeval_clamp(_PyTime_t t, struct timeval *tv, _PyTime_round_t round)
|
||||
_PyTime_AsTimeval_clamp(PyTime_t t, struct timeval *tv, _PyTime_round_t round)
|
||||
{
|
||||
(void)pytime_as_timeval_struct(t, tv, round, 0);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_PyTime_AsTimevalTime_t(_PyTime_t t, time_t *p_secs, int *us,
|
||||
_PyTime_AsTimevalTime_t(PyTime_t t, time_t *p_secs, int *us,
|
||||
_PyTime_round_t round)
|
||||
{
|
||||
_PyTime_t secs;
|
||||
PyTime_t secs;
|
||||
if (pytime_as_timeval(t, &secs, us, round) < 0) {
|
||||
pytime_time_t_overflow();
|
||||
return -1;
|
||||
|
@ -886,10 +886,10 @@ _PyTime_AsTimevalTime_t(_PyTime_t t, time_t *p_secs, int *us,
|
|||
|
||||
#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_KQUEUE)
|
||||
static int
|
||||
pytime_as_timespec(_PyTime_t t, struct timespec *ts, int raise_exc)
|
||||
pytime_as_timespec(PyTime_t t, struct timespec *ts, int raise_exc)
|
||||
{
|
||||
_PyTime_t ns = pytime_as_nanoseconds(t);
|
||||
_PyTime_t tv_sec, tv_nsec;
|
||||
PyTime_t ns = pytime_as_nanoseconds(t);
|
||||
PyTime_t tv_sec, tv_nsec;
|
||||
int res = pytime_divmod(ns, SEC_TO_NS, &tv_sec, &tv_nsec);
|
||||
|
||||
int res2 = _PyTime_AsTime_t(tv_sec, &ts->tv_sec);
|
||||
|
@ -906,13 +906,13 @@ pytime_as_timespec(_PyTime_t t, struct timespec *ts, int raise_exc)
|
|||
}
|
||||
|
||||
void
|
||||
_PyTime_AsTimespec_clamp(_PyTime_t t, struct timespec *ts)
|
||||
_PyTime_AsTimespec_clamp(PyTime_t t, struct timespec *ts)
|
||||
{
|
||||
(void)pytime_as_timespec(t, ts, 0);
|
||||
}
|
||||
|
||||
int
|
||||
_PyTime_AsTimespec(_PyTime_t t, struct timespec *ts)
|
||||
_PyTime_AsTimespec(PyTime_t t, struct timespec *ts)
|
||||
{
|
||||
return pytime_as_timespec(t, ts, 1);
|
||||
}
|
||||
|
@ -921,7 +921,7 @@ _PyTime_AsTimespec(_PyTime_t t, struct timespec *ts)
|
|||
|
||||
// N.B. If raise_exc=0, this may be called without the GIL.
|
||||
static int
|
||||
py_get_system_clock(_PyTime_t *tp, _Py_clock_info_t *info, int raise_exc)
|
||||
py_get_system_clock(PyTime_t *tp, _Py_clock_info_t *info, int raise_exc)
|
||||
{
|
||||
assert(info == NULL || raise_exc);
|
||||
|
||||
|
@ -935,7 +935,7 @@ py_get_system_clock(_PyTime_t *tp, _Py_clock_info_t *info, int raise_exc)
|
|||
/* 11,644,473,600,000,000,000: number of nanoseconds between
|
||||
the 1st january 1601 and the 1st january 1970 (369 years + 89 leap
|
||||
days). */
|
||||
_PyTime_t ns = large.QuadPart * 100 - 11644473600000000000;
|
||||
PyTime_t ns = large.QuadPart * 100 - 11644473600000000000;
|
||||
*tp = pytime_from_nanoseconds(ns);
|
||||
if (info) {
|
||||
DWORD timeAdjustment, timeIncrement;
|
||||
|
@ -1031,10 +1031,10 @@ py_get_system_clock(_PyTime_t *tp, _Py_clock_info_t *info, int raise_exc)
|
|||
}
|
||||
|
||||
|
||||
_PyTime_t
|
||||
PyTime_t
|
||||
_PyTime_GetSystemClock(void)
|
||||
{
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
if (py_get_system_clock(&t, NULL, 0) < 0) {
|
||||
// If clock_gettime(CLOCK_REALTIME) or gettimeofday() fails:
|
||||
// silently ignore the failure and return 0.
|
||||
|
@ -1057,7 +1057,7 @@ PyTime_Time(PyTime_t *result)
|
|||
}
|
||||
|
||||
int
|
||||
_PyTime_GetSystemClockWithInfo(_PyTime_t *t, _Py_clock_info_t *info)
|
||||
_PyTime_GetSystemClockWithInfo(PyTime_t *t, _Py_clock_info_t *info)
|
||||
{
|
||||
return py_get_system_clock(t, info, 1);
|
||||
}
|
||||
|
@ -1073,13 +1073,13 @@ py_mach_timebase_info(_PyTimeFraction *base, int raise)
|
|||
(void)mach_timebase_info(&timebase);
|
||||
|
||||
// Check that timebase.numer and timebase.denom can be casted to
|
||||
// _PyTime_t. In practice, timebase uses uint32_t, so casting cannot
|
||||
// PyTime_t. In practice, timebase uses uint32_t, so casting cannot
|
||||
// overflow. At the end, only make sure that the type is uint32_t
|
||||
// (_PyTime_t is 64-bit long).
|
||||
Py_BUILD_ASSERT(sizeof(timebase.numer) <= sizeof(_PyTime_t));
|
||||
Py_BUILD_ASSERT(sizeof(timebase.denom) <= sizeof(_PyTime_t));
|
||||
_PyTime_t numer = (_PyTime_t)timebase.numer;
|
||||
_PyTime_t denom = (_PyTime_t)timebase.denom;
|
||||
// (PyTime_t is 64-bit long).
|
||||
Py_BUILD_ASSERT(sizeof(timebase.numer) <= sizeof(PyTime_t));
|
||||
Py_BUILD_ASSERT(sizeof(timebase.denom) <= sizeof(PyTime_t));
|
||||
PyTime_t numer = (PyTime_t)timebase.numer;
|
||||
PyTime_t denom = (PyTime_t)timebase.denom;
|
||||
|
||||
// Known time bases:
|
||||
//
|
||||
|
@ -1100,21 +1100,21 @@ py_mach_timebase_info(_PyTimeFraction *base, int raise)
|
|||
|
||||
// N.B. If raise_exc=0, this may be called without the GIL.
|
||||
static int
|
||||
py_get_monotonic_clock(_PyTime_t *tp, _Py_clock_info_t *info, int raise_exc)
|
||||
py_get_monotonic_clock(PyTime_t *tp, _Py_clock_info_t *info, int raise_exc)
|
||||
{
|
||||
assert(info == NULL || raise_exc);
|
||||
|
||||
#if defined(MS_WINDOWS)
|
||||
ULONGLONG ticks = GetTickCount64();
|
||||
static_assert(sizeof(ticks) <= sizeof(_PyTime_t),
|
||||
"ULONGLONG is larger than _PyTime_t");
|
||||
_PyTime_t t;
|
||||
static_assert(sizeof(ticks) <= sizeof(PyTime_t),
|
||||
"ULONGLONG is larger than PyTime_t");
|
||||
PyTime_t t;
|
||||
if (ticks <= (ULONGLONG)PyTime_MAX) {
|
||||
t = (_PyTime_t)ticks;
|
||||
t = (PyTime_t)ticks;
|
||||
}
|
||||
else {
|
||||
// GetTickCount64() maximum is larger than _PyTime_t maximum:
|
||||
// ULONGLONG is unsigned, whereas _PyTime_t is signed.
|
||||
// GetTickCount64() maximum is larger than PyTime_t maximum:
|
||||
// ULONGLONG is unsigned, whereas PyTime_t is signed.
|
||||
t = PyTime_MAX;
|
||||
}
|
||||
|
||||
|
@ -1159,9 +1159,9 @@ py_get_monotonic_clock(_PyTime_t *tp, _Py_clock_info_t *info, int raise_exc)
|
|||
uint64_t uticks = mach_absolute_time();
|
||||
// unsigned => signed
|
||||
assert(uticks <= (uint64_t)PyTime_MAX);
|
||||
_PyTime_t ticks = (_PyTime_t)uticks;
|
||||
PyTime_t ticks = (PyTime_t)uticks;
|
||||
|
||||
_PyTime_t ns = _PyTimeFraction_Mul(ticks, &base);
|
||||
PyTime_t ns = _PyTimeFraction_Mul(ticks, &base);
|
||||
*tp = pytime_from_nanoseconds(ns);
|
||||
|
||||
#elif defined(__hpux)
|
||||
|
@ -1223,10 +1223,10 @@ py_get_monotonic_clock(_PyTime_t *tp, _Py_clock_info_t *info, int raise_exc)
|
|||
}
|
||||
|
||||
|
||||
_PyTime_t
|
||||
PyTime_t
|
||||
_PyTime_GetMonotonicClock(void)
|
||||
{
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
if (py_get_monotonic_clock(&t, NULL, 0) < 0) {
|
||||
// If mach_timebase_info(), clock_gettime() or gethrtime() fails:
|
||||
// silently ignore the failure and return 0.
|
||||
|
@ -1248,7 +1248,7 @@ PyTime_Monotonic(PyTime_t *result)
|
|||
|
||||
|
||||
int
|
||||
_PyTime_GetMonotonicClockWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
|
||||
_PyTime_GetMonotonicClockWithInfo(PyTime_t *tp, _Py_clock_info_t *info)
|
||||
{
|
||||
return py_get_monotonic_clock(tp, info, 1);
|
||||
}
|
||||
|
@ -1268,8 +1268,8 @@ py_win_perf_counter_frequency(_PyTimeFraction *base, int raise)
|
|||
// Since Windows XP, frequency cannot be zero.
|
||||
assert(frequency >= 1);
|
||||
|
||||
Py_BUILD_ASSERT(sizeof(_PyTime_t) == sizeof(frequency));
|
||||
_PyTime_t denom = (_PyTime_t)frequency;
|
||||
Py_BUILD_ASSERT(sizeof(PyTime_t) == sizeof(frequency));
|
||||
PyTime_t denom = (PyTime_t)frequency;
|
||||
|
||||
// Known QueryPerformanceFrequency() values:
|
||||
//
|
||||
|
@ -1288,7 +1288,7 @@ py_win_perf_counter_frequency(_PyTimeFraction *base, int raise)
|
|||
|
||||
// N.B. If raise_exc=0, this may be called without the GIL.
|
||||
static int
|
||||
py_get_win_perf_counter(_PyTime_t *tp, _Py_clock_info_t *info, int raise_exc)
|
||||
py_get_win_perf_counter(PyTime_t *tp, _Py_clock_info_t *info, int raise_exc)
|
||||
{
|
||||
assert(info == NULL || raise_exc);
|
||||
|
||||
|
@ -1310,14 +1310,14 @@ py_get_win_perf_counter(_PyTime_t *tp, _Py_clock_info_t *info, int raise_exc)
|
|||
QueryPerformanceCounter(&now);
|
||||
LONGLONG ticksll = now.QuadPart;
|
||||
|
||||
/* Make sure that casting LONGLONG to _PyTime_t cannot overflow,
|
||||
/* Make sure that casting LONGLONG to PyTime_t cannot overflow,
|
||||
both types are signed */
|
||||
_PyTime_t ticks;
|
||||
PyTime_t ticks;
|
||||
static_assert(sizeof(ticksll) <= sizeof(ticks),
|
||||
"LONGLONG is larger than _PyTime_t");
|
||||
ticks = (_PyTime_t)ticksll;
|
||||
"LONGLONG is larger than PyTime_t");
|
||||
ticks = (PyTime_t)ticksll;
|
||||
|
||||
_PyTime_t ns = _PyTimeFraction_Mul(ticks, &base);
|
||||
PyTime_t ns = _PyTimeFraction_Mul(ticks, &base);
|
||||
*tp = pytime_from_nanoseconds(ns);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1325,7 +1325,7 @@ py_get_win_perf_counter(_PyTime_t *tp, _Py_clock_info_t *info, int raise_exc)
|
|||
|
||||
|
||||
int
|
||||
_PyTime_GetPerfCounterWithInfo(_PyTime_t *t, _Py_clock_info_t *info)
|
||||
_PyTime_GetPerfCounterWithInfo(PyTime_t *t, _Py_clock_info_t *info)
|
||||
{
|
||||
#ifdef MS_WINDOWS
|
||||
return py_get_win_perf_counter(t, info, 1);
|
||||
|
@ -1335,10 +1335,10 @@ _PyTime_GetPerfCounterWithInfo(_PyTime_t *t, _Py_clock_info_t *info)
|
|||
}
|
||||
|
||||
|
||||
_PyTime_t
|
||||
PyTime_t
|
||||
_PyTime_GetPerfCounter(void)
|
||||
{
|
||||
_PyTime_t t;
|
||||
PyTime_t t;
|
||||
int res;
|
||||
#ifdef MS_WINDOWS
|
||||
res = py_get_win_perf_counter(&t, NULL, 0);
|
||||
|
@ -1440,17 +1440,17 @@ _PyTime_gmtime(time_t t, struct tm *tm)
|
|||
}
|
||||
|
||||
|
||||
_PyTime_t
|
||||
_PyDeadline_Init(_PyTime_t timeout)
|
||||
PyTime_t
|
||||
_PyDeadline_Init(PyTime_t timeout)
|
||||
{
|
||||
_PyTime_t now = _PyTime_GetMonotonicClock();
|
||||
PyTime_t now = _PyTime_GetMonotonicClock();
|
||||
return _PyTime_Add(now, timeout);
|
||||
}
|
||||
|
||||
|
||||
_PyTime_t
|
||||
_PyDeadline_Get(_PyTime_t deadline)
|
||||
PyTime_t
|
||||
_PyDeadline_Get(PyTime_t deadline)
|
||||
{
|
||||
_PyTime_t now = _PyTime_GetMonotonicClock();
|
||||
PyTime_t now = _PyTime_GetMonotonicClock();
|
||||
return deadline - now;
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ PyThread_ParseTimeoutArg(PyObject *arg, int blocking, PY_TIMEOUT_T *timeout_p)
|
|||
return -1;
|
||||
}
|
||||
|
||||
_PyTime_t timeout;
|
||||
PyTime_t timeout;
|
||||
if (_PyTime_FromSecondsObject(&timeout, arg, _PyTime_ROUND_TIMEOUT) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -132,14 +132,14 @@ PyThread_acquire_lock_timed_with_retries(PyThread_type_lock lock,
|
|||
PY_TIMEOUT_T timeout)
|
||||
{
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
_PyTime_t endtime = 0;
|
||||
PyTime_t endtime = 0;
|
||||
if (timeout > 0) {
|
||||
endtime = _PyDeadline_Init(timeout);
|
||||
}
|
||||
|
||||
PyLockStatus r;
|
||||
do {
|
||||
_PyTime_t microseconds;
|
||||
PyTime_t microseconds;
|
||||
microseconds = _PyTime_AsMicroseconds(timeout, _PyTime_ROUND_CEILING);
|
||||
|
||||
/* first a simple non-blocking try without releasing the GIL */
|
||||
|
|
|
@ -76,10 +76,10 @@ EnterNonRecursiveMutex(PNRMUTEX mutex, DWORD milliseconds)
|
|||
}
|
||||
} else if (milliseconds != 0) {
|
||||
/* wait at least until the deadline */
|
||||
_PyTime_t nanoseconds = _PyTime_FromNanoseconds((_PyTime_t)milliseconds * 1000000);
|
||||
_PyTime_t deadline = _PyTime_Add(_PyTime_GetPerfCounter(), nanoseconds);
|
||||
PyTime_t nanoseconds = _PyTime_FromNanoseconds((PyTime_t)milliseconds * 1000000);
|
||||
PyTime_t deadline = _PyTime_Add(_PyTime_GetPerfCounter(), nanoseconds);
|
||||
while (mutex->locked) {
|
||||
_PyTime_t microseconds = _PyTime_AsMicroseconds(nanoseconds,
|
||||
PyTime_t microseconds = _PyTime_AsMicroseconds(nanoseconds,
|
||||
_PyTime_ROUND_TIMEOUT);
|
||||
if (PyCOND_TIMEDWAIT(&mutex->cv, &mutex->cs, microseconds) < 0) {
|
||||
result = WAIT_FAILED;
|
||||
|
|
|
@ -149,8 +149,8 @@ _PyThread_cond_init(PyCOND_T *cond)
|
|||
void
|
||||
_PyThread_cond_after(long long us, struct timespec *abs)
|
||||
{
|
||||
_PyTime_t timeout = _PyTime_FromMicrosecondsClamp(us);
|
||||
_PyTime_t t;
|
||||
PyTime_t timeout = _PyTime_FromMicrosecondsClamp(us);
|
||||
PyTime_t t;
|
||||
#ifdef CONDATTR_MONOTONIC
|
||||
if (condattr_monotonic) {
|
||||
t = _PyTime_GetMonotonicClock();
|
||||
|
@ -481,7 +481,7 @@ PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds,
|
|||
|
||||
(void) error; /* silence unused-but-set-variable warning */
|
||||
|
||||
_PyTime_t timeout; // relative timeout
|
||||
PyTime_t timeout; // relative timeout
|
||||
if (microseconds >= 0) {
|
||||
// bpo-41710: PyThread_acquire_lock_timed() cannot report timeout
|
||||
// overflow to the caller, so clamp the timeout to
|
||||
|
@ -501,11 +501,11 @@ PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds,
|
|||
struct timespec abs_timeout;
|
||||
// Local scope for deadline
|
||||
{
|
||||
_PyTime_t deadline = _PyTime_Add(_PyTime_GetMonotonicClock(), timeout);
|
||||
PyTime_t deadline = _PyTime_Add(_PyTime_GetMonotonicClock(), timeout);
|
||||
_PyTime_AsTimespec_clamp(deadline, &abs_timeout);
|
||||
}
|
||||
#else
|
||||
_PyTime_t deadline = 0;
|
||||
PyTime_t deadline = 0;
|
||||
if (timeout > 0 && !intr_flag) {
|
||||
deadline = _PyDeadline_Init(timeout);
|
||||
}
|
||||
|
@ -517,7 +517,7 @@ PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds,
|
|||
status = fix_status(sem_clockwait(thelock, CLOCK_MONOTONIC,
|
||||
&abs_timeout));
|
||||
#else
|
||||
_PyTime_t abs_time = _PyTime_Add(_PyTime_GetSystemClock(),
|
||||
PyTime_t abs_time = _PyTime_Add(_PyTime_GetSystemClock(),
|
||||
timeout);
|
||||
struct timespec ts;
|
||||
_PyTime_AsTimespec_clamp(abs_time, &ts);
|
||||
|
|
Loading…
Reference in New Issue