[Python-checkins] CVS: python/dist/src/Include objimpl.h,2.42,2.43
Tim Peters
tim_one@users.sourceforge.net
Thu, 11 Oct 2001 11:31:33 -0700
Update of /cvsroot/python/python/dist/src/Include
In directory usw-pr-cvs1:/tmp/cvs-serv23954/python/Include
Modified Files:
objimpl.h
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: objimpl.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/objimpl.h,v
retrieving revision 2.42
retrieving revision 2.43
diff -C2 -d -r2.42 -r2.43
*** objimpl.h 2001/10/07 03:54:51 2.42
--- objimpl.h 2001/10/11 18:31:31 2.43
***************
*** 267,274 ****
/* GC information is stored BEFORE the object structure */
! typedef struct _gc_head {
! struct _gc_head *gc_next; /* not NULL if object is tracked */
! struct _gc_head *gc_prev;
! int gc_refs;
} PyGC_Head;
--- 267,277 ----
/* GC information is stored BEFORE the object structure */
! typedef union _gc_head {
! struct {
! union _gc_head *gc_next; /* not NULL if object is tracked */
! union _gc_head *gc_prev;
! int gc_refs;
! } gc;
! double dummy; /* force worst-case alignment */
} PyGC_Head;
***************
*** 279,288 ****
#define _PyObject_GC_TRACK(o) do { \
PyGC_Head *g = (PyGC_Head *)(o)-1; \
! if (g->gc_next != NULL) \
Py_FatalError("GC object already in linked list"); \
! g->gc_next = &_PyGC_generation0; \
! g->gc_prev = _PyGC_generation0.gc_prev; \
! g->gc_prev->gc_next = g; \
! _PyGC_generation0.gc_prev = g; \
} while (0);
--- 282,291 ----
#define _PyObject_GC_TRACK(o) do { \
PyGC_Head *g = (PyGC_Head *)(o)-1; \
! if (g->gc.gc_next != NULL) \
Py_FatalError("GC object already in linked list"); \
! g->gc.gc_next = &_PyGC_generation0; \
! g->gc.gc_prev = _PyGC_generation0.gc.gc_prev; \
! g->gc.gc_prev->gc.gc_next = g; \
! _PyGC_generation0.gc.gc_prev = g; \
} while (0);
***************
*** 290,296 ****
#define _PyObject_GC_UNTRACK(o) do { \
PyGC_Head *g = (PyGC_Head *)(o)-1; \
! g->gc_prev->gc_next = g->gc_next; \
! g->gc_next->gc_prev = g->gc_prev; \
! g->gc_next = NULL; \
} while (0);
--- 293,299 ----
#define _PyObject_GC_UNTRACK(o) do { \
PyGC_Head *g = (PyGC_Head *)(o)-1; \
! 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; \
} while (0);