Changeset 18656 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Jan 7, 2007, 9:08:17 PM (18 years ago)
Author:
ddkilzer
Message:

JavaScriptCore:

Reviewed by Darin.

Fix http://bugs.webkit.org/show_bug.cgi?id=11431
ARM platform has some byte alignment issues

Fix for NaN being 4 bytes and it must start on a byte boundary
for ARM architectures.

  • kjs/fpconst.cpp: (KJS::):
Location:
trunk/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r18584 r18656  
     12007-01-07  David Carson  <[email protected]>
     2
     3        Reviewed by Darin.
     4
     5        Fix http://bugs.webkit.org/show_bug.cgi?id=11431
     6        ARM platform has some byte alignment issues
     7
     8        Fix for NaN being 4 bytes and it must start on a byte boundary
     9        for ARM architectures.
     10
     11        * kjs/fpconst.cpp:
     12        (KJS::):
     13
    1142007-01-04  David Kilzer  <[email protected]>
    215
  • trunk/JavaScriptCore/kjs/fpconst.cpp

    r13092 r18656  
    4747#else // !PLATFORM(DARWIN)
    4848
     49// Note, we have to use union to ensure alignment. Otherwise, NaN_Bytes can start anywhere,
     50// while NaN_double has to be 4-byte aligned for 32-bits.
     51// With -fstrict-aliasing enabled, unions are the only safe way to do type masquerading.
     52
     53static const union {
     54    struct {
     55        unsigned char NaN_Bytes[8];
     56        unsigned char Inf_Bytes[8];
     57    } bytes;
     58   
     59    struct {
     60        double NaN_Double;
     61        double Inf_Double;
     62    } doubles;
     63   
     64} NaNInf = { {
    4965#if PLATFORM(BIG_ENDIAN)
    50     const unsigned char NaN_Bytes[] = { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 };
    51     const unsigned char Inf_Bytes[] = { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 };
     66    { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 },
     67    { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 }
    5268#elif PLATFORM(MIDDLE_ENDIAN)
    53     const unsigned char NaN_Bytes[] = { 0, 0, 0xf8, 0x7f, 0, 0, 0, 0 };
    54     const unsigned char Inf_Bytes[] = { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 };
     69    { 0, 0, 0xf8, 0x7f, 0, 0, 0, 0 },
     70    { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 }
    5571#else
    56     const unsigned char NaN_Bytes[] = { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f };
    57     const unsigned char Inf_Bytes[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f };
     72    { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f },
     73    { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }
    5874#endif
    59     extern const double NaN = *(const double*) NaN_Bytes;
    60     extern const double Inf = *(const double*) Inf_Bytes;
     75} } ;
     76
     77    extern const double NaN = NaNInf.doubles.NaN_Double;
     78    extern const double Inf = NaNInf.doubles.Inf_Double;
    6179 
    6280#endif // !PLATFORM(DARWIN)
Note: See TracChangeset for help on using the changeset viewer.