gjavah.c (java_float_finite): Use a union to do type punning.

* gjavah.c (java_float_finite): Use a union to do type punning.
        (java_double_finite): Likewise.

From-SVN: r24608
This commit is contained in:
Richard Henderson 1999-01-10 05:36:44 -08:00 committed by Richard Henderson
parent 7c4710c720
commit b6186fe678
2 changed files with 17 additions and 4 deletions

View File

@ -1,3 +1,8 @@
Sun Jan 10 13:36:14 1999 Richard Henderson <rth@cygnus.com>
* gjavah.c (java_float_finite): Use a union to do type punning.
(java_double_finite): Likewise.
Sat Jan 9 11:25:00 1999 Per Bothner <bothner@cygnus.com>
* parse.y (build_new_array_init): Don't set EXPR_WFL_LINECOL

View File

@ -149,12 +149,16 @@ static int
java_float_finite (f)
jfloat f;
{
int32 *ip = (int32 *) &f;
union {
jfloat f;
int32 i;
} u;
u.f = f;
/* We happen to know that F_NAN_MASK will match all NaN values, and
also positive and negative infinity. That's why we only need one
test here. See The Java Language Specification, section 20.9. */
return (*ip & F_NAN_MASK) != F_NAN_MASK;
return (u.i & F_NAN_MASK) != F_NAN_MASK;
}
/* Return 1 if D is not Inf or NaN. */
@ -162,10 +166,14 @@ static int
java_double_finite (d)
jdouble d;
{
int64 *ip = (int64 *) &d;
union {
jdouble d;
int64 i;
} u;
u.d = d;
/* Now check for all NaNs. */
return (*ip & D_NAN_MASK) != D_NAN_MASK;
return (u.i & D_NAN_MASK) != D_NAN_MASK;
}
void