Skip to content

Commit

Permalink
supress fast-math warns
Browse files Browse the repository at this point in the history
  • Loading branch information
recp committed Aug 27, 2024
1 parent b0f3520 commit c12f318
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/cglm/vec2-ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ glm_vec2_min(vec2 v) {
CGLM_INLINE
bool
glm_vec2_isnan(vec2 v) {
#ifndef CGLM_FAST_MATH
return isnan(v[0]) || isnan(v[1]);
#else
return false;
#endif
}

/*!
Expand All @@ -148,7 +152,11 @@ glm_vec2_isnan(vec2 v) {
CGLM_INLINE
bool
glm_vec2_isinf(vec2 v) {
#ifndef CGLM_FAST_MATH
return isinf(v[0]) || isinf(v[1]);
#else
return false;
#endif
}

/*!
Expand Down
8 changes: 8 additions & 0 deletions include/cglm/vec3-ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ glm_vec3_min(vec3 v) {
CGLM_INLINE
bool
glm_vec3_isnan(vec3 v) {
#ifndef CGLM_FAST_MATH
return isnan(v[0]) || isnan(v[1]) || isnan(v[2]);
#else
return false;
#endif
}

/*!
Expand All @@ -184,7 +188,11 @@ glm_vec3_isnan(vec3 v) {
CGLM_INLINE
bool
glm_vec3_isinf(vec3 v) {
#ifndef CGLM_FAST_MATH
return isinf(v[0]) || isinf(v[1]) || isinf(v[2]);
#else
return false;
#endif
}

/*!
Expand Down
8 changes: 8 additions & 0 deletions include/cglm/vec4-ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ glm_vec4_min(vec4 v) {
CGLM_INLINE
bool
glm_vec4_isnan(vec4 v) {
#ifndef CGLM_FAST_MATH
return isnan(v[0]) || isnan(v[1]) || isnan(v[2]) || isnan(v[3]);
#else
return false;
#endif
}

/*!
Expand All @@ -198,7 +202,11 @@ glm_vec4_isnan(vec4 v) {
CGLM_INLINE
bool
glm_vec4_isinf(vec4 v) {
#ifndef CGLM_FAST_MATH
return isinf(v[0]) || isinf(v[1]) || isinf(v[2]) || isinf(v[3]);
#else
return false;
#endif
}

/*!
Expand Down
32 changes: 32 additions & 0 deletions test/src/test_vec3.h
Original file line number Diff line number Diff line change
Expand Up @@ -872,18 +872,30 @@ TEST_IMPL(GLM_PREFIX, vec3_angle) {
float a;

a = GLM(vec3_angle)(v1, v1);

#ifndef CGLM_FAST_MATH
ASSERT(!isinf(a))
ASSERT(!isnan(a))
#endif

ASSERT(test_eq(a, 0.0f))

a = GLM(vec3_angle)(v1, v2);

#ifndef CGLM_FAST_MATH
ASSERT(!isinf(a))
ASSERT(!isnan(a))
#endif

ASSERT(test_eq(a, GLM_PI_4f))

a = GLM(vec3_angle)(v1, v3);

#ifndef CGLM_FAST_MATH
ASSERT(!isinf(a))
ASSERT(!isnan(a))
#endif

ASSERT(test_eq(a, GLM_PI_2f))

TEST_SUCCESS
Expand Down Expand Up @@ -1227,23 +1239,39 @@ TEST_IMPL(GLM_PREFIX, vec3_ortho) {
GLM(vec3_ortho)(v4, v8);

a = glm_vec3_angle(v1, v5);

#ifndef CGLM_FAST_MATH
ASSERT(!isinf(a))
ASSERT(!isnan(a))
#endif

ASSERT(test_eq(a, GLM_PI_2f))

a = glm_vec3_angle(v2, v6);

#ifndef CGLM_FAST_MATH
ASSERT(!isinf(a))
ASSERT(!isnan(a))
#endif

ASSERT(test_eq(a, GLM_PI_2f))

a = glm_vec3_angle(v3, v7);

#ifndef CGLM_FAST_MATH
ASSERT(!isinf(a))
ASSERT(!isnan(a))
#endif

ASSERT(test_eq(a, GLM_PI_2f))

a = glm_vec3_angle(v4, v8);

#ifndef CGLM_FAST_MATH
ASSERT(!isinf(a))
ASSERT(!isnan(a))
#endif

ASSERT(test_eq(a, GLM_PI_2f))

TEST_SUCCESS
Expand Down Expand Up @@ -1692,12 +1720,16 @@ TEST_IMPL(GLM_PREFIX, vec3_max) {

TEST_IMPL(GLM_PREFIX, vec3_min) {
vec3 v1 = {2.104f, -3.012f, -4.10f}, v2 = {-12.35f, -31.140f, -43.502f};
#ifndef CGLM_FAST_MATH
vec3 v3 = {INFINITY, 0.0f, 0.0f}/*, v4 = {NAN, INFINITY, 2.0f}*/;
#endif
vec3 /*v5 = {NAN, -1.0f, -1.0f},*/ v6 = {-1.0f, -11.0f, 11.0f};

ASSERT(test_eq(GLM(vec3_min)(v1), -4.10f))
ASSERT(test_eq(GLM(vec3_min)(v2), -43.502f))
#ifndef CGLM_FAST_MATH
ASSERT(test_eq(GLM(vec3_min)(v3), 0.0f))
#endif
// ASSERT(isnan(GLM(vec3_min)(v4)))
// ASSERT(isnan(GLM(vec3_min)(v5)))
ASSERT(test_eq(GLM(vec3_min)(v6), -11.0f))
Expand Down
4 changes: 4 additions & 0 deletions test/src/test_vec4.h
Original file line number Diff line number Diff line change
Expand Up @@ -1366,14 +1366,18 @@ TEST_IMPL(GLM_PREFIX, vec4_max) {
TEST_IMPL(GLM_PREFIX, vec4_min) {
vec4 v1 = {2.104f, -3.012f, -4.10f, -4.10f};
vec4 v2 = {-12.35f, -31.140f, -43.502f, -43.502f};
#ifndef CGLM_FAST_MATH
vec4 v3 = {INFINITY, 0.0f, 0.0f, 0.0f};
#endif
// vec4 v4 = {NAN, INFINITY, 2.0f, 2.0f};
// vec4 v5 = {NAN, -1.0f, -1.0f, -1.0f};
vec4 v6 = {-1.0f, -11.0f, 11.0f, 11.0f};

ASSERT(test_eq(GLM(vec4_min)(v1), -4.10f))
ASSERT(test_eq(GLM(vec4_min)(v2), -43.502f))
#ifndef CGLM_FAST_MATH
ASSERT(test_eq(GLM(vec4_min)(v3), 0.0f))
#endif
// ASSERT(isnan(GLM(vec4_min)(v4)))
// ASSERT(isnan(GLM(vec4_min)(v5)))
ASSERT(test_eq(GLM(vec4_min)(v6), -11.0f))
Expand Down

0 comments on commit c12f318

Please sign in to comment.