mirror of
https://github.com/python/cpython.git
synced 2025-07-19 01:05:26 +00:00
gh-110850: Rename internal PyTime C API functions (#115734)
Rename functions: * _PyTime_GetSystemClock() => _PyTime_TimeUnchecked() * _PyTime_GetPerfCounter() => _PyTime_PerfCounterUnchecked() * _PyTime_GetMonotonicClock() => _PyTime_MonotonicUnchecked() * _PyTime_GetSystemClockWithInfo() => _PyTime_TimeWithInfo() * _PyTime_GetMonotonicClockWithInfo() => _PyTime_MonotonicWithInfo() * _PyTime_GetMonotonicClockWithInfo() => _PyTime_MonotonicWithInfo() Changes: * Remove "typedef PyTime_t PyTime_t;" which was "typedef PyTime_t _PyTime_t;" before a previous rename. * Update comments of "Unchecked" functions. * Remove invalid PyTime_Time() comment.
This commit is contained in:
parent
e1fdc3c323
commit
52d1477566
16 changed files with 68 additions and 83 deletions
|
@ -12,7 +12,7 @@
|
|||
#include "pycore_object_alloc.h" // _PyObject_MallocWithType()
|
||||
#include "pycore_pyerrors.h"
|
||||
#include "pycore_pystate.h" // _PyThreadState_GET()
|
||||
#include "pycore_time.h" // _PyTime_GetPerfCounter()
|
||||
#include "pycore_time.h" // _PyTime_PerfCounterUnchecked()
|
||||
#include "pycore_weakref.h" // _PyWeakref_ClearRef()
|
||||
#include "pydtrace.h"
|
||||
|
||||
|
@ -1327,7 +1327,7 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason)
|
|||
if (gcstate->debug & _PyGC_DEBUG_STATS) {
|
||||
PySys_WriteStderr("gc: collecting generation %d...\n", generation);
|
||||
show_stats_each_generations(gcstate);
|
||||
t1 = _PyTime_GetPerfCounter();
|
||||
t1 = _PyTime_PerfCounterUnchecked();
|
||||
}
|
||||
|
||||
if (PyDTrace_GC_START_ENABLED()) {
|
||||
|
@ -1428,7 +1428,7 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason)
|
|||
debug_cycle("uncollectable", FROM_GC(gc));
|
||||
}
|
||||
if (gcstate->debug & _PyGC_DEBUG_STATS) {
|
||||
double d = _PyTime_AsSecondsDouble(_PyTime_GetPerfCounter() - t1);
|
||||
double d = _PyTime_AsSecondsDouble(_PyTime_PerfCounterUnchecked() - t1);
|
||||
PySys_WriteStderr(
|
||||
"gc: done, %zd unreachable, %zd uncollectable, %.4fs elapsed\n",
|
||||
n+m, n, d);
|
||||
|
|
|
@ -1108,7 +1108,7 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason)
|
|||
if (gcstate->debug & _PyGC_DEBUG_STATS) {
|
||||
PySys_WriteStderr("gc: collecting generation %d...\n", generation);
|
||||
show_stats_each_generations(gcstate);
|
||||
t1 = _PyTime_GetPerfCounter();
|
||||
t1 = _PyTime_PerfCounterUnchecked();
|
||||
}
|
||||
|
||||
if (PyDTrace_GC_START_ENABLED()) {
|
||||
|
@ -1136,7 +1136,7 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason)
|
|||
n = state.uncollectable;
|
||||
|
||||
if (gcstate->debug & _PyGC_DEBUG_STATS) {
|
||||
double d = _PyTime_AsSecondsDouble(_PyTime_GetPerfCounter() - t1);
|
||||
double d = _PyTime_AsSecondsDouble(_PyTime_PerfCounterUnchecked() - t1);
|
||||
PySys_WriteStderr(
|
||||
"gc: done, %zd unreachable, %zd uncollectable, %.4fs elapsed\n",
|
||||
n+m, n, d);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "pycore_pymem.h" // _PyMem_SetDefaultAllocator()
|
||||
#include "pycore_pystate.h" // _PyInterpreterState_GET()
|
||||
#include "pycore_sysmodule.h" // _PySys_Audit()
|
||||
#include "pycore_time.h" // _PyTime_GetPerfCounter()
|
||||
#include "pycore_time.h" // _PyTime_PerfCounterUnchecked()
|
||||
#include "pycore_weakref.h" // _PyWeakref_GET_REF()
|
||||
|
||||
#include "marshal.h" // PyMarshal_ReadObjectFromString()
|
||||
|
@ -2748,7 +2748,7 @@ import_find_and_load(PyThreadState *tstate, PyObject *abs_name)
|
|||
#undef header
|
||||
|
||||
import_level++;
|
||||
t1 = _PyTime_GetPerfCounter();
|
||||
t1 = _PyTime_PerfCounterUnchecked();
|
||||
accumulated = 0;
|
||||
}
|
||||
|
||||
|
@ -2763,7 +2763,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_PerfCounterUnchecked() - t1;
|
||||
|
||||
import_level--;
|
||||
fprintf(stderr, "import time: %9ld | %10ld | %*s%s\n",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "pycore_lock.h"
|
||||
#include "pycore_parking_lot.h"
|
||||
#include "pycore_semaphore.h"
|
||||
#include "pycore_time.h" // _PyTime_GetMonotonicClock()
|
||||
#include "pycore_time.h" // _PyTime_MonotonicUnchecked()
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
|
@ -66,7 +66,7 @@ _PyMutex_LockTimed(PyMutex *m, PyTime_t timeout, _PyLockFlags flags)
|
|||
return PY_LOCK_FAILURE;
|
||||
}
|
||||
|
||||
PyTime_t now = _PyTime_GetMonotonicClock();
|
||||
PyTime_t now = _PyTime_MonotonicUnchecked();
|
||||
PyTime_t endtime = 0;
|
||||
if (timeout > 0) {
|
||||
endtime = _PyTime_Add(now, timeout);
|
||||
|
@ -143,7 +143,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_MonotonicUnchecked();
|
||||
int should_be_fair = now > entry->time_to_be_fair;
|
||||
|
||||
entry->handed_off = should_be_fair;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "pycore_pyerrors.h" // _Py_FatalErrorFormat
|
||||
#include "pycore_pystate.h" // _PyThreadState_GET
|
||||
#include "pycore_semaphore.h" // _PySemaphore
|
||||
#include "pycore_time.h" //_PyTime_GetMonotonicClock()
|
||||
#include "pycore_time.h" //_PyTime_MonotonicUnchecked()
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
|
@ -120,13 +120,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_MonotonicUnchecked(), 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_TimeUnchecked(), timeout);
|
||||
|
||||
_PyTime_AsTimespec_clamp(deadline, &ts);
|
||||
|
||||
|
@ -163,7 +163,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_TimeUnchecked(), timeout);
|
||||
_PyTime_AsTimespec_clamp(deadline, &ts);
|
||||
|
||||
err = pthread_cond_timedwait(&sema->cond, &sema->mutex, &ts);
|
||||
|
|
|
@ -1032,7 +1032,7 @@ py_get_system_clock(PyTime_t *tp, _Py_clock_info_t *info, int raise_exc)
|
|||
|
||||
|
||||
PyTime_t
|
||||
_PyTime_GetSystemClock(void)
|
||||
_PyTime_TimeUnchecked(void)
|
||||
{
|
||||
PyTime_t t;
|
||||
if (py_get_system_clock(&t, NULL, 0) < 0) {
|
||||
|
@ -1048,8 +1048,6 @@ int
|
|||
PyTime_Time(PyTime_t *result)
|
||||
{
|
||||
if (py_get_system_clock(result, NULL, 1) < 0) {
|
||||
// If clock_gettime(CLOCK_REALTIME) or gettimeofday() fails:
|
||||
// silently ignore the failure and return 0.
|
||||
*result = 0;
|
||||
return -1;
|
||||
}
|
||||
|
@ -1057,7 +1055,7 @@ PyTime_Time(PyTime_t *result)
|
|||
}
|
||||
|
||||
int
|
||||
_PyTime_GetSystemClockWithInfo(PyTime_t *t, _Py_clock_info_t *info)
|
||||
_PyTime_TimeWithInfo(PyTime_t *t, _Py_clock_info_t *info)
|
||||
{
|
||||
return py_get_system_clock(t, info, 1);
|
||||
}
|
||||
|
@ -1224,7 +1222,7 @@ py_get_monotonic_clock(PyTime_t *tp, _Py_clock_info_t *info, int raise_exc)
|
|||
|
||||
|
||||
PyTime_t
|
||||
_PyTime_GetMonotonicClock(void)
|
||||
_PyTime_MonotonicUnchecked(void)
|
||||
{
|
||||
PyTime_t t;
|
||||
if (py_get_monotonic_clock(&t, NULL, 0) < 0) {
|
||||
|
@ -1248,7 +1246,7 @@ PyTime_Monotonic(PyTime_t *result)
|
|||
|
||||
|
||||
int
|
||||
_PyTime_GetMonotonicClockWithInfo(PyTime_t *tp, _Py_clock_info_t *info)
|
||||
_PyTime_MonotonicWithInfo(PyTime_t *tp, _Py_clock_info_t *info)
|
||||
{
|
||||
return py_get_monotonic_clock(tp, info, 1);
|
||||
}
|
||||
|
@ -1325,18 +1323,18 @@ 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_PerfCounterWithInfo(PyTime_t *t, _Py_clock_info_t *info)
|
||||
{
|
||||
#ifdef MS_WINDOWS
|
||||
return py_get_win_perf_counter(t, info, 1);
|
||||
#else
|
||||
return _PyTime_GetMonotonicClockWithInfo(t, info);
|
||||
return _PyTime_MonotonicWithInfo(t, info);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
PyTime_t
|
||||
_PyTime_GetPerfCounter(void)
|
||||
_PyTime_PerfCounterUnchecked(void)
|
||||
{
|
||||
PyTime_t t;
|
||||
int res;
|
||||
|
@ -1443,7 +1441,7 @@ _PyTime_gmtime(time_t t, struct tm *tm)
|
|||
PyTime_t
|
||||
_PyDeadline_Init(PyTime_t timeout)
|
||||
{
|
||||
PyTime_t now = _PyTime_GetMonotonicClock();
|
||||
PyTime_t now = _PyTime_MonotonicUnchecked();
|
||||
return _PyTime_Add(now, timeout);
|
||||
}
|
||||
|
||||
|
@ -1451,6 +1449,6 @@ _PyDeadline_Init(PyTime_t timeout)
|
|||
PyTime_t
|
||||
_PyDeadline_Get(PyTime_t deadline)
|
||||
{
|
||||
PyTime_t now = _PyTime_GetMonotonicClock();
|
||||
PyTime_t now = _PyTime_MonotonicUnchecked();
|
||||
return deadline - now;
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ 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 deadline = _PyTime_Add(_PyTime_PerfCounterUnchecked(), nanoseconds);
|
||||
while (mutex->locked) {
|
||||
PyTime_t microseconds = _PyTime_AsMicroseconds(nanoseconds,
|
||||
_PyTime_ROUND_TIMEOUT);
|
||||
|
@ -86,7 +86,7 @@ EnterNonRecursiveMutex(PNRMUTEX mutex, DWORD milliseconds)
|
|||
result = WAIT_FAILED;
|
||||
break;
|
||||
}
|
||||
nanoseconds = deadline - _PyTime_GetPerfCounter();
|
||||
nanoseconds = deadline - _PyTime_PerfCounterUnchecked();
|
||||
if (nanoseconds <= 0) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -154,12 +154,12 @@ _PyThread_cond_after(long long us, struct timespec *abs)
|
|||
PyTime_t t;
|
||||
#ifdef CONDATTR_MONOTONIC
|
||||
if (condattr_monotonic) {
|
||||
t = _PyTime_GetMonotonicClock();
|
||||
t = _PyTime_MonotonicUnchecked();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
t = _PyTime_GetSystemClock();
|
||||
t = _PyTime_TimeUnchecked();
|
||||
}
|
||||
t = _PyTime_Add(t, timeout);
|
||||
_PyTime_AsTimespec_clamp(t, abs);
|
||||
|
@ -502,7 +502,7 @@ 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_MonotonicUnchecked(), timeout);
|
||||
_PyTime_AsTimespec_clamp(deadline, &abs_timeout);
|
||||
}
|
||||
#else
|
||||
|
@ -518,7 +518,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_TimeUnchecked(),
|
||||
timeout);
|
||||
struct timespec ts;
|
||||
_PyTime_AsTimespec_clamp(abs_time, &ts);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue