bpo-35081: Add Include/internal/pycore_object.h (GH-10640) · python/cpython@bcda8f1

@@ -323,51 +323,6 @@ typedef struct {

323323

_PyGCHead_SET_FINALIZED(_Py_AS_GC(o))

324324

#endif /* !defined(Py_LIMITED_API) */

325325326-327-

#if defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_BUILTIN)

328-

/* Tell the GC to track this object.

329-

*

330-

* NB: While the object is tracked by the collector, it must be safe to call the

331-

* ob_traverse method.

332-

*

333-

* Internal note: _PyRuntime.gc.generation0->_gc_prev doesn't have any bit flags

334-

* because it's not object header. So we don't use _PyGCHead_PREV() and

335-

* _PyGCHead_SET_PREV() for it to avoid unnecessary bitwise operations.

336-

*

337-

* The PyObject_GC_Track() function is the public version of this macro.

338-

*/

339-

#define _PyObject_GC_TRACK(o) do { \

340-

PyGC_Head *g = _Py_AS_GC(o); \

341-

if (g->_gc_next != 0) { \

342-

Py_FatalError("GC object already tracked"); \

343-

} \

344-

assert((g->_gc_prev & _PyGC_PREV_MASK_COLLECTING) == 0); \

345-

PyGC_Head *last = (PyGC_Head*)(_PyRuntime.gc.generation0->_gc_prev); \

346-

_PyGCHead_SET_NEXT(last, g); \

347-

_PyGCHead_SET_PREV(g, last); \

348-

_PyGCHead_SET_NEXT(g, _PyRuntime.gc.generation0); \

349-

_PyRuntime.gc.generation0->_gc_prev = (uintptr_t)g; \

350-

} while (0);

351-352-

/* Tell the GC to stop tracking this object.

353-

*

354-

* Internal note: This may be called while GC. So _PyGC_PREV_MASK_COLLECTING must

355-

* be cleared. But _PyGC_PREV_MASK_FINALIZED bit is kept.

356-

*

357-

* The PyObject_GC_UnTrack() function is the public version of this macro.

358-

*/

359-

#define _PyObject_GC_UNTRACK(o) do { \

360-

PyGC_Head *g = _Py_AS_GC(o); \

361-

PyGC_Head *prev = _PyGCHead_PREV(g); \

362-

PyGC_Head *next = _PyGCHead_NEXT(g); \

363-

assert(next != NULL); \

364-

_PyGCHead_SET_NEXT(prev, next); \

365-

_PyGCHead_SET_PREV(next, prev); \

366-

g->_gc_next = 0; \

367-

g->_gc_prev &= _PyGC_PREV_MASK_FINALIZED; \

368-

} while (0);

369-

#endif /* defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_BUILTIN) */

370-371326

#ifndef Py_LIMITED_API

372327

PyAPI_FUNC(PyObject *) _PyObject_GC_Malloc(size_t size);

373328

PyAPI_FUNC(PyObject *) _PyObject_GC_Calloc(size_t size);