mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 289394 - "Double.cpp causes unaligned accesses" [p=davidm@hpl.hp.com (David Mosberger) / eric@debian.org (Eric Dorland) / mh+mozilla@glandium.org (Mike Hommey) r+sr=sicking sr=bryner a1.9=beltzner]
This commit is contained in:
parent
64aa8e3a97
commit
1ca961cdad
@ -68,14 +68,7 @@ static fp_except_t oldmask = fpsetmask(~allmask);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (__GNUC__ == 2 && __GNUC_MINOR__ > 95) || __GNUC__ > 2
|
||||
/**
|
||||
* This version of the macros is safe for the alias optimizations
|
||||
* that gcc does, but uses gcc-specific extensions.
|
||||
*/
|
||||
|
||||
typedef union txdpun {
|
||||
PRFloat64 d;
|
||||
struct {
|
||||
#if defined(IS_LITTLE_ENDIAN) && !defined(FPU_IS_ARM_FPA)
|
||||
PRUint32 lo, hi;
|
||||
@ -83,8 +76,14 @@ typedef union txdpun {
|
||||
PRUint32 hi, lo;
|
||||
#endif
|
||||
} s;
|
||||
PRFloat64 d;
|
||||
} txdpun;
|
||||
|
||||
#if (__GNUC__ == 2 && __GNUC_MINOR__ > 95) || __GNUC__ > 2
|
||||
/**
|
||||
* This version of the macros is safe for the alias optimizations
|
||||
* that gcc does, but uses gcc-specific extensions.
|
||||
*/
|
||||
#define TX_DOUBLE_HI32(x) (__extension__ ({ txdpun u; u.d = (x); u.s.hi; }))
|
||||
#define TX_DOUBLE_LO32(x) (__extension__ ({ txdpun u; u.d = (x); u.s.lo; }))
|
||||
|
||||
@ -113,11 +112,11 @@ typedef union txdpun {
|
||||
(TX_DOUBLE_LO32(x) || (TX_DOUBLE_HI32(x) & TX_DOUBLE_HI32_MANTMASK)))
|
||||
|
||||
#ifdef IS_BIG_ENDIAN
|
||||
#define TX_DOUBLE_NaN {TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_MANTMASK, \
|
||||
0xffffffff}
|
||||
#define TX_DOUBLE_NaN {{TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_MANTMASK, \
|
||||
0xffffffff}}
|
||||
#else
|
||||
#define TX_DOUBLE_NaN {0xffffffff, \
|
||||
TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_MANTMASK}
|
||||
#define TX_DOUBLE_NaN {{0xffffffff, \
|
||||
TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_MANTMASK}}
|
||||
#endif
|
||||
|
||||
#if defined(XP_WIN)
|
||||
|
@ -50,18 +50,18 @@
|
||||
*/
|
||||
|
||||
//-- Initialize Double related constants
|
||||
const PRUint32 nanMask[2] = TX_DOUBLE_NaN;
|
||||
const txdpun nanMask = TX_DOUBLE_NaN;
|
||||
#ifdef IS_BIG_ENDIAN
|
||||
const PRUint32 infMask[2] = {TX_DOUBLE_HI32_EXPMASK, 0};
|
||||
const PRUint32 negInfMask[2] = {TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_SIGNBIT, 0};
|
||||
const txdpun infMask = {{TX_DOUBLE_HI32_EXPMASK, 0}};
|
||||
const txdpun negInfMask = {{TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_SIGNBIT, 0}};
|
||||
#else
|
||||
const PRUint32 infMask[2] = {0, TX_DOUBLE_HI32_EXPMASK};
|
||||
const PRUint32 negInfMask[2] = {0, TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_SIGNBIT};
|
||||
const txdpun infMask = {{0, TX_DOUBLE_HI32_EXPMASK}};
|
||||
const txdpun negInfMask = {{0, TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_SIGNBIT}};
|
||||
#endif
|
||||
|
||||
const double Double::NaN = *((double*)nanMask);
|
||||
const double Double::POSITIVE_INFINITY = *((double*)infMask);
|
||||
const double Double::NEGATIVE_INFINITY = *((double*)negInfMask);
|
||||
const double Double::NaN = nanMask.d;
|
||||
const double Double::POSITIVE_INFINITY = infMask.d;
|
||||
const double Double::NEGATIVE_INFINITY = negInfMask.d;
|
||||
|
||||
/*
|
||||
* Determines whether the given double represents positive or negative
|
||||
|
Loading…
Reference in New Issue
Block a user