[Python-Dev] GC head alignment issue (original) (raw)
Paul Svensson paul@svensson.org
Thu, 11 Oct 2001 19:07:08 -0400 (EDT)
- Previous message: [Python-Dev] GC head alignment issue
- Next message: [Python-Dev] GC head alignment issue
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, 11 Oct 2001, Tim Peters wrote:
[Tim]
My head hurts, so I'm not sure this is strictly legit C (drop-in replacement for the current PyGCHead declaration):
/* GC information is stored BEFORE the object structure */ typedef union gchead { struct { union gchead gcnext; / not NULL if object is tracked */ union gchead *gcprev; int gcrefs; }; double dummy; /* force worst-case alignment */ } PyGCHead; [Guido] Alas, gcc gives me warnings about this: ../Include/objimpl.h:274: warning: unnamed struct/union that defines no instances and references to the fields fail with errors: ../Objects/cellobject.c: In function
PyCellNew':_ _../Objects/cellobject.c:14: union has no member named
gcnext' [and many more] Then: If that's not legit, we could make it legit by naming the struct member and interpolating the name into all existing references. This is straightforward, if a bit tedious ... OK, I did that. Requires changes to the track and untrack macros, plus a ton of edits inside gcmodule.c. But that's it, and they're all straightforward changes (i.e., low chance of breakage). Should I check it in?
The usual thing to do in this situation would be:
typedef union _gc_head { struct { union _gc_head *internal_gc_next; union _gc_head internal_gc_prev; int internal_gc_refs; } gc_internals; double dummy; / force worst-case alignment */ } PyGC_Head;
#define gc_next gc_internals.internal_gc_head #define gc_next gc_internals.internal_gc_head #define gc_refs gc_internals.internal_gc_refs
No need to change any other code.
/Paul
- Previous message: [Python-Dev] GC head alignment issue
- Next message: [Python-Dev] GC head alignment issue
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]