Work around MSVC6/7.1 copysign bustage (329383, tachyonal r=mrbkap).

This commit is contained in:
brendan%mozilla.org 2006-03-06 01:32:55 +00:00
parent 728330ed20
commit 61309696b5
2 changed files with 24 additions and 3 deletions

View File

@ -77,8 +77,14 @@
/* The right copysign function is not always named the same thing. */
#if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
#define fd_copysign __builtin_copysign
#elif (defined _WIN32 && !defined WINCE)
#elif defined _WIN32 && !defined WINCE
#if _MSC_VER < 1400
/* Try to work around apparent _copysign bustage in VC6 and VC7. */
#define fd_copysign js_copysign
extern double js_copysign(double, double);
#else
#define fd_copysign _copysign
#endif
#else
#define fd_copysign copysign
#endif

View File

@ -241,7 +241,7 @@ math_max(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
*rval = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
if ((x==0)&&(x==z)&&(fd_copysign(1.0,z)==-1))
if (x == 0 && x == z && fd_copysign(1.0, z) == -1)
z = x;
else
z = (x > z) ? x : z;
@ -266,7 +266,7 @@ math_min(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
*rval = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
return JS_TRUE;
}
if ((x==0)&&(x==z)&&(fd_copysign(1.0,x)==-1))
if (x == 0 && x == z && fd_copysign(1.0,x) == -1)
z = x;
else
z = (x < z) ? x : z;
@ -384,6 +384,21 @@ math_random(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
return js_NewNumberValue(cx, z, rval);
}
#if defined _WIN32 && !defined WINCE && _MSC_VER < 1400
/* Try to work around apparent _copysign bustage in VC6 and VC7. */
double
js_copysign(double x, double y)
{
jsdpun xu, yu;
xu.d = x;
yu.d = y;
xu.s.hi &= ~JSDOUBLE_HI32_SIGNBIT;
xu.s.hi |= yu.s.hi & JSDOUBLE_HI32_SIGNBIT;
return xu.d;
}
#endif
static JSBool
math_round(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{