From: Brian Paul Date: Tue, 31 Mar 2009 22:06:19 +0000 (-0600) Subject: gallium: added util_is_inf_or_nan() function to u_math.h X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3705d03b0fbe349dee0221d982965a0590bc7cb0;p=mesa.git gallium: added util_is_inf_or_nan() function to u_math.h --- diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index 9268a9bb7ee..e5003af01d8 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -319,6 +319,18 @@ util_iround(float f) +/** + * Test if x is NaN or +/- infinity. + */ +static INLINE boolean +util_is_inf_or_nan(float x) +{ + union fi tmp; + tmp.f = x; + return !(int)((unsigned int)((tmp.i & 0x7fffffff)-0x7f800000) >> 31); +} + + /** * Find first bit set in word. Least significant bit is 1. * Return 0 if no bits set.