]> granicus.if.org Git - python/commitdiff
Removed WITH_CYCLE_GC #ifdef-ery. Holes:
authorTim Peters <tim.peters@gmail.com>
Sun, 7 Jul 2002 03:59:34 +0000 (03:59 +0000)
committerTim Peters <tim.peters@gmail.com>
Sun, 7 Jul 2002 03:59:34 +0000 (03:59 +0000)
+ I'm not sure what to do about configure.in.  Left it alone.

+ Ditto pyexpat.c.  Fred or Martin will know what to do.

12 files changed:
Include/Python.h
Include/object.h
Include/objimpl.h
Misc/NEWS
Modules/config.c.in
Modules/gcmodule.c
Objects/classobject.c
Objects/object.c
PC/config.c
PC/pyconfig.h
RISCOS/Modules/config.c
RISCOS/pyconfig.h

index ff21ad1b85e0282da7558042915d266f4447f05d..d4afdaf76bfef1b777d299d081d63e2720b6ddb2 100644 (file)
 #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
index a742fd8764a82cb345e9b1b030ce4ce86a382fa1..7bb1eacb81fe0638a29afab7f17035014a9357ca 100644 (file)
@@ -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 | \
index 3a7488a3223f360d387d591b0772a223e7b277df..730b032adc14ceeb0229658e02beda1addd1b8a9 100644 (file)
@@ -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. */
index c8bda833f0d5436994b987a0acb8d364bac1419e..2d323eabcb549949f83330c76e681a701540e93c 100644 (file)
--- a/Misc/NEWS
+++ b/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,
index 0218c8dfba35cd8b059c8e93696064e28bf3e664..3b4d037a4e4624ae01f313edf9a6e8508efb1ae9 100644 (file)
@@ -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}
index c81a35299932c86d19b0a0d4569c965b124ba5e4..5685101bb6ceb3bfdce7ec9713128cdcb039901c 100644 (file)
@@ -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 */
index 88bd20c29e5b3bc33eb730eee873d35e9d1c5392..90a0e22dd46fbd011801628cf7df574a49c831a0 100644 (file)
@@ -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);
index 206746b9184b315e374596806575f94d681e5d1d..8d670c9c941672a363956bab24502c77bbe744ea 100644 (file)
@@ -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);
 
index 38c6b509970374a4437357520c6ad66782a1d57e..64eb9623d659d46f914c91d36d81dcf4e8c78e8a 100644 (file)
@@ -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
index ac043ebcd2df6885d3c0da413606de24c228b61f..547a567e2d554840f26d1359d49f1a266a795e68 100644 (file)
@@ -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
 
index 03f6e3ce46fa3c5b4de2069de1a1e51ce12ae014..54fbc7909cddc75427a4ccab3e3b41197fb0588d 100644 (file)
@@ -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}
index a8cc8c7eb7209efa88c9d62265cec3cad03f19b2..e7c3484e0d9c180998985eba7e926fae957cb153 100644 (file)
    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.