help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] Re: problem compiling smalltalk


From: Paolo Bonzini
Subject: [Help-smalltalk] Re: problem compiling smalltalk
Date: Mon, 23 Sep 2002 11:38:48 +0200
User-agent: Mutt/1.4i

The problem is in floatq_oop_value and floatd_oop_value.  Up to 2.0.1 I
was using an union of a few longs and a double to access unaligned
doubles.  Now I use memcpy, but GCC inlines it and thinks it can emit a
load-store of a single 64-bit value (instead of separate 32-bit loads and
stores).

-munaligned-doubles does not fix it (though this would not be a fix
because it is GCC specific).  From reading the manual it looks like it is
right that it doesn't, but then I wonder what it is for...

Fixed with the following patch:

diff -rc smalltalk-2.0.6-orig/libgst/dict.inl smalltalk-2.0.6/libgst/dict.inl
*** smalltalk-2.0.6-orig/libgst/dict.inl        Mon Sep  9 19:42:50 2002
--- smalltalk-2.0.6/libgst/dict.inl     Mon Sep 23 11:31:37 2002
***************
*** 433,439 ****
  
    /* we may not be aligned properly...fetch things out the hard way */
    obj = OOP_TO_OBJ (floatOOP);
!   memcpy (&d, obj->data, sizeof (double));
    return (d);
  }
  #endif
--- 433,439 ----
  
    /* we may not be aligned properly...fetch things out the hard way */
    obj = OOP_TO_OBJ (floatOOP);
!   memcpy ((PTR) &d, obj->data, sizeof (double));
    return (d);
  }
  #endif
***************
*** 441,456 ****
  OOP
  floatd_new (double f)
  {
-   gst_floatd floatObject;
    OOP floatOOP;
  
    floatObject = (gst_floatd) new_instance_with 
      (_gst_floatd_class, sizeof (double), &floatOOP);
  
- #if (DOUBLE_ALIGNMENT <= SIZEOF_CHAR_P)
    floatObject->value = f;
  #else
!   memcpy (&floatObject->value, &f, sizeof (double));
  #endif
  
    return (floatOOP);
--- 441,461 ----
  OOP
  floatd_new (double f)
  {
    OOP floatOOP;
+ #if (LONG_DOUBLE_ALIGNMENT <= SIZEOF_CHAR_P)
+   gst_floatd floatObject;
  
    floatObject = (gst_floatd) new_instance_with 
      (_gst_floatd_class, sizeof (double), &floatOOP);
  
    floatObject->value = f;
  #else
!   mst_Object obj;
! 
!   obj = new_instance_with 
!     (_gst_floatd_class, sizeof (double), &floatOOP);
! 
!   memcpy (obj->data, (PTR) &f, sizeof (double));
  #endif
  
    return (floatOOP);
***************
*** 473,479 ****
  
    /* we may not be aligned properly...fetch things out the hard way */
    obj = OOP_TO_OBJ (floatOOP);
!   memcpy (&d, obj->data, sizeof (long double));
    return (d);
  }
  #endif
--- 478,484 ----
  
    /* we may not be aligned properly...fetch things out the hard way */
    obj = OOP_TO_OBJ (floatOOP);
!   memcpy ((PTR) &d, obj->data, sizeof (long double));
    return (d);
  }
  #endif
***************
*** 481,496 ****
  OOP
  floatq_new (long double f)
  {
-   gst_floatq floatObject;
    OOP floatOOP;
  
    floatObject = (gst_floatq) new_instance_with 
      (_gst_floatq_class, sizeof (long double), &floatOOP);
  
- #if (LONG_DOUBLE_ALIGNMENT <= SIZEOF_CHAR_P)
    floatObject->value = f;
  #else
!   memcpy (&floatObject->value, &f, sizeof (long double));
  #endif
  
    return (floatOOP);
--- 486,506 ----
  OOP
  floatq_new (long double f)
  {
    OOP floatOOP;
+ #if (LONG_DOUBLE_ALIGNMENT <= SIZEOF_CHAR_P)
+   gst_floatq floatObject;
  
    floatObject = (gst_floatq) new_instance_with 
      (_gst_floatq_class, sizeof (long double), &floatOOP);
  
    floatObject->value = f;
  #else
!   mst_Object obj;
! 
!   obj = new_instance_with 
!     (_gst_floatq_class, sizeof (long double), &floatOOP);
! 
!   memcpy (obj->data, (PTR) &f, sizeof (long double));
  #endif
  
    return (floatOOP);

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]