Skip to content

Commit a9da6b6

Browse files
committed
Update signatures for the new revision.
1 parent cbd7254 commit a9da6b6

File tree

4 files changed

+30
-29
lines changed

4 files changed

+30
-29
lines changed

Include/cpython/pystate.h

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -286,41 +286,42 @@ PyAPI_FUNC(void) _PyInterpreterState_SetEvalFrameFunc(
286286

287287
typedef uintptr_t PyInterpreterLock;
288288

289-
PyAPI_FUNC(int) PyInterpreterLock_FromCurrent(PyInterpreterLock *ref);
290-
PyAPI_FUNC(PyInterpreterLock) PyInterpreterLock_Copy(PyInterpreterLock ref);
291-
PyAPI_FUNC(int) PyUnstable_InterpreterView_FromDefault(PyInterpreterLock *ref);
292-
PyAPI_FUNC(void) PyInterpreterLock_Release(PyInterpreterLock ref);
293-
PyAPI_FUNC(PyInterpreterState *) PyInterpreterLock_GetInterpreter(PyInterpreterLock ref);
294-
295-
#define PyInterpreterLock_Release(ref) do { \
296-
PyInterpreterLock_Release(ref); \
297-
ref = 0; \
289+
PyAPI_FUNC(PyInterpreterLock) PyInterpreterLock_FromCurrent(void);
290+
PyAPI_FUNC(PyInterpreterLock) PyInterpreterLock_Copy(PyInterpreterLock lock);
291+
PyAPI_FUNC(void) PyInterpreterLock_Release(PyInterpreterLock lock);
292+
PyAPI_FUNC(PyInterpreterState *) PyInterpreterLock_GetInterpreter(PyInterpreterLock lock);
293+
PyAPI_FUNC(PyInterpreterLock) PyInterpreterLock_FromView(PyInterpreterView view);
294+
295+
#define PyInterpreterLock_Release(lock) do { \
296+
PyInterpreterLock_Release(lock); \
297+
ref = 0; \
298298
} while (0)
299299

300-
/* Weak interpreter references */
300+
/* Interpreter views */
301301

302302
typedef struct _PyInterpreterView {
303303
int64_t id;
304304
Py_ssize_t refcount;
305305
} _PyInterpreterView;
306306

307-
typedef _PyInterpreterView *PyInterpreterView;
307+
typedef uintptr_t PyInterpreterView;
308308

309-
PyAPI_FUNC(int) PyInterpreterView_FromCurrent(PyInterpreterView *ptr);
310-
PyAPI_FUNC(PyInterpreterView) PyInterpreterView_Copy(PyInterpreterView wref);
311-
PyAPI_FUNC(int) PyInterpreterLock_FromView(PyInterpreterView wref, PyInterpreterLock *strong_ptr);
312-
PyAPI_FUNC(void) PyInterpreterView_Close(PyInterpreterView wref);
309+
PyAPI_FUNC(PyInterpreterView) PyInterpreterView_FromCurrent(void);
310+
PyAPI_FUNC(PyInterpreterView) PyInterpreterView_Copy(PyInterpreterView view);
311+
PyAPI_FUNC(void) PyInterpreterView_Close(PyInterpreterView view);
312+
PyAPI_FUNC(PyInterpreterView) PyUnstable_InterpreterView_FromDefault(void);
313313

314-
#define PyInterpreterView_Close(ref) do { \
315-
PyInterpreterView_Close(ref); \
316-
ref = 0; \
314+
315+
#define PyInterpreterView_Close(view) do { \
316+
PyInterpreterView_Close(view); \
317+
ref = 0; \
317318
} while (0)
318319

319320

320-
/* Thread references */
321+
/* Thread views */
321322

322323
typedef uintptr_t PyThreadView;
323324

324-
PyAPI_FUNC(int) PyThreadState_Ensure(PyInterpreterLock interp_ref, PyThreadView *thread_ref);
325+
PyAPI_FUNC(PyThreadView) PyThreadState_Ensure(PyInterpreterLock lock);
325326

326327
PyAPI_FUNC(void) PyThreadState_Release(PyThreadView thread_ref);

Include/internal/pycore_interp_structs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,8 +973,8 @@ struct _is {
973973

974974
struct {
975975
_PyRWMutex lock;
976-
Py_ssize_t refcount;
977-
} references;
976+
Py_ssize_t countdown;
977+
} finalization_locks;
978978

979979
/* the initial PyInterpreterState.threads.head */
980980
_PyThreadStateImpl _initial_thread;

Include/internal/pycore_pystate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ _Py_RecursionLimit_GetMargin(PyThreadState *tstate)
330330
}
331331

332332
// Exports for '_testinternalcapi' shared extension
333-
PyAPI_FUNC(Py_ssize_t) _PyInterpreterState_Refcount(PyInterpreterState *interp);
333+
PyAPI_FUNC(Py_ssize_t) _PyInterpreterState_LockCountdown(PyInterpreterState *interp);
334334

335335
#ifdef __cplusplus
336336
}

Modules/_testinternalcapi.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,18 +2424,18 @@ static PyObject *
24242424
test_interp_refcount(PyObject *self, PyObject *unused)
24252425
{
24262426
PyInterpreterState *interp = PyInterpreterState_Get();
2427-
assert(_PyInterpreterState_Refcount(interp) == 0);
2427+
assert(_PyInterpreterState_LockCountdown(interp) == 0);
24282428
PyInterpreterLock refs[NUM_REFS];
24292429
for (int i = 0; i < NUM_REFS; ++i) {
24302430
int res = PyInterpreterLock_FromCurrent(&refs[i]);
24312431
(void)res;
24322432
assert(res == 0);
2433-
assert(_PyInterpreterState_Refcount(interp) == i + 1);
2433+
assert(_PyInterpreterState_LockCountdown(interp) == i + 1);
24342434
}
24352435

24362436
for (int i = 0; i < NUM_REFS; ++i) {
24372437
PyInterpreterLock_Release(refs[i]);
2438-
assert(_PyInterpreterState_Refcount(interp) == (NUM_REFS - i - 1));
2438+
assert(_PyInterpreterState_LockCountdown(interp) == (NUM_REFS - i - 1));
24392439
}
24402440

24412441
Py_RETURN_NONE;
@@ -2449,7 +2449,7 @@ test_interp_weakref_incref(PyObject *self, PyObject *unused)
24492449
if (PyInterpreterView_FromCurrent(&wref) < 0) {
24502450
return NULL;
24512451
}
2452-
assert(_PyInterpreterState_Refcount(interp) == 0);
2452+
assert(_PyInterpreterState_LockCountdown(interp) == 0);
24532453

24542454
PyInterpreterLock refs[NUM_REFS];
24552455

@@ -2458,12 +2458,12 @@ test_interp_weakref_incref(PyObject *self, PyObject *unused)
24582458
(void)res;
24592459
assert(res == 0);
24602460
assert(PyInterpreterLock_GetInterpreter(refs[i]) == interp);
2461-
assert(_PyInterpreterState_Refcount(interp) == i + 1);
2461+
assert(_PyInterpreterState_LockCountdown(interp) == i + 1);
24622462
}
24632463

24642464
for (int i = 0; i < NUM_REFS; ++i) {
24652465
PyInterpreterLock_Release(refs[i]);
2466-
assert(_PyInterpreterState_Refcount(interp) == (NUM_REFS - i - 1));
2466+
assert(_PyInterpreterState_LockCountdown(interp) == (NUM_REFS - i - 1));
24672467
}
24682468

24692469
PyInterpreterView_Close(wref);

0 commit comments

Comments
 (0)