diff -r -C 2 Python-1.5.1/Include/mymalloc.h Python-1.5.1-gc-no-refcnt/Include/mymalloc.h *** Python-1.5.1/Include/mymalloc.h Thu Aug 21 09:13:37 1997 --- Python-1.5.1-gc-no-refcnt/Include/mymalloc.h Mon Nov 30 05:22:35 1998 *************** *** 88,91 **** --- 88,98 ---- #endif + #include "/usr/src/gc/gc.h" + + #define malloc(n) GC_malloc(n) + #define calloc(m,n) GC_malloc((m)*(n)) + #define realloc(o,n) GC_realloc(o,n) + #define free(n) GC_free(n) + #define PyMem_NEW(type, n) \ ( (type *) malloc(_PyMem_EXTRA + (n) * sizeof(type)) ) diff -r -C 2 Python-1.5.1/Include/object.h Python-1.5.1-gc-no-refcnt/Include/object.h *** Python-1.5.1/Include/object.h Fri Apr 10 15:32:24 1998 --- Python-1.5.1-gc-no-refcnt/Include/object.h Mon Nov 30 06:31:40 1998 *************** *** 95,98 **** --- 95,103 ---- #endif /* Py_DEBUG */ + #ifdef Py_USE_GC + #define PyObject_HEAD \ + struct _typeobject *ob_type; + #define PyObject_HEAD_INIT(type) type, + #else #ifdef Py_TRACE_REFS #define PyObject_HEAD \ *************** *** 107,110 **** --- 112,116 ---- #define PyObject_HEAD_INIT(type) 1, type, #endif /* !Py_TRACE_REFS */ + #endif /* !Py_USE_GC */ #define PyObject_VAR_HEAD \ *************** *** 360,363 **** --- 366,372 ---- #else /* !Py_REF_DEBUG */ + #ifdef Py_USE_GC + #define _Py_NewReference(op) + #else #ifdef COUNT_ALLOCS #define _Py_NewReference(op) (inc_count((op)->ob_type), (op)->ob_refcnt = 1) *************** *** 365,368 **** --- 374,383 ---- #define _Py_NewReference(op) ((op)->ob_refcnt = 1) #endif + #endif /* !Py_USE_GC */ + + #ifdef Py_USE_GC + #define Py_INCREF(op) + #define Py_DECREF(op) + #else #define Py_INCREF(op) ((op)->ob_refcnt++) *************** *** 373,381 **** --- 388,405 ---- _Py_Dealloc((PyObject *)(op)) #endif /* !Py_REF_DEBUG */ + #endif /* !Py_USE_GC */ /* Macros to use in case the object pointer may be NULL: */ + + #ifdef Py_USE_GC + #define Py_XINCREF(op) + #define Py_XDECREF(op) + #else + #define Py_XINCREF(op) if ((op) == NULL) ; else Py_INCREF(op) #define Py_XDECREF(op) if ((op) == NULL) ; else Py_DECREF(op) + + #endif /* !Py_USE_GC */ /* Definition of NULL, so you don't have to include */ Only in Python-1.5.1-gc-no-refcnt: Makefile Only in Python-1.5.1-gc-no-refcnt/Modules: Makefile Only in Python-1.5.1-gc-no-refcnt/Modules: Setup Only in Python-1.5.1-gc-no-refcnt/Modules: Setup.local Only in Python-1.5.1-gc-no-refcnt/Modules: Setup.thread diff -r -C 2 Python-1.5.1/Modules/cPickle.c Python-1.5.1-gc-no-refcnt/Modules/cPickle.c *** Python-1.5.1/Modules/cPickle.c Fri Apr 3 13:13:02 1998 --- Python-1.5.1-gc-no-refcnt/Modules/cPickle.c Mon Nov 30 06:30:51 1998 *************** *** 549,553 **** --- 549,555 ---- static int put(Picklerobject *self, PyObject *ob) { + #ifndef Py_USE_GC if (ob->ob_refcnt < 2) + #endif return 0; *************** *** 1527,1531 **** --- 1529,1537 ---- } + #ifdef Py_USE_GC + if (1) { + #else if (args->ob_refcnt > 1) { + #endif long ob_id; int has_key; Only in Python-1.5.1/Modules: glmodule.c Only in Python-1.5.1-gc-no-refcnt/Objects: Makefile diff -r -C 2 Python-1.5.1/Objects/classobject.c Python-1.5.1-gc-no-refcnt/Objects/classobject.c *** Python-1.5.1/Objects/classobject.c Tue Dec 2 16:06:02 1997 --- Python-1.5.1-gc-no-refcnt/Objects/classobject.c Mon Nov 30 06:11:45 1998 *************** *** 465,468 **** --- 465,470 ---- /* Restore the saved exception and undo the temporary revival */ PyErr_Restore(error_type, error_value, error_traceback); + + #ifndef Py_USE_GC /* Can't use DECREF here, it would cause a recursive call */ if (--inst->ob_refcnt > 0) { *************** *** 472,475 **** --- 474,479 ---- return; /* __del__ added a reference; don't delete now */ } + #endif /* Py_USE_GC */ + #ifdef Py_TRACE_REFS #ifdef COUNT_ALLOCS diff -r -C 2 Python-1.5.1/Objects/fileobject.c Python-1.5.1-gc-no-refcnt/Objects/fileobject.c *** Python-1.5.1/Objects/fileobject.c Fri Apr 10 15:16:34 1998 --- Python-1.5.1-gc-no-refcnt/Objects/fileobject.c Mon Nov 30 06:14:11 1998 *************** *** 629,635 **** --- 629,637 ---- } else if (s[len-1] == '\n') { + #ifndef Py_USE_GC if (result->ob_refcnt == 1) _PyString_Resize(&result, len-1); else { + #endif PyObject *v; v = PyString_FromStringAndSize(s, *************** *** 637,641 **** --- 639,645 ---- Py_DECREF(result); result = v; + #ifndef Py_USE_GC } + #endif } } diff -r -C 2 Python-1.5.1/Objects/longobject.c Python-1.5.1-gc-no-refcnt/Objects/longobject.c *** Python-1.5.1/Objects/longobject.c Fri Apr 10 15:16:36 1998 --- Python-1.5.1-gc-no-refcnt/Objects/longobject.c Mon Nov 30 06:14:39 1998 *************** *** 570,574 **** --- 570,576 ---- assert(size_v >= size_w && size_w > 1); /* Assert checks by div() */ + #ifndef Py_USE_GC assert(v->ob_refcnt == 1); /* Since v will be used as accumulator! */ + #endif assert(size_w == ABS(w->ob_size)); /* That's how d was calculated */ diff -r -C 2 Python-1.5.1/Objects/object.c Python-1.5.1-gc-no-refcnt/Objects/object.c *** Python-1.5.1/Objects/object.c Sat Apr 11 08:17:34 1998 --- Python-1.5.1-gc-no-refcnt/Objects/object.c Mon Nov 30 06:15:37 1998 *************** *** 167,174 **** --- 167,178 ---- } else { + #ifndef Py_USE_GC if (op->ob_refcnt <= 0) fprintf(fp, "", op->ob_refcnt, (long)op); else if (op->ob_type->tp_print == NULL) { + #else + if (op->ob_type->tp_print == NULL) { + #endif if (op->ob_type->tp_repr == NULL) { fprintf(fp, "<%s object at %lx>", diff -r -C 2 Python-1.5.1/Objects/stringobject.c Python-1.5.1-gc-no-refcnt/Objects/stringobject.c *** Python-1.5.1/Objects/stringobject.c Fri Apr 10 15:16:39 1998 --- Python-1.5.1-gc-no-refcnt/Objects/stringobject.c Mon Nov 30 07:23:05 1998 *************** *** 578,581 **** --- 578,589 ---- register PyStringObject *sv; v = *pv; + + #ifdef Py_USE_GC + if (!PyString_Check(v)) { + *pv = 0; + PyErr_BadInternalCall(); + return -1; + } + #else if (!PyString_Check(v) || v->ob_refcnt != 1) { *pv = 0; *************** *** 584,587 **** --- 592,596 ---- return -1; } + #endif /* XXX UNREF/NEWREF interface should be more symmetrical */ #ifdef Py_REF_DEBUG *************** *** 1096,1099 **** --- 1105,1109 ---- nullstring = NULL; #endif + #ifndef Py_USE_GC #ifdef INTERN_STRINGS if (interned) { *************** *** 1111,1114 **** --- 1121,1125 ---- } while (changed); } + #endif #endif } diff -r -C 2 Python-1.5.1/Objects/tupleobject.c Python-1.5.1-gc-no-refcnt/Objects/tupleobject.c *** Python-1.5.1/Objects/tupleobject.c Sun Aug 17 09:25:45 1997 --- Python-1.5.1-gc-no-refcnt/Objects/tupleobject.c Mon Nov 30 07:15:50 1998 *************** *** 134,137 **** --- 134,145 ---- register PyObject *olditem; register PyObject **p; + + #ifdef Py_USE_GC + /* Not sure if any code *expects* to call this with refcnt > 1 */ + if (!PyTuple_Check(op)) { + PyErr_BadInternalCall(); + return -1; + } + #else if (!PyTuple_Check(op) || op->ob_refcnt != 1) { Py_XDECREF(newitem); *************** *** 139,142 **** --- 147,151 ---- return -1; } + #endif if (i < 0 || i >= ((PyTupleObject *)op) -> ob_size) { Py_XDECREF(newitem); *************** *** 420,423 **** --- 429,437 ---- v = (PyTupleObject *) *pv; + #ifdef Py_USE_GC + *pv = 0; + PyErr_BadInternalCall(); + return -1; + #else if (v == NULL || !PyTuple_Check(v) || v->ob_refcnt != 1) { *pv = 0; *************** *** 426,429 **** --- 440,444 ---- return -1; } + #endif sizediff = newsize - v->ob_size; if (sizediff == 0) Only in Python-1.5.1-gc-no-refcnt/Parser: Makefile Only in Python-1.5.1-gc-no-refcnt/Parser: intrcheck.i Only in Python-1.5.1-gc-no-refcnt/Python: Makefile diff -r -C 2 Python-1.5.1/Python/bltinmodule.c Python-1.5.1-gc-no-refcnt/Python/bltinmodule.c *** Python-1.5.1/Python/bltinmodule.c Fri Apr 10 15:25:25 1998 --- Python-1.5.1-gc-no-refcnt/Python/bltinmodule.c Mon Nov 30 06:25:42 1998 *************** *** 154,157 **** --- 154,158 ---- goto Fail_2; + #ifndef Py_USE_GC if (PyList_Check(seq) && seq->ob_refcnt == 1) { Py_INCREF(seq); *************** *** 162,165 **** --- 163,170 ---- goto Fail_2; } + #else + if ((result = PyList_New(len)) == NULL) + goto Fail_2; + #endif for (i = j = 0; ; ++i) { *************** *** 1414,1418 **** --- 1419,1427 ---- PyObject *op2; + #ifdef Py_USE_GC + if (1) { + #else if (args->ob_refcnt > 1) { + #endif Py_DECREF(args); if ((args = PyTuple_New(2)) == NULL) diff -r -C 2 Python-1.5.1/Python/import.c Python-1.5.1-gc-no-refcnt/Python/import.c *** Python-1.5.1/Python/import.c Sat Apr 11 10:38:22 1998 --- Python-1.5.1-gc-no-refcnt/Python/import.c Mon Nov 30 06:27:50 1998 *************** *** 269,272 **** --- 269,273 ---- /* Next, repeatedly delete modules with a reference count of one (skipping __builtin__ and sys) and delete them */ + #ifndef Py_USE_GC do { ndone = 0; *************** *** 290,294 **** } } while (ndone > 0); ! /* Next, delete all modules (still skipping __builtin__ and sys) */ pos = 0; --- 291,295 ---- } } while (ndone > 0); ! #endif /* Next, delete all modules (still skipping __builtin__ and sys) */ pos = 0; diff -r -C 2 Python-1.5.1/Python/sysmodule.c Python-1.5.1-gc-no-refcnt/Python/sysmodule.c *** Python-1.5.1/Python/sysmodule.c Thu Feb 19 12:53:06 1998 --- Python-1.5.1-gc-no-refcnt/Python/sysmodule.c Mon Nov 30 06:28:29 1998 *************** *** 188,191 **** --- 188,192 ---- #endif /* USE_MALLOPT */ + #ifndef Py_USE_GC static PyObject * sys_getrefcount(self, args) *************** *** 198,201 **** --- 199,203 ---- return PyInt_FromLong((long) arg->ob_refcnt); } + #endif #ifdef COUNT_ALLOCS *************** *** 235,239 **** --- 237,243 ---- {"getobjects", _Py_GetObjects, 1}, #endif + #ifndef Py_USE_GC {"getrefcount", sys_getrefcount, 0}, + #endif #ifdef USE_MALLOPT {"mdebug", sys_mdebug, 0}, Only in Python-1.5.1-gc-no-refcnt: buildno Only in Python-1.5.1-gc-no-refcnt: config.status