mirror of https://github.com/python/cpython
Removed WITH_CYCLE_GC #ifdef-ery. Holes:
+ I'm not sure what to do about configure.in. Left it alone. + Ditto pyexpat.c. Fred or Martin will know what to do.
This commit is contained in:
parent
12f4f35f6e
commit
943382c8e5
|
@ -23,6 +23,14 @@
|
|||
#include "patchlevel.h"
|
||||
#include "pyconfig.h"
|
||||
|
||||
/* Cyclic gc is always enabled, starting with release 2.3a1. Supply the
|
||||
* old symbol for the benefit of extension modules written before then
|
||||
* that may be conditionalizing on it. The core doesn't use it anymore.
|
||||
*/
|
||||
#ifndef WITH_CYCLE_GC
|
||||
#define WITH_CYCLE_GC 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
|
|
@ -441,11 +441,7 @@ given type object has a specified feature.
|
|||
#define Py_TPFLAGS_READYING (1L<<13)
|
||||
|
||||
/* Objects support garbage collection (see objimp.h) */
|
||||
#ifdef WITH_CYCLE_GC
|
||||
#define Py_TPFLAGS_HAVE_GC (1L<<14)
|
||||
#else
|
||||
#define Py_TPFLAGS_HAVE_GC 0
|
||||
#endif
|
||||
|
||||
#define Py_TPFLAGS_DEFAULT ( \
|
||||
Py_TPFLAGS_HAVE_GETCHARBUFFER | \
|
||||
|
|
|
@ -226,10 +226,6 @@ extern DL_IMPORT(PyVarObject *) _PyObject_NewVar(PyTypeObject *, int);
|
|||
/*
|
||||
* Garbage Collection Support
|
||||
* ==========================
|
||||
*
|
||||
* Some of the functions and macros below are always defined; when
|
||||
* WITH_CYCLE_GC is undefined, they simply don't do anything different
|
||||
* than their non-GC counterparts.
|
||||
*/
|
||||
|
||||
/* Test if a type has a GC head */
|
||||
|
@ -246,8 +242,6 @@ extern DL_IMPORT(PyVarObject *) _PyObject_GC_Resize(PyVarObject *, int);
|
|||
/* for source compatibility with 2.2 */
|
||||
#define _PyObject_GC_Del PyObject_GC_Del
|
||||
|
||||
#ifdef WITH_CYCLE_GC
|
||||
|
||||
/* GC information is stored BEFORE the object structure. */
|
||||
typedef union _gc_head {
|
||||
struct {
|
||||
|
@ -305,19 +299,6 @@ extern DL_IMPORT(void) PyObject_GC_Del(void *);
|
|||
( (type *) _PyObject_GC_NewVar((typeobj), (n)) )
|
||||
|
||||
|
||||
#else /* !WITH_CYCLE_GC */
|
||||
|
||||
#define _PyObject_GC_Malloc PyObject_Malloc
|
||||
#define PyObject_GC_New PyObject_New
|
||||
#define PyObject_GC_NewVar PyObject_NewVar
|
||||
#define PyObject_GC_Del PyObject_Del
|
||||
#define _PyObject_GC_TRACK(op)
|
||||
#define _PyObject_GC_UNTRACK(op)
|
||||
#define PyObject_GC_Track(op)
|
||||
#define PyObject_GC_UnTrack(op)
|
||||
|
||||
#endif
|
||||
|
||||
/* This is here for the sake of backwards compatibility. Extensions that
|
||||
* use the old GC API will still compile but the objects will not be
|
||||
* tracked by the GC. */
|
||||
|
|
14
Misc/NEWS
14
Misc/NEWS
|
@ -170,6 +170,11 @@ Extension modules
|
|||
|
||||
Library
|
||||
|
||||
- binascii.crc32() and the zipfile module had problems on some 64-bit
|
||||
platforms. These have been fixed. On a platform with 8-byte C longs,
|
||||
crc32() now returns a signed-extended 4-byte result, so that its value
|
||||
as a Python int is equal to the value computed a 32-bit platform.
|
||||
|
||||
- xml.dom.minidom.toxml and toprettyxml now take an optional encoding
|
||||
argument.
|
||||
|
||||
|
@ -289,6 +294,15 @@ Tools/Demos
|
|||
|
||||
Build
|
||||
|
||||
- Compiling out the cyclic garbage collector is no longer an option.
|
||||
The old symbol WITH_CYCLE_GC is now ignored, and Python.h arranges
|
||||
that it's always defined (for the benefit of any extension modules
|
||||
that may be conditionalizing on it). A bonus is that any extension
|
||||
type participating in cyclic gc can choose to participate in the
|
||||
Py_TRASHCAN mechanism now too; in the absence of cyclic gc, this used
|
||||
to require editing the core to teach the trashcan mechanism about the
|
||||
new type.
|
||||
|
||||
- Accoring to Annex F of the current C standard,
|
||||
|
||||
The Standard C macro HUGE_VAL and its float and long double analogs,
|
||||
|
|
|
@ -40,10 +40,8 @@ struct _inittab _PyImport_Inittab[] = {
|
|||
{"sys", NULL},
|
||||
{"exceptions", NULL},
|
||||
|
||||
#ifdef WITH_CYCLE_GC
|
||||
/* This lives in gcmodule.c */
|
||||
{"gc", initgc},
|
||||
#endif
|
||||
|
||||
/* Sentinel */
|
||||
{0, 0}
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
|
||||
#include "Python.h"
|
||||
|
||||
#ifdef WITH_CYCLE_GC
|
||||
|
||||
/* Get an object's GC head */
|
||||
#define AS_GC(o) ((PyGC_Head *)(o)-1)
|
||||
|
||||
|
@ -941,8 +939,6 @@ void _PyGC_Dump(PyGC_Head *g)
|
|||
_PyObject_Dump(FROM_GC(g));
|
||||
}
|
||||
|
||||
#endif /* WITH_CYCLE_GC */
|
||||
|
||||
/* extension modules might be compiled with GC support so these
|
||||
functions must always be available */
|
||||
|
||||
|
@ -967,10 +963,8 @@ _PyObject_GC_Track(PyObject *op)
|
|||
void
|
||||
PyObject_GC_UnTrack(void *op)
|
||||
{
|
||||
#ifdef WITH_CYCLE_GC
|
||||
if (IS_TRACKED(op))
|
||||
_PyObject_GC_UNTRACK(op);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* for binary compatibility with 2.2 */
|
||||
|
@ -984,7 +978,6 @@ PyObject *
|
|||
_PyObject_GC_Malloc(size_t basicsize)
|
||||
{
|
||||
PyObject *op;
|
||||
#ifdef WITH_CYCLE_GC
|
||||
PyGC_Head *g = PyObject_MALLOC(sizeof(PyGC_Head) + basicsize);
|
||||
if (g == NULL)
|
||||
return PyErr_NoMemory();
|
||||
|
@ -1000,12 +993,6 @@ _PyObject_GC_Malloc(size_t basicsize)
|
|||
collecting = 0;
|
||||
}
|
||||
op = FROM_GC(g);
|
||||
#else
|
||||
op = PyObject_MALLOC(basicsize);
|
||||
if (op == NULL)
|
||||
return PyErr_NoMemory();
|
||||
|
||||
#endif
|
||||
return op;
|
||||
}
|
||||
|
||||
|
@ -1032,17 +1019,11 @@ PyVarObject *
|
|||
_PyObject_GC_Resize(PyVarObject *op, int nitems)
|
||||
{
|
||||
const size_t basicsize = _PyObject_VAR_SIZE(op->ob_type, nitems);
|
||||
#ifdef WITH_CYCLE_GC
|
||||
PyGC_Head *g = AS_GC(op);
|
||||
g = PyObject_REALLOC(g, sizeof(PyGC_Head) + basicsize);
|
||||
if (g == NULL)
|
||||
return (PyVarObject *)PyErr_NoMemory();
|
||||
op = (PyVarObject *) FROM_GC(g);
|
||||
#else
|
||||
op = PyObject_REALLOC(op, basicsize);
|
||||
if (op == NULL)
|
||||
return (PyVarObject *)PyErr_NoMemory();
|
||||
#endif
|
||||
op->ob_size = nitems;
|
||||
return op;
|
||||
}
|
||||
|
@ -1050,7 +1031,6 @@ _PyObject_GC_Resize(PyVarObject *op, int nitems)
|
|||
void
|
||||
PyObject_GC_Del(void *op)
|
||||
{
|
||||
#ifdef WITH_CYCLE_GC
|
||||
PyGC_Head *g = AS_GC(op);
|
||||
if (IS_TRACKED(op))
|
||||
gc_list_remove(g);
|
||||
|
@ -1058,9 +1038,6 @@ PyObject_GC_Del(void *op)
|
|||
generations[0].count--;
|
||||
}
|
||||
PyObject_FREE(g);
|
||||
#else
|
||||
PyObject_FREE(op);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* for binary compatibility with 2.2 */
|
||||
|
|
|
@ -678,9 +678,6 @@ instance_dealloc(register PyInstanceObject *inst)
|
|||
/* compensate for increment in _Py_ForgetReference */
|
||||
inst->ob_type->tp_frees--;
|
||||
#endif
|
||||
#ifndef WITH_CYCLE_GC
|
||||
inst->ob_type = NULL;
|
||||
#endif
|
||||
#endif
|
||||
Py_DECREF(inst->in_class);
|
||||
Py_XDECREF(inst->in_dict);
|
||||
|
|
|
@ -2080,29 +2080,8 @@ PyObject * _PyTrash_delete_later = NULL;
|
|||
void
|
||||
_PyTrash_deposit_object(PyObject *op)
|
||||
{
|
||||
#ifndef WITH_CYCLE_GC
|
||||
int typecode;
|
||||
|
||||
if (PyTuple_Check(op))
|
||||
typecode = Py_TRASHCAN_TUPLE;
|
||||
else if (PyList_Check(op))
|
||||
typecode = Py_TRASHCAN_LIST;
|
||||
else if (PyDict_Check(op))
|
||||
typecode = Py_TRASHCAN_DICT;
|
||||
else if (PyFrame_Check(op))
|
||||
typecode = Py_TRASHCAN_FRAME;
|
||||
else if (PyTraceBack_Check(op))
|
||||
typecode = Py_TRASHCAN_TRACEBACK;
|
||||
else /* We have a bug here -- those are the only types in GC */ {
|
||||
Py_FatalError("Type not supported in GC -- internal bug");
|
||||
return; /* pacify compiler -- execution never here */
|
||||
}
|
||||
op->ob_refcnt = typecode;
|
||||
op->ob_type = (PyTypeObject*)_PyTrash_delete_later;
|
||||
#else
|
||||
assert (_Py_AS_GC(op)->gc.gc_next == NULL);
|
||||
_Py_AS_GC(op)->gc.gc_prev = (PyGC_Head *)_PyTrash_delete_later;
|
||||
#endif
|
||||
_PyTrash_delete_later = op;
|
||||
}
|
||||
|
||||
|
@ -2112,30 +2091,8 @@ _PyTrash_destroy_chain(void)
|
|||
while (_PyTrash_delete_later) {
|
||||
PyObject *shredder = _PyTrash_delete_later;
|
||||
|
||||
#ifndef WITH_CYCLE_GC
|
||||
_PyTrash_delete_later = (PyObject*) shredder->ob_type;
|
||||
|
||||
switch (shredder->ob_refcnt) {
|
||||
case Py_TRASHCAN_TUPLE:
|
||||
shredder->ob_type = &PyTuple_Type;
|
||||
break;
|
||||
case Py_TRASHCAN_LIST:
|
||||
shredder->ob_type = &PyList_Type;
|
||||
break;
|
||||
case Py_TRASHCAN_DICT:
|
||||
shredder->ob_type = &PyDict_Type;
|
||||
break;
|
||||
case Py_TRASHCAN_FRAME:
|
||||
shredder->ob_type = &PyFrame_Type;
|
||||
break;
|
||||
case Py_TRASHCAN_TRACEBACK:
|
||||
shredder->ob_type = &PyTraceBack_Type;
|
||||
break;
|
||||
}
|
||||
#else
|
||||
_PyTrash_delete_later =
|
||||
(PyObject*) _Py_AS_GC(shredder)->gc.gc_prev;
|
||||
#endif
|
||||
|
||||
_Py_NewReference(shredder);
|
||||
|
||||
|
|
|
@ -12,9 +12,7 @@ extern void initaudioop(void);
|
|||
extern void initbinascii(void);
|
||||
extern void initcmath(void);
|
||||
extern void initerrno(void);
|
||||
#ifdef WITH_CYCLE_GC
|
||||
extern void initgc(void);
|
||||
#endif
|
||||
#ifndef MS_WIN64
|
||||
extern void initimageop(void);
|
||||
#endif
|
||||
|
@ -63,9 +61,7 @@ struct _inittab _PyImport_Inittab[] = {
|
|||
{"binascii", initbinascii},
|
||||
{"cmath", initcmath},
|
||||
{"errno", initerrno},
|
||||
#ifdef WITH_CYCLE_GC
|
||||
{"gc", initgc},
|
||||
#endif
|
||||
#ifndef MS_WIN64
|
||||
{"imageop", initimageop},
|
||||
#endif
|
||||
|
|
|
@ -499,9 +499,6 @@ typedef int pid_t;
|
|||
#define HAVE_USABLE_WCHAR_T
|
||||
#endif
|
||||
|
||||
/* Define if you want cycle garbage collection */
|
||||
#define WITH_CYCLE_GC 1
|
||||
|
||||
/* Use Python's own small-block memory-allocator. */
|
||||
#define WITH_PYMALLOC 1
|
||||
|
||||
|
|
|
@ -65,10 +65,8 @@ struct _inittab _PyImport_Inittab[] = {
|
|||
{"sys", NULL},
|
||||
{"exceptions", NULL},
|
||||
|
||||
#ifdef WITH_CYCLE_GC
|
||||
/* This lives in gcmodule.c */
|
||||
{"gc", initgc},
|
||||
#endif
|
||||
|
||||
/* Sentinel */
|
||||
{0, 0}
|
||||
|
|
|
@ -236,9 +236,6 @@
|
|||
one supplied by Python itself. (see Include/unicodectype.h). */
|
||||
#undef WANT_WCTYPE_FUNCTIONS
|
||||
|
||||
/* Define if you want to compile in cycle garbage collection */
|
||||
#define WITH_CYCLE_GC 1
|
||||
|
||||
/* Define if you want to emulate SGI (IRIX 4) dynamic linking.
|
||||
This is rumoured to work on VAX (Ultrix), Sun3 (SunOS 3.4),
|
||||
Sequent Symmetry (Dynix), and Atari ST.
|
||||
|
|
Loading…
Reference in New Issue