* mathlib.h (IS_NAN): Fixed strict aliasing violation by providing

an inline function using a float/int union instead of the original
  macro.

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@650 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Ozkan Sezer 2012-03-24 06:24:56 +00:00
parent 4f04731c51
commit 8d997767e7
1 changed files with 10 additions and 2 deletions

View File

@ -37,8 +37,16 @@ struct mplane_s;
extern vec3_t vec3_origin; extern vec3_t vec3_origin;
#define nanmask (255<<23) /* 7F800000 */ #define nanmask (255 << 23) /* 7F800000 */
#define IS_NAN(x) (((*(int *) &x) & nanmask) == nanmask) #if 0 /* macro is violating strict aliasing rules */
#define IS_NAN(x) (((*(int *) (char *) &x) & nanmask) == nanmask)
#else
static inline int IS_NAN (float x) {
union { float f; int i; } num;
num.f = x;
return ((num.i & nanmask) == nanmask);
}
#endif
#define Q_rint(x) ((x) > 0 ? (int)((x) + 0.5) : (int)((x) - 0.5)) //johnfitz -- from joequake #define Q_rint(x) ((x) > 0 ? (int)((x) + 0.5) : (int)((x) - 0.5)) //johnfitz -- from joequake