Skip to content

Commit 1c26440

Browse files
authored
Merge pull request #277 from qnx-ports/merge_upstream
Replace obsolete isinff(...)
2 parents e5d65a6 + 61e62da commit 1c26440

File tree

3 files changed

+24
-41
lines changed

3 files changed

+24
-41
lines changed

meson.build

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,12 @@ if cc.get_id() == 'msvc'
8585
]
8686
else
8787
test_cflags = [
88-
'-ffast-math',
88+
'-fno-math-errno',
89+
'-funsafe-math-optimizations',
90+
# '-ffinite-math-only',
91+
'-fno-rounding-math',
92+
'-fno-signaling-nans',
93+
'-fcx-limited-range',
8994
'-fstrict-aliasing',
9095
'-Wpointer-arith',
9196
'-Wstrict-prototypes',
@@ -173,7 +178,6 @@ endif
173178

174179
math_exts = [
175180
'sincosf',
176-
'isinff',
177181
'isnanf',
178182
]
179183

src/graphene-box.c

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -427,55 +427,39 @@ graphene_box_get_depth (const graphene_box_t *box)
427427
static inline bool
428428
graphene_box_is_empty (const graphene_box_t *box)
429429
{
430-
#ifdef HAVE_ISINFF
431430
float vmin[3], vmax[3];
432431

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

436-
return (isinff (vmin[0]) == 1 && isinff (vmin[1]) == 1 && isinff (vmin[2]) == 1) &&
437-
(isinff (vmax[0]) == -1 && isinff (vmax[1]) == -1 && isinff (vmax[2]) == -1);
438-
#else
439-
graphene_simd4f_t neg_inf = graphene_simd4f_init (-INFINITY, -INFINITY, -INFINITY, 0.f);
440-
graphene_simd4f_t pos_inf = graphene_simd4f_init (INFINITY, INFINITY, INFINITY, 0.f);
441-
442-
/* This is only every going to be valid for boxes that we have
443-
* initialized ourselves, because we use the same values; the
444-
* bitwise comparison will not hold for infinities generated by
445-
* other operations
446-
*/
447-
int min_cmp = memcmp (&box->min.value, &pos_inf, sizeof (graphene_simd4f_t));
448-
int max_cmp = memcmp (&box->max.value, &neg_inf, sizeof (graphene_simd4f_t));
449-
450-
return min_cmp == 0 && max_cmp == 0;
451-
#endif
435+
bool vmin_valid = (isinf(vmin[0]) && !signbit(vmin[0])) &&
436+
(isinf(vmin[1]) && !signbit(vmin[1])) &&
437+
(isinf(vmin[2]) && !signbit(vmin[2]));
438+
439+
bool vmax_valid = (isinf(vmax[0]) && signbit(vmax[0])) &&
440+
(isinf(vmax[1]) && signbit(vmax[1])) &&
441+
(isinf(vmax[2]) && signbit(vmax[2]));
442+
443+
return vmin_valid && vmax_valid;
452444
}
453445

454446
static inline bool
455447
graphene_box_is_infinity (const graphene_box_t *box)
456448
{
457-
#ifdef HAVE_ISINFF
458449
float vmin[3], vmax[3];
459450

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

463-
return (isinff (vmin[0]) == -1 && isinff (vmin[1]) == -1 && isinff (vmin[2]) == -1) &&
464-
(isinff (vmax[0]) == 1 && isinff (vmax[1]) == 1 && isinff (vmax[2]) == 1);
465-
#else
466-
graphene_simd4f_t neg_inf = graphene_simd4f_init (-INFINITY, -INFINITY, -INFINITY, 0.f);
467-
graphene_simd4f_t pos_inf = graphene_simd4f_init (INFINITY, INFINITY, INFINITY, 0.f);
468-
469-
/* This is only every going to be valid for boxes that we have
470-
* initialized ourselves, because we use the same values; the
471-
* bitwise comparison will not hold for infinities generated by
472-
* other operations
473-
*/
474-
int min_cmp = memcmp (&box->min.value, &neg_inf, sizeof (graphene_simd4f_t));
475-
int max_cmp = memcmp (&box->max.value, &pos_inf, sizeof (graphene_simd4f_t));
476-
477-
return min_cmp == 0 && max_cmp == 0;
478-
#endif
454+
bool vmin_valid = (isinf(vmin[0]) && signbit(vmin[0])) &&
455+
(isinf(vmin[1]) && signbit(vmin[1])) &&
456+
(isinf(vmin[2]) && signbit(vmin[2]));
457+
458+
bool vmax_valid = (isinf(vmax[0]) && !signbit(vmax[0])) &&
459+
(isinf(vmax[1]) && !signbit(vmax[1])) &&
460+
(isinf(vmax[2]) && !signbit(vmax[2]));
461+
462+
return vmin_valid && vmax_valid;
479463
}
480464

481465
/**

src/graphene-simd4f.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,13 +1435,8 @@ approx_equal (float a,
14351435
float b,
14361436
float epsilon)
14371437
{
1438-
#ifdef HAVE_ISINFF
1439-
if (isinff (a) && isinff (b))
1440-
return true;
1441-
#else
14421438
if (fpclassify (a) == FP_INFINITE && fpclassify (b) == FP_INFINITE)
14431439
return true;
1444-
#endif
14451440

14461441
float diff = fabsf (a - b);
14471442
if (isnan (diff))

0 commit comments

Comments
 (0)