Commit b6186fe6 by Richard Henderson Committed by Richard Henderson

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
parent 7c4710c7
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> Sat Jan 9 11:25:00 1999 Per Bothner <bothner@cygnus.com>
* parse.y (build_new_array_init): Don't set EXPR_WFL_LINECOL * parse.y (build_new_array_init): Don't set EXPR_WFL_LINECOL
......
...@@ -149,12 +149,16 @@ static int ...@@ -149,12 +149,16 @@ static int
java_float_finite (f) java_float_finite (f)
jfloat 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 /* 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 also positive and negative infinity. That's why we only need one
test here. See The Java Language Specification, section 20.9. */ 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. */ /* Return 1 if D is not Inf or NaN. */
...@@ -162,10 +166,14 @@ static int ...@@ -162,10 +166,14 @@ static int
java_double_finite (d) java_double_finite (d)
jdouble d; jdouble d;
{ {
int64 *ip = (int64 *) &d; union {
jdouble d;
int64 i;
} u;
u.d = d;
/* Now check for all NaNs. */ /* Now check for all NaNs. */
return (*ip & D_NAN_MASK) != D_NAN_MASK; return (u.i & D_NAN_MASK) != D_NAN_MASK;
} }
void void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment