[Python-checkins] CVS: python/dist/src/Modules gcmodule.c,2.23,2.24
Tim Peters
tim_one@users.sourceforge.net
Thu, 11 Oct 2001 11:31:33 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv23954/python/Modules
Modified Files:
gcmodule.c
Log Message:
SF bug [#467145] Python 2.2a4 build problem on HPUX 11.0.
The platform requires 8-byte alignment for doubles, but the GC header
was 12 bytes and that threw off the natural alignment of the double
members of a subtype of complex. The fix puts the GC header into a
union with a double as the other member, to force no-looser-than
double alignment of GC headers. On boxes that require 8-byte alignment
for doubles, this may add pad bytes to the GC header accordingly; ditto
for platforms that *prefer* 8-byte alignment for doubles. On platforms
that don't care, it shouldn't change the memory layout (because the
size of the old GC header is certainly greater than the size of a double
on all platforms, so unioning with a double shouldn't change size or
alignment on such boxes).
Index: gcmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v
retrieving revision 2.23
retrieving revision 2.24
diff -C2 -d -r2.23 -r2.24
*** gcmodule.c 2001/10/07 03:54:51 2.23
--- gcmodule.c 2001/10/11 18:31:31 2.24
***************
*** 78,83 ****
gc_list_init(PyGC_Head *list)
{
! list->gc_prev = list;
! list->gc_next = list;
}
--- 78,83 ----
gc_list_init(PyGC_Head *list)
{
! list->gc.gc_prev = list;
! list->gc.gc_next = list;
}
***************
*** 85,92 ****
gc_list_append(PyGC_Head *node, PyGC_Head *list)
{
! node->gc_next = list;
! node->gc_prev = list->gc_prev;
! node->gc_prev->gc_next = node;
! list->gc_prev = node;
}
--- 85,92 ----
gc_list_append(PyGC_Head *node, PyGC_Head *list)
{
! node->gc.gc_next = list;
! node->gc.gc_prev = list->gc.gc_prev;
! node->gc.gc_prev->gc.gc_next = node;
! list->gc.gc_prev = node;
}
***************
*** 94,100 ****
gc_list_remove(PyGC_Head *node)
{
! node->gc_prev->gc_next = node->gc_next;
! node->gc_next->gc_prev = node->gc_prev;
! node->gc_next = NULL; /* object is not currently tracked */
}
--- 94,100 ----
gc_list_remove(PyGC_Head *node)
{
! node->gc.gc_prev->gc.gc_next = node->gc.gc_next;
! node->gc.gc_next->gc.gc_prev = node->gc.gc_prev;
! node->gc.gc_next = NULL; /* object is not currently tracked */
}
***************
*** 102,114 ****
gc_list_move(PyGC_Head *from, PyGC_Head *to)
{
! if (from->gc_next == from) {
/* empty from list */
gc_list_init(to);
}
else {
! to->gc_next = from->gc_next;
! to->gc_next->gc_prev = to;
! to->gc_prev = from->gc_prev;
! to->gc_prev->gc_next = to;
}
gc_list_init(from);
--- 102,114 ----
gc_list_move(PyGC_Head *from, PyGC_Head *to)
{
! if (from->gc.gc_next == from) {
/* empty from list */
gc_list_init(to);
}
else {
! to->gc.gc_next = from->gc.gc_next;
! to->gc.gc_next->gc.gc_prev = to;
! to->gc.gc_prev = from->gc.gc_prev;
! to->gc.gc_prev->gc.gc_next = to;
}
gc_list_init(from);
***************
*** 120,129 ****
{
PyGC_Head *tail;
! if (from->gc_next != from) {
! tail = to->gc_prev;
! tail->gc_next = from->gc_next;
! tail->gc_next->gc_prev = tail;
! to->gc_prev = from->gc_prev;
! to->gc_prev->gc_next = to;
}
gc_list_init(from);
--- 120,129 ----
{
PyGC_Head *tail;
! if (from->gc.gc_next != from) {
! tail = to->gc.gc_prev;
! tail->gc.gc_next = from->gc.gc_next;
! tail->gc.gc_next->gc.gc_prev = tail;
! to->gc.gc_prev = from->gc.gc_prev;
! to->gc.gc_prev->gc.gc_next = to;
}
gc_list_init(from);
***************
*** 135,139 ****
PyGC_Head *gc;
long n = 0;
! for (gc = list->gc_next; gc != list; gc = gc->gc_next) {
n++;
}
--- 135,139 ----
PyGC_Head *gc;
long n = 0;
! for (gc = list->gc.gc_next; gc != list; gc = gc->gc.gc_next) {
n++;
}
***************
*** 149,155 ****
update_refs(PyGC_Head *containers)
{
! PyGC_Head *gc = containers->gc_next;
! for (; gc != containers; gc=gc->gc_next) {
! gc->gc_refs = FROM_GC(gc)->ob_refcnt;
}
}
--- 149,155 ----
update_refs(PyGC_Head *containers)
{
! PyGC_Head *gc = containers->gc.gc_next;
! for (; gc != containers; gc=gc->gc.gc_next) {
! gc->gc.gc_refs = FROM_GC(gc)->ob_refcnt;
}
}
***************
*** 160,165 ****
if (op && PyObject_IS_GC(op)) {
PyGC_Head *gc = AS_GC(op);
! if (gc->gc_next != NULL)
! AS_GC(op)->gc_refs--;
}
return 0;
--- 160,165 ----
if (op && PyObject_IS_GC(op)) {
PyGC_Head *gc = AS_GC(op);
! if (gc->gc.gc_next != NULL)
! AS_GC(op)->gc.gc_refs--;
}
return 0;
***************
*** 171,176 ****
{
traverseproc traverse;
! PyGC_Head *gc = containers->gc_next;
! for (; gc != containers; gc=gc->gc_next) {
traverse = FROM_GC(gc)->ob_type->tp_traverse;
(void) traverse(FROM_GC(gc),
--- 171,176 ----
{
traverseproc traverse;
! PyGC_Head *gc = containers->gc.gc_next;
! for (; gc != containers; gc=gc->gc.gc_next) {
traverse = FROM_GC(gc)->ob_type->tp_traverse;
(void) traverse(FROM_GC(gc),
***************
*** 185,195 ****
{
PyGC_Head *next;
! PyGC_Head *gc = containers->gc_next;
while (gc != containers) {
! next = gc->gc_next;
! if (gc->gc_refs > 0) {
gc_list_remove(gc);
gc_list_append(gc, roots);
! gc->gc_refs = GC_MOVED;
}
gc = next;
--- 185,195 ----
{
PyGC_Head *next;
! PyGC_Head *gc = containers->gc.gc_next;
while (gc != containers) {
! next = gc->gc.gc_next;
! if (gc->gc.gc_refs > 0) {
gc_list_remove(gc);
gc_list_append(gc, roots);
! gc->gc.gc_refs = GC_MOVED;
}
gc = next;
***************
*** 202,209 ****
if (PyObject_IS_GC(op)) {
PyGC_Head *gc = AS_GC(op);
! if (gc->gc_next != NULL && gc->gc_refs != GC_MOVED) {
gc_list_remove(gc);
gc_list_append(gc, tolist);
! gc->gc_refs = GC_MOVED;
}
}
--- 202,209 ----
if (PyObject_IS_GC(op)) {
PyGC_Head *gc = AS_GC(op);
! if (gc->gc.gc_next != NULL && gc->gc.gc_refs != GC_MOVED) {
gc_list_remove(gc);
gc_list_append(gc, tolist);
! gc->gc.gc_refs = GC_MOVED;
}
}
***************
*** 216,221 ****
{
traverseproc traverse;
! PyGC_Head *gc = reachable->gc_next;
! for (; gc != reachable; gc=gc->gc_next) {
/* careful, reachable list is growing here */
PyObject *op = FROM_GC(gc);
--- 216,221 ----
{
traverseproc traverse;
! PyGC_Head *gc = reachable->gc.gc_next;
! for (; gc != reachable; gc=gc->gc.gc_next) {
/* careful, reachable list is growing here */
PyObject *op = FROM_GC(gc);
***************
*** 232,236 ****
{
PyGC_Head *next;
! PyGC_Head *gc = unreachable->gc_next;
static PyObject *delstr = NULL;
if (delstr == NULL) {
--- 232,236 ----
{
PyGC_Head *next;
! PyGC_Head *gc = unreachable->gc.gc_next;
static PyObject *delstr = NULL;
if (delstr == NULL) {
***************
*** 241,245 ****
for (; gc != unreachable; gc=next) {
PyObject *op = FROM_GC(gc);
! next = gc->gc_next;
if (PyInstance_Check(op) && PyObject_HasAttr(op, delstr)) {
gc_list_remove(gc);
--- 241,245 ----
for (; gc != unreachable; gc=next) {
PyObject *op = FROM_GC(gc);
! next = gc->gc.gc_next;
if (PyInstance_Check(op) && PyObject_HasAttr(op, delstr)) {
gc_list_remove(gc);
***************
*** 254,259 ****
{
traverseproc traverse;
! PyGC_Head *gc = finalizers->gc_next;
! for (; gc != finalizers; gc=gc->gc_next) {
/* careful, finalizers list is growing here */
traverse = FROM_GC(gc)->ob_type->tp_traverse;
--- 254,259 ----
{
traverseproc traverse;
! PyGC_Head *gc = finalizers->gc.gc_next;
! for (; gc != finalizers; gc=gc->gc.gc_next) {
/* careful, finalizers list is growing here */
traverse = FROM_GC(gc)->ob_type->tp_traverse;
***************
*** 298,303 ****
garbage = PyList_New(0);
}
! for (gc = finalizers->gc_next; gc != finalizers;
! gc = finalizers->gc_next) {
PyObject *op = FROM_GC(gc);
if ((debug & DEBUG_SAVEALL) || PyInstance_Check(op)) {
--- 298,303 ----
garbage = PyList_New(0);
}
! for (gc = finalizers->gc.gc_next; gc != finalizers;
! gc = finalizers->gc.gc_next) {
PyObject *op = FROM_GC(gc);
if ((debug & DEBUG_SAVEALL) || PyInstance_Check(op)) {
***************
*** 322,327 ****
inquiry clear;
! while (unreachable->gc_next != unreachable) {
! PyGC_Head *gc = unreachable->gc_next;
PyObject *op = FROM_GC(gc);
if (debug & DEBUG_SAVEALL) {
--- 322,327 ----
inquiry clear;
! while (unreachable->gc.gc_next != unreachable) {
! PyGC_Head *gc = unreachable->gc.gc_next;
PyObject *op = FROM_GC(gc);
if (debug & DEBUG_SAVEALL) {
***************
*** 335,339 ****
}
}
! if (unreachable->gc_next == gc) {
/* object is still alive, move it, it may die later */
gc_list_remove(gc);
--- 335,339 ----
}
}
! if (unreachable->gc.gc_next == gc) {
/* object is still alive, move it, it may die later */
gc_list_remove(gc);
***************
*** 397,402 ****
/* Collect statistics on collectable objects found and print
* debugging information. */
! for (gc = unreachable.gc_next; gc != &unreachable;
! gc = gc->gc_next) {
m++;
if (debug & DEBUG_COLLECTABLE) {
--- 397,402 ----
/* Collect statistics on collectable objects found and print
* debugging information. */
! for (gc = unreachable.gc.gc_next; gc != &unreachable;
! gc = gc->gc.gc_next) {
m++;
if (debug & DEBUG_COLLECTABLE) {
***************
*** 411,416 ****
/* Collect statistics on uncollectable objects found and print
* debugging information. */
! for (gc = finalizers.gc_next; gc != &finalizers;
! gc = gc->gc_next) {
n++;
if (debug & DEBUG_UNCOLLECTABLE) {
--- 411,416 ----
/* Collect statistics on uncollectable objects found and print
* debugging information. */
! for (gc = finalizers.gc.gc_next; gc != &finalizers;
! gc = gc->gc.gc_next) {
n++;
if (debug & DEBUG_UNCOLLECTABLE) {
***************
*** 457,461 ****
gc_list_merge(&_PyGC_generation0, &generation2);
gc_list_merge(&generation1, &generation2);
! if (generation2.gc_next != &generation2) {
n = collect(&generation2, &generation2);
}
--- 457,461 ----
gc_list_merge(&_PyGC_generation0, &generation2);
gc_list_merge(&generation1, &generation2);
! if (generation2.gc.gc_next != &generation2) {
n = collect(&generation2, &generation2);
}
***************
*** 466,470 ****
collections1++;
gc_list_merge(&_PyGC_generation0, &generation1);
! if (generation1.gc_next != &generation1) {
n = collect(&generation1, &generation2);
}
--- 466,470 ----
collections1++;
gc_list_merge(&_PyGC_generation0, &generation1);
! if (generation1.gc.gc_next != &generation1) {
n = collect(&generation1, &generation2);
}
***************
*** 474,478 ****
generation = 0;
collections0++;
! if (_PyGC_generation0.gc_next != &_PyGC_generation0) {
n = collect(&_PyGC_generation0, &generation1);
}
--- 474,478 ----
generation = 0;
collections0++;
! if (_PyGC_generation0.gc.gc_next != &_PyGC_generation0) {
n = collect(&_PyGC_generation0, &generation1);
}
***************
*** 647,651 ****
PyObject *obj;
traverseproc traverse;
! for (gc = list->gc_next; gc != list; gc = gc->gc_next) {
obj = FROM_GC(gc);
traverse = obj->ob_type->tp_traverse;
--- 647,651 ----
PyObject *obj;
traverseproc traverse;
! for (gc = list->gc.gc_next; gc != list; gc = gc->gc.gc_next) {
obj = FROM_GC(gc);
traverse = obj->ob_type->tp_traverse;
***************
*** 689,693 ****
{
PyGC_Head *gc;
! for (gc = gc_list->gc_next; gc != gc_list; gc = gc->gc_next) {
PyObject *op = FROM_GC(gc);
if (op != py_list) {
--- 689,693 ----
{
PyGC_Head *gc;
! for (gc = gc_list->gc.gc_next; gc != gc_list; gc = gc->gc.gc_next) {
PyObject *op = FROM_GC(gc);
if (op != py_list) {
***************
*** 808,812 ****
if (g == NULL)
return (PyObject *)PyErr_NoMemory();
! g->gc_next = NULL;
allocated++;
if (allocated > threshold0 &&
--- 808,812 ----
if (g == NULL)
return (PyObject *)PyErr_NoMemory();
! g->gc.gc_next = NULL;
allocated++;
if (allocated > threshold0 &&
***************
*** 867,871 ****
#ifdef WITH_CYCLE_GC
PyGC_Head *g = AS_GC(op);
! if (g->gc_next != NULL)
gc_list_remove(g);
if (allocated > 0) {
--- 867,871 ----
#ifdef WITH_CYCLE_GC
PyGC_Head *g = AS_GC(op);
! if (g->gc.gc_next != NULL)
gc_list_remove(g);
if (allocated > 0) {