$NetBSD: patch-ah,v 1.7 2009/11/29 13:01:06 enami Exp $

Index: src/gauche.h
===================================================================
--- src/gauche.h	(revision 6883)
+++ src/gauche.h	(revision 6885)
@@ -134,6 +134,16 @@
    Hence this macro. */
 #define SCM_IGNORE_RESULT(expr)  do { if(expr) {} } while(0)
 
+/* ScmFlonum and ScmClass must always be aligned in 8-byte boundaries.
+   (All other Scheme objects can be in 4-byte boundary.)
+   Some platform doesn't align static double in 8-byte boundaries, so
+   we try this as well.  */
+#ifdef __GNUC__
+#define SCM_ALIGN8  __attribute__ ((aligned (8)))
+#else  /* !__GNUC__ */
+#define SCM_ALIGN8  /*empty*/
+#endif /* !__GNUC__ */
+
 /*-------------------------------------------------------------
  * BASIC TYPES
  */
@@ -289,7 +299,7 @@
 
 typedef struct ScmFlonumRec {
     double val;
-} ScmFlonum;
+} ScmFlonum SCM_ALIGN8;
 
 #define SCM_FLONUM(obj)            ((ScmFlonum*)(SCM_WORD(obj)&~0x07))
 #define SCM_FLONUMP(obj)           (SCM_TAG2(obj) == 2)
@@ -599,13 +609,9 @@
    those fields casually.  Also, the order of these fields must be
    reflected to the class definition macros below. */
 struct ScmClassRec {
-    /* We need all class structures be aligned on (at least) 8-byte boundary
-       to make our tagging scheme work.  Dynamically allocated objects
-       are *always* 8-byte aligned due to Boehm GC's architecture.  However,
-       we found that statically allocated class structures can be placed
-       4-byte boundary on some 32bit systems if we started ScmClassRec
-       with SCM_INSTANCE_HEADER.  The following union is the trick
-       to ensure 8-byte alighment on such systems. */ 
+    /* A trick to align statically allocated class structure on 8-byte
+       boundary.  This doesn't guarantee, though, so we use __alignment__
+       attribute as well, whenever possible (see SCM_ALIGN8 macro). */
     union {
         SCM_INSTANCE_HEADER;
         double align_dummy;
@@ -642,7 +648,7 @@
     ScmInternalMutex mutex;     /* to protect from MT hazard */
     ScmInternalCond cv;         /* wait on this while a class being updated */
     void   *data;               /* extra data to do nasty trick */
-};
+} SCM_ALIGN8;
 
 typedef struct ScmClassStaticSlotSpecRec ScmClassStaticSlotSpec;
 
