Skip to content

Commit 9af80ec

Browse files
authored
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")
1 parent 0749244 commit 9af80ec

31 files changed

+341
-341
lines changed

Include/internal/pycore_import.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extern "C" {
1111

1212
#include "pycore_lock.h" // PyMutex
1313
#include "pycore_hashtable.h" // _Py_hashtable_t
14-
#include "pycore_time.h" // _PyTime_t
14+
#include "pycore_time.h" // PyTime_t
1515

1616
extern int _PyImport_IsInitialized(PyInterpreterState *);
1717

@@ -103,7 +103,7 @@ struct _import_state {
103103
/* diagnostic info in PyImport_ImportModuleLevelObject() */
104104
struct {
105105
int import_level;
106-
_PyTime_t accumulated;
106+
PyTime_t accumulated;
107107
int header;
108108
} find_and_load;
109109
};

Include/internal/pycore_lock.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extern "C" {
1313
# error "this header requires Py_BUILD_CORE define"
1414
#endif
1515

16-
#include "pycore_time.h" // _PyTime_t
16+
#include "pycore_time.h" // PyTime_t
1717

1818

1919
// A mutex that occupies one byte. The lock can be zero initialized.
@@ -113,7 +113,7 @@ typedef enum _PyLockFlags {
113113
// Lock a mutex with an optional timeout and additional options. See
114114
// _PyLockFlags for details.
115115
extern PyLockStatus
116-
_PyMutex_LockTimed(PyMutex *m, _PyTime_t timeout_ns, _PyLockFlags flags);
116+
_PyMutex_LockTimed(PyMutex *m, PyTime_t timeout_ns, _PyLockFlags flags);
117117

118118
// Lock a mutex with aditional options. See _PyLockFlags for details.
119119
static inline void
@@ -146,7 +146,7 @@ PyAPI_FUNC(void) PyEvent_Wait(PyEvent *evt);
146146
// Wait for the event to be set, or until the timeout expires. If the event is
147147
// already set, then this returns immediately. Returns 1 if the event was set,
148148
// and 0 if the timeout expired or thread was interrupted.
149-
PyAPI_FUNC(int) PyEvent_WaitTimed(PyEvent *evt, _PyTime_t timeout_ns);
149+
PyAPI_FUNC(int) PyEvent_WaitTimed(PyEvent *evt, PyTime_t timeout_ns);
150150

151151

152152
// _PyRawMutex implements a word-sized mutex that that does not depend on the

Include/internal/pycore_parking_lot.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extern "C" {
1818
# error "this header requires Py_BUILD_CORE define"
1919
#endif
2020

21-
#include "pycore_time.h" // _PyTime_t
21+
#include "pycore_time.h" // PyTime_t
2222

2323

2424
enum {
@@ -61,7 +61,7 @@ enum {
6161
// }
6262
PyAPI_FUNC(int)
6363
_PyParkingLot_Park(const void *address, const void *expected,
64-
size_t address_size, _PyTime_t timeout_ns,
64+
size_t address_size, PyTime_t timeout_ns,
6565
void *park_arg, int detach);
6666

6767
// Callback for _PyParkingLot_Unpark:

Include/internal/pycore_pythread.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ extern void _PyThread_AfterFork(struct _pythread_runtime_state *state);
9696

9797

9898
// unset: -1 seconds, in nanoseconds
99-
#define PyThread_UNSET_TIMEOUT ((_PyTime_t)(-1 * 1000 * 1000 * 1000))
99+
#define PyThread_UNSET_TIMEOUT ((PyTime_t)(-1 * 1000 * 1000 * 1000))
100100

101101
// Exported for the _xxinterpchannels module.
102102
PyAPI_FUNC(int) PyThread_ParseTimeoutArg(

Include/internal/pycore_semaphore.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#endif
99

1010
#include "pycore_pythread.h" // _POSIX_SEMAPHORES
11-
#include "pycore_time.h" // _PyTime_t
11+
#include "pycore_time.h" // PyTime_t
1212

1313
#ifdef MS_WINDOWS
1414
# define WIN32_LEAN_AND_MEAN
@@ -48,7 +48,7 @@ typedef struct _PySemaphore {
4848
// If `detach` is true, then the thread will detach/release the GIL while
4949
// sleeping.
5050
PyAPI_FUNC(int)
51-
_PySemaphore_Wait(_PySemaphore *sema, _PyTime_t timeout_ns, int detach);
51+
_PySemaphore_Wait(_PySemaphore *sema, PyTime_t timeout_ns, int detach);
5252

5353
// Wakes up a single thread waiting on sema. Note that _PySemaphore_Wakeup()
5454
// can be called before _PySemaphore_Wait().

Include/internal/pycore_time.h

+37-37
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ extern "C" {
6262
struct timeval;
6363
#endif
6464

65-
typedef PyTime_t _PyTime_t;
65+
typedef PyTime_t PyTime_t;
6666
#define _SIZEOF_PYTIME_T 8
6767

6868
typedef enum {
@@ -130,84 +130,84 @@ PyAPI_FUNC(int) _PyTime_ObjectToTimespec(
130130

131131
// Create a timestamp from a number of seconds.
132132
// Export for '_socket' shared extension.
133-
PyAPI_FUNC(_PyTime_t) _PyTime_FromSeconds(int seconds);
133+
PyAPI_FUNC(PyTime_t) _PyTime_FromSeconds(int seconds);
134134

135135
// Create a timestamp from a number of seconds in double.
136136
// Export for '_socket' shared extension.
137-
PyAPI_FUNC(_PyTime_t) _PyTime_FromSecondsDouble(double seconds, _PyTime_round_t round);
137+
PyAPI_FUNC(PyTime_t) _PyTime_FromSecondsDouble(double seconds, _PyTime_round_t round);
138138

139139
// Macro to create a timestamp from a number of seconds, no integer overflow.
140140
// Only use the macro for small values, prefer _PyTime_FromSeconds().
141141
#define _PYTIME_FROMSECONDS(seconds) \
142-
((_PyTime_t)(seconds) * (1000 * 1000 * 1000))
142+
((PyTime_t)(seconds) * (1000 * 1000 * 1000))
143143

144144
// Create a timestamp from a number of nanoseconds.
145145
// Export for '_testinternalcapi' shared extension.
146-
PyAPI_FUNC(_PyTime_t) _PyTime_FromNanoseconds(_PyTime_t ns);
146+
PyAPI_FUNC(PyTime_t) _PyTime_FromNanoseconds(PyTime_t ns);
147147

148148
// Create a timestamp from a number of microseconds.
149149
// Clamp to [PyTime_MIN; PyTime_MAX] on overflow.
150-
extern _PyTime_t _PyTime_FromMicrosecondsClamp(_PyTime_t us);
150+
extern PyTime_t _PyTime_FromMicrosecondsClamp(PyTime_t us);
151151

152152
// Create a timestamp from nanoseconds (Python int).
153153
// Export for '_lsprof' shared extension.
154-
PyAPI_FUNC(int) _PyTime_FromNanosecondsObject(_PyTime_t *t,
154+
PyAPI_FUNC(int) _PyTime_FromNanosecondsObject(PyTime_t *t,
155155
PyObject *obj);
156156

157157
// Convert a number of seconds (Python float or int) to a timestamp.
158158
// Raise an exception and return -1 on error, return 0 on success.
159159
// Export for '_socket' shared extension.
160-
PyAPI_FUNC(int) _PyTime_FromSecondsObject(_PyTime_t *t,
160+
PyAPI_FUNC(int) _PyTime_FromSecondsObject(PyTime_t *t,
161161
PyObject *obj,
162162
_PyTime_round_t round);
163163

164164
// Convert a number of milliseconds (Python float or int, 10^-3) to a timestamp.
165165
// Raise an exception and return -1 on error, return 0 on success.
166166
// Export for 'select' shared extension.
167-
PyAPI_FUNC(int) _PyTime_FromMillisecondsObject(_PyTime_t *t,
167+
PyAPI_FUNC(int) _PyTime_FromMillisecondsObject(PyTime_t *t,
168168
PyObject *obj,
169169
_PyTime_round_t round);
170170

171171
// Convert timestamp to a number of milliseconds (10^-3 seconds).
172172
// Export for '_ssl' shared extension.
173-
PyAPI_FUNC(_PyTime_t) _PyTime_AsMilliseconds(_PyTime_t t,
173+
PyAPI_FUNC(PyTime_t) _PyTime_AsMilliseconds(PyTime_t t,
174174
_PyTime_round_t round);
175175

176176
// Convert timestamp to a number of microseconds (10^-6 seconds).
177177
// Export for '_queue' shared extension.
178-
PyAPI_FUNC(_PyTime_t) _PyTime_AsMicroseconds(_PyTime_t t,
178+
PyAPI_FUNC(PyTime_t) _PyTime_AsMicroseconds(PyTime_t t,
179179
_PyTime_round_t round);
180180

181181
#ifdef MS_WINDOWS
182182
// Convert timestamp to a number of 100 nanoseconds (10^-7 seconds).
183-
extern _PyTime_t _PyTime_As100Nanoseconds(_PyTime_t t,
183+
extern PyTime_t _PyTime_As100Nanoseconds(PyTime_t t,
184184
_PyTime_round_t round);
185185
#endif
186186

187187
// Convert timestamp to a number of nanoseconds (10^-9 seconds) as a Python int
188188
// object.
189189
// Export for '_testinternalcapi' shared extension.
190-
PyAPI_FUNC(PyObject*) _PyTime_AsNanosecondsObject(_PyTime_t t);
190+
PyAPI_FUNC(PyObject*) _PyTime_AsNanosecondsObject(PyTime_t t);
191191

192192
#ifndef MS_WINDOWS
193193
// Create a timestamp from a timeval structure.
194194
// Raise an exception and return -1 on overflow, return 0 on success.
195-
extern int _PyTime_FromTimeval(_PyTime_t *tp, struct timeval *tv);
195+
extern int _PyTime_FromTimeval(PyTime_t *tp, struct timeval *tv);
196196
#endif
197197

198198
// Convert a timestamp to a timeval structure (microsecond resolution).
199199
// tv_usec is always positive.
200200
// Raise an exception and return -1 if the conversion overflowed,
201201
// return 0 on success.
202202
// Export for 'select' shared extension.
203-
PyAPI_FUNC(int) _PyTime_AsTimeval(_PyTime_t t,
203+
PyAPI_FUNC(int) _PyTime_AsTimeval(PyTime_t t,
204204
struct timeval *tv,
205205
_PyTime_round_t round);
206206

207207
// Similar to _PyTime_AsTimeval() but don't raise an exception on overflow.
208-
// On overflow, clamp tv_sec to _PyTime_t min/max.
208+
// On overflow, clamp tv_sec to PyTime_t min/max.
209209
// Export for 'select' shared extension.
210-
PyAPI_FUNC(void) _PyTime_AsTimeval_clamp(_PyTime_t t,
210+
PyAPI_FUNC(void) _PyTime_AsTimeval_clamp(PyTime_t t,
211211
struct timeval *tv,
212212
_PyTime_round_t round);
213213

@@ -219,31 +219,31 @@ PyAPI_FUNC(void) _PyTime_AsTimeval_clamp(_PyTime_t t,
219219
// return 0 on success.
220220
// Export for '_datetime' shared extension.
221221
PyAPI_FUNC(int) _PyTime_AsTimevalTime_t(
222-
_PyTime_t t,
222+
PyTime_t t,
223223
time_t *secs,
224224
int *us,
225225
_PyTime_round_t round);
226226

227227
#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_KQUEUE)
228228
// Create a timestamp from a timespec structure.
229229
// Raise an exception and return -1 on overflow, return 0 on success.
230-
extern int _PyTime_FromTimespec(_PyTime_t *tp, const struct timespec *ts);
230+
extern int _PyTime_FromTimespec(PyTime_t *tp, const struct timespec *ts);
231231

232232
// Convert a timestamp to a timespec structure (nanosecond resolution).
233233
// tv_nsec is always positive.
234234
// Raise an exception and return -1 on error, return 0 on success.
235235
// Export for '_testinternalcapi' shared extension.
236-
PyAPI_FUNC(int) _PyTime_AsTimespec(_PyTime_t t, struct timespec *ts);
236+
PyAPI_FUNC(int) _PyTime_AsTimespec(PyTime_t t, struct timespec *ts);
237237

238238
// Similar to _PyTime_AsTimespec() but don't raise an exception on overflow.
239-
// On overflow, clamp tv_sec to _PyTime_t min/max.
239+
// On overflow, clamp tv_sec to PyTime_t min/max.
240240
// Export for '_testinternalcapi' shared extension.
241-
PyAPI_FUNC(void) _PyTime_AsTimespec_clamp(_PyTime_t t, struct timespec *ts);
241+
PyAPI_FUNC(void) _PyTime_AsTimespec_clamp(PyTime_t t, struct timespec *ts);
242242
#endif
243243

244244

245245
// Compute t1 + t2. Clamp to [PyTime_MIN; PyTime_MAX] on overflow.
246-
extern _PyTime_t _PyTime_Add(_PyTime_t t1, _PyTime_t t2);
246+
extern PyTime_t _PyTime_Add(PyTime_t t1, PyTime_t t2);
247247

248248
// Structure used by time.get_clock_info()
249249
typedef struct {
@@ -262,13 +262,13 @@ typedef struct {
262262
// Use _PyTime_GetSystemClockWithInfo or the public PyTime_Time() to check
263263
// for failure.
264264
// Export for '_random' shared extension.
265-
PyAPI_FUNC(_PyTime_t) _PyTime_GetSystemClock(void);
265+
PyAPI_FUNC(PyTime_t) _PyTime_GetSystemClock(void);
266266

267267
// Get the current time from the system clock.
268268
// On success, set *t and *info (if not NULL), and return 0.
269269
// On error, raise an exception and return -1.
270270
extern int _PyTime_GetSystemClockWithInfo(
271-
_PyTime_t *t,
271+
PyTime_t *t,
272272
_Py_clock_info_t *info);
273273

274274
// Get the time of a monotonic clock, i.e. a clock that cannot go backwards.
@@ -283,7 +283,7 @@ extern int _PyTime_GetSystemClockWithInfo(
283283
// Use _PyTime_GetMonotonicClockWithInfo or the public PyTime_Monotonic()
284284
// to check for failure.
285285
// Export for '_random' shared extension.
286-
PyAPI_FUNC(_PyTime_t) _PyTime_GetMonotonicClock(void);
286+
PyAPI_FUNC(PyTime_t) _PyTime_GetMonotonicClock(void);
287287

288288
// Get the time of a monotonic clock, i.e. a clock that cannot go backwards.
289289
// The clock is not affected by system clock updates. The reference point of
@@ -295,7 +295,7 @@ PyAPI_FUNC(_PyTime_t) _PyTime_GetMonotonicClock(void);
295295
// Return 0 on success, raise an exception and return -1 on error.
296296
// Export for '_testsinglephase' shared extension.
297297
PyAPI_FUNC(int) _PyTime_GetMonotonicClockWithInfo(
298-
_PyTime_t *t,
298+
PyTime_t *t,
299299
_Py_clock_info_t *info);
300300

301301

@@ -319,7 +319,7 @@ PyAPI_FUNC(int) _PyTime_gmtime(time_t t, struct tm *tm);
319319
// Use _PyTime_GetPerfCounterWithInfo() or the public PyTime_PerfCounter
320320
// to check for failure.
321321
// Export for '_lsprof' shared extension.
322-
PyAPI_FUNC(_PyTime_t) _PyTime_GetPerfCounter(void);
322+
PyAPI_FUNC(PyTime_t) _PyTime_GetPerfCounter(void);
323323

324324

325325
// Get the performance counter: clock with the highest available resolution to
@@ -329,7 +329,7 @@ PyAPI_FUNC(_PyTime_t) _PyTime_GetPerfCounter(void);
329329
//
330330
// Return 0 on success, raise an exception and return -1 on error.
331331
extern int _PyTime_GetPerfCounterWithInfo(
332-
_PyTime_t *t,
332+
PyTime_t *t,
333333
_Py_clock_info_t *info);
334334

335335
// Alias for backward compatibility
@@ -343,33 +343,33 @@ extern int _PyTime_GetPerfCounterWithInfo(
343343
// Create a deadline.
344344
// Pseudo code: _PyTime_GetMonotonicClock() + timeout.
345345
// Export for '_ssl' shared extension.
346-
PyAPI_FUNC(_PyTime_t) _PyDeadline_Init(_PyTime_t timeout);
346+
PyAPI_FUNC(PyTime_t) _PyDeadline_Init(PyTime_t timeout);
347347

348348
// Get remaining time from a deadline.
349349
// Pseudo code: deadline - _PyTime_GetMonotonicClock().
350350
// Export for '_ssl' shared extension.
351-
PyAPI_FUNC(_PyTime_t) _PyDeadline_Get(_PyTime_t deadline);
351+
PyAPI_FUNC(PyTime_t) _PyDeadline_Get(PyTime_t deadline);
352352

353353

354354
// --- _PyTimeFraction -------------------------------------------------------
355355

356356
typedef struct {
357-
_PyTime_t numer;
358-
_PyTime_t denom;
357+
PyTime_t numer;
358+
PyTime_t denom;
359359
} _PyTimeFraction;
360360

361361
// Set a fraction.
362362
// Return 0 on success.
363363
// Return -1 if the fraction is invalid.
364364
extern int _PyTimeFraction_Set(
365365
_PyTimeFraction *frac,
366-
_PyTime_t numer,
367-
_PyTime_t denom);
366+
PyTime_t numer,
367+
PyTime_t denom);
368368

369369
// Compute ticks * frac.numer / frac.denom.
370370
// Clamp to [_PyTime_MIN; _PyTime_MAX] on overflow.
371-
extern _PyTime_t _PyTimeFraction_Mul(
372-
_PyTime_t ticks,
371+
extern PyTime_t _PyTimeFraction_Mul(
372+
PyTime_t ticks,
373373
const _PyTimeFraction *frac);
374374

375375
// Compute a clock resolution: frac.numer / frac.denom / 1e9.

Modules/_datetimemodule.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -5131,7 +5131,7 @@ datetime_from_timestamp(PyObject *cls, TM_FUNC f, PyObject *timestamp,
51315131
static PyObject *
51325132
datetime_best_possible(PyObject *cls, TM_FUNC f, PyObject *tzinfo)
51335133
{
5134-
_PyTime_t ts = _PyTime_GetSystemClock();
5134+
PyTime_t ts = _PyTime_GetSystemClock();
51355135
time_t secs;
51365136
int us;
51375137

0 commit comments

Comments
 (0)