mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Add _Py_AS_GC macro. It will be used by the trashcan code on object.c.
This commit is contained in:
parent
bd02b14255
commit
ef99723b66
1 changed files with 4 additions and 2 deletions
|
@ -235,10 +235,12 @@ typedef union _gc_head {
|
||||||
|
|
||||||
extern PyGC_Head _PyGC_generation0;
|
extern PyGC_Head _PyGC_generation0;
|
||||||
|
|
||||||
|
#define _Py_AS_GC(o) ((PyGC_Head *)(o)-1)
|
||||||
|
|
||||||
/* Tell the GC to track this object. NB: While the object is tracked the
|
/* Tell the GC to track this object. NB: While the object is tracked the
|
||||||
* collector it must be safe to call the ob_traverse method. */
|
* collector it must be safe to call the ob_traverse method. */
|
||||||
#define _PyObject_GC_TRACK(o) do { \
|
#define _PyObject_GC_TRACK(o) do { \
|
||||||
PyGC_Head *g = (PyGC_Head *)(o)-1; \
|
PyGC_Head *g = _Py_AS_GC(o); \
|
||||||
if (g->gc.gc_next != NULL) \
|
if (g->gc.gc_next != NULL) \
|
||||||
Py_FatalError("GC object already in linked list"); \
|
Py_FatalError("GC object already in linked list"); \
|
||||||
g->gc.gc_next = &_PyGC_generation0; \
|
g->gc.gc_next = &_PyGC_generation0; \
|
||||||
|
@ -249,7 +251,7 @@ extern PyGC_Head _PyGC_generation0;
|
||||||
|
|
||||||
/* Tell the GC to stop tracking this object. */
|
/* Tell the GC to stop tracking this object. */
|
||||||
#define _PyObject_GC_UNTRACK(o) do { \
|
#define _PyObject_GC_UNTRACK(o) do { \
|
||||||
PyGC_Head *g = (PyGC_Head *)(o)-1; \
|
PyGC_Head *g = _Py_AS_GC(o); \
|
||||||
g->gc.gc_prev->gc.gc_next = g->gc.gc_next; \
|
g->gc.gc_prev->gc.gc_next = g->gc.gc_next; \
|
||||||
g->gc.gc_next->gc.gc_prev = g->gc.gc_prev; \
|
g->gc.gc_next->gc.gc_prev = g->gc.gc_prev; \
|
||||||
g->gc.gc_next = NULL; \
|
g->gc.gc_next = NULL; \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue