summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
Diffstat (limited to 'Include')
-rw-r--r--Include/object.h10
-rw-r--r--Include/objimpl.h34
2 files changed, 39 insertions, 5 deletions
diff --git a/Include/object.h b/Include/object.h
index 221b4a2..25b96e8 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -408,6 +408,8 @@ typedef struct _typeobject {
/* Type attribute cache version tag. Added in version 2.6 */
unsigned int tp_version_tag;
+ destructor tp_finalize;
+
#ifdef COUNT_ALLOCS
/* these must be last and never explicitly initialized */
Py_ssize_t tp_allocs;
@@ -529,6 +531,8 @@ PyAPI_FUNC(int) PyObject_Not(PyObject *);
PyAPI_FUNC(int) PyCallable_Check(PyObject *);
PyAPI_FUNC(void) PyObject_ClearWeakRefs(PyObject *);
+PyAPI_FUNC(void) PyObject_CallFinalizer(PyObject *);
+PyAPI_FUNC(int) PyObject_CallFinalizerFromDealloc(PyObject *);
/* Same as PyObject_Generic{Get,Set}Attr, but passing the attributes
dict as the last parameter. */
@@ -646,6 +650,12 @@ given type object has a specified feature.
Py_TPFLAGS_HAVE_VERSION_TAG | \
0)
+/* NOTE: The following flags reuse lower bits (removed as part of the
+ * Python 3.0 transition). */
+
+/* Type structure has tp_finalize member (3.4) */
+#define Py_TPFLAGS_HAVE_FINALIZE (1UL << 0)
+
#ifdef Py_LIMITED_API
#define PyType_HasFeature(t,f) ((PyType_GetFlags(t) & (f)) != 0)
#else
diff --git a/Include/objimpl.h b/Include/objimpl.h
index 4e72a46..264c120 100644
--- a/Include/objimpl.h
+++ b/Include/objimpl.h
@@ -256,6 +256,30 @@ extern PyGC_Head *_PyGC_generation0;
#define _Py_AS_GC(o) ((PyGC_Head *)(o)-1)
+/* Bit 0 is set when tp_finalize is called */
+#define _PyGC_REFS_MASK_FINALIZED (1 << 0)
+/* The (N-1) most significant bits contain the gc state / refcount */
+#define _PyGC_REFS_SHIFT (1)
+#define _PyGC_REFS_MASK (((size_t) -1) << _PyGC_REFS_SHIFT)
+
+#define _PyGCHead_REFS(g) ((g)->gc.gc_refs >> _PyGC_REFS_SHIFT)
+#define _PyGCHead_SET_REFS(g, v) do { \
+ (g)->gc.gc_refs = ((g)->gc.gc_refs & ~_PyGC_REFS_MASK) \
+ | (v << _PyGC_REFS_SHIFT); \
+ } while (0)
+#define _PyGCHead_DECREF(g) ((g)->gc.gc_refs -= 1 << _PyGC_REFS_SHIFT)
+
+#define _PyGCHead_FINALIZED(g) (((g)->gc.gc_refs & _PyGC_REFS_MASK_FINALIZED) != 0)
+#define _PyGCHead_SET_FINALIZED(g, v) do { \
+ (g)->gc.gc_refs = ((g)->gc.gc_refs & ~_PyGC_REFS_MASK_FINALIZED) \
+ | (v != 0); \
+ } while (0)
+
+#define _PyGC_FINALIZED(o) _PyGCHead_FINALIZED(_Py_AS_GC(o))
+#define _PyGC_SET_FINALIZED(o, v) _PyGCHead_SET_FINALIZED(_Py_AS_GC(o), v)
+
+#define _PyGC_REFS(o) _PyGCHead_REFS(_Py_AS_GC(o))
+
#define _PyGC_REFS_UNTRACKED (-2)
#define _PyGC_REFS_REACHABLE (-3)
#define _PyGC_REFS_TENTATIVELY_UNREACHABLE (-4)
@@ -264,9 +288,9 @@ extern PyGC_Head *_PyGC_generation0;
* collector it must be safe to call the ob_traverse method. */
#define _PyObject_GC_TRACK(o) do { \
PyGC_Head *g = _Py_AS_GC(o); \
- if (g->gc.gc_refs != _PyGC_REFS_UNTRACKED) \
+ if (_PyGCHead_REFS(g) != _PyGC_REFS_UNTRACKED) \
Py_FatalError("GC object already tracked"); \
- g->gc.gc_refs = _PyGC_REFS_REACHABLE; \
+ _PyGCHead_SET_REFS(g, _PyGC_REFS_REACHABLE); \
g->gc.gc_next = _PyGC_generation0; \
g->gc.gc_prev = _PyGC_generation0->gc.gc_prev; \
g->gc.gc_prev->gc.gc_next = g; \
@@ -279,8 +303,8 @@ extern PyGC_Head *_PyGC_generation0;
*/
#define _PyObject_GC_UNTRACK(o) do { \
PyGC_Head *g = _Py_AS_GC(o); \
- assert(g->gc.gc_refs != _PyGC_REFS_UNTRACKED); \
- g->gc.gc_refs = _PyGC_REFS_UNTRACKED; \
+ assert(_PyGCHead_REFS(g) != _PyGC_REFS_UNTRACKED); \
+ _PyGCHead_SET_REFS(g, _PyGC_REFS_UNTRACKED); \
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 = NULL; \
@@ -288,7 +312,7 @@ extern PyGC_Head *_PyGC_generation0;
/* True if the object is currently tracked by the GC. */
#define _PyObject_GC_IS_TRACKED(o) \
- ((_Py_AS_GC(o))->gc.gc_refs != _PyGC_REFS_UNTRACKED)
+ (_PyGC_REFS(o) != _PyGC_REFS_UNTRACKED)
/* True if the object may be tracked by the GC in the future, or already is.
This can be useful to implement some optimizations. */
_code_cleanup'>contrib_patrick_fradin_code_cleanup Tcl is a high-level, general-purpose, interpreted, dynamic programming language. It was designed with the goal of being very simple but powerful.
summaryrefslogtreecommitdiffstats
path: root/unix
Commit message (Expand)AuthorAgeFilesLines
* * tests/http.test (http-5.1): bump http to 2.5.3dgp2006-09-161-3/+3
* * unix/configure.in (HAVE_MTSAFE_GETHOST*): Modified to recognizeandreas_kupries2006-09-122-1/+29
* * unix/tclUnixCompat.c (PadBuffer): Fixed bug in calculation ofandreas_kupries2006-09-121-5/+11
* * unix/Makefile.in (install-libraries): Fixed typo tcltest 2.3.9 -> 2.3.0.andreas_kupries2006-09-111-2/+2
* * unix/tclUnixCompat.c: make compatLock static and only declare it whendas2006-09-111-107/+110
* bump msgcat version to 1.4.2Kevin B Kenny2006-09-111-3/+3
* * doc/tcltest.n: Bump to version tcltest 2.3.0 to accountdgp2006-09-111-3/+3
* * library/msgcat/msgcat.tcl (msgcat::Init): on Darwin, add fallback ofdas2006-09-105-598/+703
* Added special handling for Darwin where gethostbyname/addr are actuallyvasiljevic2006-09-083-15/+42
* * unix/tclUnixCompat.c: Fixed conditions for CopyArray/CopyString,andreas_kupries2006-09-081-6/+6
* unix/tclUnixCompat.c: Added fallback to MT-unsafevasiljevic2006-09-071-21/+62
* Rewritten MT-safe wrappers to return ptrs to TSD storage.vasiljevic2006-09-075-217/+161
* Use MODULE_SCOPE declaration where appropriatevasiljevic2006-09-061-7/+7
* Added for fixing Tcl Bug 999544vasiljevic2006-09-061-0/+584
* Added fixes for Tcl Bug 999544 (ported from core-8-4-branch).vasiljevic2006-09-068-14/+2075
* * unix/Makefile.in (valgrindshell): add valgrindshell target andhobbs2006-08-301-2/+9
* Fix for stack.test failures on FreeBSDJoe Mistachkin2006-08-292-13/+5
* fixed [ 1548263 ] NULL return from Tcl_FSGetNormalizedPath segvcoldstore2006-08-291-1/+4
* * unix/tclUnixPort.h (Darwin): override potentially faulty configuredas2006-08-211-7/+13
* * generic/tclClock.c (ClockClicksObjCmd): add support for Darwindas2006-08-214-2/+104
* * macosx/tclMacOSXNotify.c (Tcl_WaitForEvent): if the run loop isdas2006-08-211-2/+12
* * unix/tclUnixChan.c (TclUnixWaitForFile): with timeout < 0, if select()das2006-08-181-1/+4
* * unix/tcl.m4 (Darwin): add support for --enable-64bit on x86_64, fordas2006-08-185-34/+161
* Various minor object file size efficiency fixes. [Bug 1530474]dkf2006-08-10