Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add gc shared bits
  • Loading branch information
DinoV committed Feb 3, 2024
commit 482e1a20b95daf97b68d10418da573743682ab60
14 changes: 14 additions & 0 deletions Include/internal/pycore_gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ static inline PyObject* _Py_FROM_GC(PyGC_Head *gc) {
# define _PyGC_BITS_FINALIZED (2)
# define _PyGC_BITS_UNREACHABLE (4)
# define _PyGC_BITS_FROZEN (8)
# define _PyGC_BITS_SHARED (16)
#endif

/* True if the object is currently tracked by the GC. */
Expand All @@ -68,6 +69,19 @@ static inline int _PyObject_GC_MAY_BE_TRACKED(PyObject *obj) {
return 1;
}

#ifdef Py_GIL_DISABLED

static inline int _PyObject_GC_IS_SHARED(PyObject *op) {
Comment thread
DinoV marked this conversation as resolved.
return (op->ob_gc_bits & _PyGC_BITS_SHARED) != 0;
}
#define _PyObject_GC_IS_SHARED(op) _PyObject_GC_IS_SHARED(_Py_CAST(PyObject*, op))

static inline int _PyObject_GC_SET_SHARED(PyObject *op) {
Comment thread
DinoV marked this conversation as resolved.
Outdated
return op->ob_gc_bits |= _PyGC_BITS_SHARED;
}
#define _PyObject_GC_SET_SHARED(op) _PyObject_GC_SET_SHARED(_Py_CAST(PyObject*, op))

#endif

/* Bit flags for _gc_prev */
/* Bit 0 is set when tp_finalize is called */
Expand Down