Files
typthon/Include/internal/pycore_uniqueid.h
copilot-swe-agent[bot] 71cf7bf14f Fix more missed Py_ patterns - opcode, thread, exception
Fixed additional patterns:
- _PyOpcode_* → _TyOpcode_* (all opcode metadata)
- _PyUOpName → _TyUOpName
- _PyFunction_* → _TyFunction_*
- _PyListIterObject → _TyListIterObject
- _Py_T_OBJECT → _Ty_T_OBJECT
- Py_BEGIN_ALLOW_THREADS, Py_END_ALLOW_THREADS → Ty_*
- PyDoc_STRVAR, PyDoc_STR → TyDoc_*
- PyInterpreterState, PyThread_*, PyTime_t → Ty*
- PyStructSequence_* → TyStructSequence_*
- PyLockStatus → TyLockStatus
- PyVarObject_HEAD_INIT → TyVarObject_HEAD_INIT
- PyBaseExceptionObject → TyBaseExceptionObject
- Fixed _PyExc_ → _TyExc_ in exception macros

Build is progressing further.

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
2025-12-29 18:27:36 +00:00

58 lines
1.9 KiB
C

#ifndef Ty_INTERNAL_UNIQUEID_H
#define Ty_INTERNAL_UNIQUEID_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef Ty_BUILD_CORE
# error "this header requires Ty_BUILD_CORE define"
#endif
#ifdef Ty_GIL_DISABLED
// This contains code for allocating unique ids to objects for per-thread
// reference counting.
//
// Per-thread reference counting is used along with deferred reference
// counting to avoid scaling bottlenecks due to reference count contention.
//
// An id of 0 is used to indicate that an object doesn't use per-thread
// refcounting. This value is used when the object is finalized by the GC
// and during interpreter shutdown to allow the object to be
// deallocated promptly when the object's refcount reaches zero.
//
// Each entry implicitly represents a unique id based on its offset in the
// table. Non-allocated entries form a free-list via the 'next' pointer.
// Allocated entries store the corresponding TyObject.
#define _Ty_INVALID_UNIQUE_ID 0
// Assigns the next id from the pool of ids.
extern Ty_ssize_t _TyObject_AssignUniqueId(TyObject *obj);
// Releases the allocated id back to the pool.
extern void _TyObject_ReleaseUniqueId(Ty_ssize_t unique_id);
// Releases the allocated id back to the pool.
extern void _TyObject_DisablePerThreadRefcounting(TyObject *obj);
// Merges the per-thread reference counts into the corresponding objects.
extern void _TyObject_MergePerThreadRefcounts(_PyThreadStateImpl *tstate);
// Like _TyObject_MergePerThreadRefcounts, but also frees the per-thread
// array of refcounts.
extern void _TyObject_FinalizePerThreadRefcounts(_PyThreadStateImpl *tstate);
// Frees the interpreter's pool of type ids.
extern void _TyObject_FinalizeUniqueIdPool(TyInterpreterState *interp);
// Increfs the object, resizing the thread-local refcount array if necessary.
PyAPI_FUNC(void) _TyObject_ThreadIncrefSlow(TyObject *obj, size_t idx);
#endif /* Ty_GIL_DISABLED */
#ifdef __cplusplus
}
#endif
#endif /* !Ty_INTERNAL_UNIQUEID_H */