Unverified Commit b871d44a authored by Joshua Ashton's avatar Joshua Ashton 🐸
Browse files

r300g: Use union for rc_print_inline_float



Fixes a warning in GCC 9+ that's been bugging me for a very long time when building Mesa.

Additionally avoids pointer type punning.

Signed-off-by: Joshua Ashton's avatarJoshua Ashton <joshua@froggi.es>
parent 4b0975a8
Pipeline #405726 waiting for manual action with stages
in 7 seconds
......@@ -114,14 +114,17 @@ static void rc_print_inline_float(FILE * f, int index)
int r300_exponent = (index >> 3) & 0xf;
unsigned r300_mantissa = index & 0x7;
unsigned float_exponent;
unsigned real_float;
float * print_float = (float*) &real_float;
union
{
unsigned u;
float f;
} raw_float;
r300_exponent -= 7;
float_exponent = r300_exponent + 127;
real_float = (r300_mantissa << 20) | (float_exponent << 23);
raw_float.u = (r300_mantissa << 20) | (float_exponent << 23);
fprintf(f, "%f (0x%x)", *print_float, index);
fprintf(f, "%f (0x%x)", raw_float.f, index);
}
......
Supports Markdown
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