Bug 83388 -- dialogs (and probably other things) broken when using -O2 on gcc 2.96 due to js code that was unsafe for alias optimization. r=drepper@cygnus.com, sr=brendan.

git-svn-id: svn://10.0.0.236/trunk@99303 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bryner%uiuc.edu
2001-07-16 05:02:10 +00:00
parent a1bbf94586
commit 052526b1b0

View File

@@ -48,6 +48,37 @@
JS_BEGIN_EXTERN_C
#if __GNUC__ >= 2
/* This version of the macros is safe for the alias optimizations
* that gcc does, but uses gcc-specific extensions.
*/
typedef union {
double value;
struct {
#ifdef IS_LITTLE_ENDIAN
u_int32_t lsw;
u_int32_t msw;
#else
u_int32_t msw;
u_int32_t lsw;
#endif
} parts;
} js_ieee_double_shape_type;
#define JSDOUBLE_HI32(x) (__extension__ ({ js_ieee_double_shape_type sh_u; \
sh_u.value = (x); \
sh_u.parts.msw; }))
#define JSDOUBLE_LO32(x) (__extension__ ({ js_ieee_double_shape_type sh_u; \
sh_u.value = (x); \
sh_u.parts.lsw; }))
#else /* GNUC */
/* We don't know of any non-gcc compilers that perform alias optimization,
* so this code should work.
*/
#ifdef IS_LITTLE_ENDIAN
#define JSDOUBLE_HI32(x) (((uint32 *)&(x))[1])
#define JSDOUBLE_LO32(x) (((uint32 *)&(x))[0])
@@ -55,6 +86,9 @@ JS_BEGIN_EXTERN_C
#define JSDOUBLE_HI32(x) (((uint32 *)&(x))[0])
#define JSDOUBLE_LO32(x) (((uint32 *)&(x))[1])
#endif
#endif /* GNUC */
#define JSDOUBLE_HI32_SIGNBIT 0x80000000
#define JSDOUBLE_HI32_EXPMASK 0x7ff00000
#define JSDOUBLE_HI32_MANTMASK 0x000fffff