Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use obsolete isinff and isnanf functions #174

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ endif

math_exts = [
'sincosf',
'isinff',
'isnanf',
]

foreach mfunc: math_exts
Expand Down
20 changes: 14 additions & 6 deletions src/graphene-box.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,14 +427,18 @@ graphene_box_get_depth (const graphene_box_t *box)
static inline bool
graphene_box_is_empty (const graphene_box_t *box)
{
#ifdef HAVE_ISINFF
#if defined(isinf) && defined(signbit)
float vmin[3], vmax[3];

graphene_simd4f_dup_3f (box->min.value, vmin);
graphene_simd4f_dup_3f (box->max.value, vmax);

return (isinff (vmin[0]) == 1 && isinff (vmin[1]) == 1 && isinff (vmin[2]) == 1) &&
(isinff (vmax[0]) == -1 && isinff (vmax[1]) == -1 && isinff (vmax[2]) == -1);
return ((isinf (vmin[0]) && !signbit (vmin[0])) &&
(isinf (vmin[1]) && !signbit (vmin[1])) &&
(isinf (vmin[2]) && !signbit (vmin[2]))) &&
((isinf (vmax[0]) && signbit (vmax[0])) &&
(isinf (vmax[1]) && signbit (vmax[1])) &&
(isinf (vmax[2]) && signbit (vmax[2])));
#else
graphene_simd4f_t neg_inf = graphene_simd4f_init (-INFINITY, -INFINITY, -INFINITY, 0.f);
graphene_simd4f_t pos_inf = graphene_simd4f_init (INFINITY, INFINITY, INFINITY, 0.f);
Expand All @@ -454,14 +458,18 @@ graphene_box_is_empty (const graphene_box_t *box)
static inline bool
graphene_box_is_infinity (const graphene_box_t *box)
{
#ifdef HAVE_ISINFF
#if defined(isinf) && defined(signbit)
float vmin[3], vmax[3];

graphene_simd4f_dup_3f (box->min.value, vmin);
graphene_simd4f_dup_3f (box->max.value, vmax);

return (isinff (vmin[0]) == -1 && isinff (vmin[1]) == -1 && isinff (vmin[2]) == -1) &&
(isinff (vmax[0]) == 1 && isinff (vmax[1]) == 1 && isinff (vmax[2]) == 1);
return ((isinf (vmin[0]) && signbit (vmin[0])) &&
(isinf (vmin[1]) && signbit (vmin[1])) &&
(isinf (vmin[2]) && signbit (vmin[2]))) &&
((isinf (vmax[0]) && !signbit (vmax[0])) &&
(isinf (vmax[1]) && !signbit (vmax[1])) &&
(isinf (vmax[2]) && !signbit (vmax[2])));
#else
graphene_simd4f_t neg_inf = graphene_simd4f_init (-INFINITY, -INFINITY, -INFINITY, 0.f);
graphene_simd4f_t pos_inf = graphene_simd4f_init (INFINITY, INFINITY, INFINITY, 0.f);
Expand Down
12 changes: 6 additions & 6 deletions src/graphene-ray.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,10 @@ graphene_ray_intersect_box (const graphene_ray_t *r,
/* These lines also handle the case where tx_min or tx_max is NaN
* (result of 0 * INFINITY): NaN != NaN
*/
#ifdef HAVE_ISNANF
if (ty_min > tx_min || isnanf (tx_min))
#ifdef isnan
if (ty_min > tx_min || isnan (tx_min))
tx_min = ty_min;
if (ty_max < tx_max || isnanf (tx_max))
if (ty_max < tx_max || isnan (tx_max))
tx_max = ty_max;
#else
if (ty_min > tx_min || fpclassify (tx_min) == FP_NAN)
Expand All @@ -553,10 +553,10 @@ graphene_ray_intersect_box (const graphene_ray_t *r,
if ((tx_min > tz_max) || (tz_min > tx_max))
return GRAPHENE_RAY_INTERSECTION_KIND_NONE;

#ifdef HAVE_ISNANF
if (tz_min > tx_min || isnanf (tx_min))
#ifdef isnan
if (tz_min > tx_min || isnan (tx_min))
tx_min = tz_min;
if (tz_max < tx_max || isnanf (tx_max))
if (tz_max < tx_max || isnan (tx_max))
tx_max = tz_max;
#else
if (tz_min > tx_min || fpclassify (tx_min) == FP_NAN)
Expand Down
4 changes: 2 additions & 2 deletions src/graphene-simd4f.c
Original file line number Diff line number Diff line change
Expand Up @@ -1374,8 +1374,8 @@ approx_equal (float a,
float b,
float epsilon)
{
#ifdef HAVE_ISINFF
if (isinff (a) && isinff (b))
#ifdef isinf
if (isinf (a) && isinf (b))
return true;
#else
if (fpclassify (a) == FP_INFINITE && fpclassify (b) == FP_INFINITE)
Expand Down