From da538dc69f467601e01ff22b36f728c6bc90cd9d Mon Sep 17 00:00:00 2001 From: Alison Watson Date: Tue, 3 Dec 2019 01:51:23 -0500 Subject: [PATCH] remove IS_NAN (isnan exists) --- source/mathlib.h | 16 ---------------- source/pr_cmds.c | 8 ++++---- source/sv_phys.c | 4 ++-- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/source/mathlib.h b/source/mathlib.h index 74fc68d..ebc22ce 100644 --- a/source/mathlib.h +++ b/source/mathlib.h @@ -35,22 +35,6 @@ struct mplane_s; extern vec3_t vec3_origin; -#define nanmask (255 << 23) /* 7F800000 */ -#if 0 /* macro is violating strict aliasing rules */ -#define IS_NAN(x) (((*(int32_t *) (char *) &x) & nanmask) == nanmask) -#else -static inline int32_t IS_NAN(float x) -{ - union - { - float f; - int32_t i; - } num; - num.f = x; - return ((num.i & nanmask) == nanmask); -} -#endif - #define Q_rint(x) ((x) > 0 ? (int32_t)((x) + 0.5) : (int32_t)((x) - 0.5)) #define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2]) diff --git a/source/pr_cmds.c b/source/pr_cmds.c index 2edcfe5..02f346f 100644 --- a/source/pr_cmds.c +++ b/source/pr_cmds.c @@ -690,17 +690,17 @@ static void PF_traceline(void) /* FIXME FIXME FIXME: Why do we hit this with certain progs.dat ?? */ if(developer.value) { - if(IS_NAN(v1[0]) || IS_NAN(v1[1]) || IS_NAN(v1[2]) || - IS_NAN(v2[0]) || IS_NAN(v2[1]) || IS_NAN(v2[2])) + if(isnan(v1[0]) || isnan(v1[1]) || isnan(v1[2]) || + isnan(v2[0]) || isnan(v2[1]) || isnan(v2[2])) { Con_Warning("NAN in traceline:\nv1(%f %f %f) v2(%f %f %f)\nentity %" PRIi32 "\n", v1[0], v1[1], v1[2], v2[0], v2[1], v2[2], NUM_FOR_EDICT(ent)); } } - if(IS_NAN(v1[0]) || IS_NAN(v1[1]) || IS_NAN(v1[2])) + if(isnan(v1[0]) || isnan(v1[1]) || isnan(v1[2])) v1[0] = v1[1] = v1[2] = 0; - if(IS_NAN(v2[0]) || IS_NAN(v2[1]) || IS_NAN(v2[2])) + if(isnan(v2[0]) || isnan(v2[1]) || isnan(v2[2])) v2[0] = v2[1] = v2[2] = 0; trace = SV_Move(v1, vec3_origin, vec3_origin, v2, nomonsters, ent); diff --git a/source/sv_phys.c b/source/sv_phys.c index a9c663d..803f451 100644 --- a/source/sv_phys.c +++ b/source/sv_phys.c @@ -93,12 +93,12 @@ void SV_CheckVelocity(edict_t *ent) // for(i = 0 ; i < 3 ; i++) { - if(IS_NAN(ent->v.velocity[i])) + if(isnan(ent->v.velocity[i])) { Con_Printf("Got a NaN velocity on %s\n", PR_GetString(ent->v.classname)); ent->v.velocity[i] = 0; } - if(IS_NAN(ent->v.origin[i])) + if(isnan(ent->v.origin[i])) { Con_Printf("Got a NaN origin on %s\n", PR_GetString(ent->v.classname)); ent->v.origin[i] = 0;