Here's another proposed patch for testing on various platforms.  I'm trying to 
get rid of some dodgy casts (which likely don't help C++ and processors with 
stricter alignment than 32-bit x86).  I'd also like to remove unnecessary 
members from a few structs.  This is the next step.

Are there any weird errors or unexpected crashes on anything more exotic than 
32-bit x86 GNU/Linux?

-- c

=== include/parrot/pobj.h
==================================================================
--- include/parrot/pobj.h	(revision 27223)
+++ include/parrot/pobj.h	(local)
@@ -41,14 +41,14 @@
 
 /* Parrot Object - base class for all others */
 typedef struct pobj_t {
+    Parrot_UInt flags;
     UnionVal u;
-    Parrot_UInt flags;
 } pobj_t;
 
 /* plain Buffer is the smallest Parrot Obj */
 typedef struct Buffer {
+    Parrot_UInt flags;
     UnionVal    cache;
-    Parrot_UInt flags;
 } Buffer;
 
 typedef Buffer PObj;
@@ -118,8 +118,8 @@
 } parrot_string_representation_t;
 
 struct parrot_string_t {
+    Parrot_UInt flags;
     UnionVal    cache;
-    Parrot_UInt flags;
     char       *strstart;
     UINTVAL     bufused;
     UINTVAL     strlen;
@@ -136,8 +136,8 @@
 
 /* note that cache and flags are isomorphic with Buffer and PObj */
 struct PMC {
+    Parrot_UInt     flags;
     UnionVal        cache;
-    Parrot_UInt     flags;
     VTABLE         *vtable;
     DPOINTER       *data;
     struct PMC_EXT *pmc_ext;
=== include/parrot/stacks.h
==================================================================
--- include/parrot/stacks.h	(revision 27223)
+++ include/parrot/stacks.h	(local)
@@ -25,8 +25,8 @@
 } Stack_Entry_t;
 
 typedef struct Stack_Chunk {
+    Parrot_UInt         flags;
     UnionVal            cache;
-    Parrot_UInt         flags;
     int                 size;
     const char         *name;
     struct Stack_Chunk *prev;
=== src/gc/smallobject.c
==================================================================
--- src/gc/smallobject.c	(revision 27223)
+++ src/gc/smallobject.c	(local)
@@ -415,9 +415,6 @@
     Small_Object_Pool * const pool =
         mem_internal_allocate_zeroed_typed(Small_Object_Pool);
 
-    pool->last_Arena        = NULL;
-    pool->free_list         = NULL;
-    pool->mem_pool          = NULL;
     pool->object_size       = object_size;
     pool->objects_per_alloc = objects_per_alloc;
 
@@ -505,16 +502,13 @@
     /* XXX num_free_objects doesn't seem to be accounted correctly in, e.g.,
      * the PMC_EXT pool.
      */
-#if 0
-    if (source->num_free_objects == source->total_objects) {
+    if (source->num_free_objects == source->total_objects)
         return;
-    }
-#endif
 
     /* PARROT_ASSERT(source->total_objects); */
     PARROT_ASSERT(dest->object_size == source->object_size);
-    PARROT_ASSERT((dest->name == NULL && source->name == NULL) ||
-        STREQ(dest->name, source->name));
+    PARROT_ASSERT((!dest->name && !source->name)
+    ||              STREQ(dest->name, source->name));
 
     dest->total_objects += source->total_objects;
 
@@ -523,9 +517,9 @@
     free_list_end  = &dest->free_list;
 
     while (*free_list_end)
-        free_list_end = (void **)*free_list_end;
+        free_list_end = &PMC_struct_val((PObj *)free_list_end);
 
-    *free_list_end = source->free_list;
+    PMC_struct_val((PObj *)free_list_end) = source->free_list;
 
     /* now append source arenas */
     cur_arena = source->last_Arena;
=== src/headers.c
==================================================================
--- src/headers.c	(revision 27223)
+++ src/headers.c	(local)
@@ -258,12 +258,11 @@
         memset(sized_pools + num_old, 0, sizeof (void *) * (num_new - num_old));
 
         interp->arena_base->sized_header_pools = sized_pools;
-        interp->arena_base->num_sized = num_new;
+        interp->arena_base->num_sized          = num_new;
     }
 
-    if (sized_pools[idx] == NULL) {
+    if (sized_pools[idx] == NULL)
         sized_pools[idx] = new_bufferlike_pool(interp, buffer_size);
-    }
 
     return sized_pools[idx];
 }
@@ -935,12 +934,11 @@
             source_arena->pmc_ext_pool);
 
     for (i = 0; i < source_arena->num_sized; ++i) {
-        if (!source_arena->sized_header_pools[i]) {
+        if (!source_arena->sized_header_pools[i])
             continue;
-        }
 
-        if (i >= dest_arena->num_sized ||
-            !dest_arena->sized_header_pools[i]) {
+        if (i >= dest_arena->num_sized
+        || !dest_arena->sized_header_pools[i]) {
             Small_Object_Pool *ignored = make_bufferlike_pool(dest_interp,
                     i * sizeof (void *) + sizeof (Buffer));
             UNUSED(ignored);
 

Reply via email to