Skip to content

Commit 67f8557

Browse files
committed
Remove custom implementation for inifinity and NAN as we can now rely on C99
Those ZEND_* constant variant are now identical to their C counterpart, we may considering removing them in the future.
1 parent 2d0b0d6 commit 67f8557

File tree

1 file changed

+3
-43
lines changed

1 file changed

+3
-43
lines changed

Zend/zend_portability.h

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -438,49 +438,9 @@ char *alloca();
438438
#define ZEND_BIT_TEST(bits, bit) \
439439
(((bits)[(bit) / (sizeof((bits)[0])*8)] >> ((bit) & (sizeof((bits)[0])*8-1))) & 1)
440440

441-
/* We always define a function, even if there's a macro or expression we could
442-
* alias, so that using it in contexts where we can't make function calls
443-
* won't fail to compile on some machines and not others.
444-
*/
445-
static zend_always_inline double _zend_get_inf(void) /* {{{ */
446-
{
447-
#ifdef INFINITY
448-
return INFINITY;
449-
#elif HAVE_HUGE_VAL_INF
450-
return HUGE_VAL;
451-
#elif defined(__i386__) || defined(_X86_) || defined(ALPHA) || defined(_ALPHA) || defined(__alpha)
452-
# define _zend_DOUBLE_INFINITY_HIGH 0x7ff00000
453-
double val = 0.0;
454-
((uint32_t*)&val)[1] = _zend_DOUBLE_INFINITY_HIGH;
455-
((uint32_t*)&val)[0] = 0;
456-
return val;
457-
#elif HAVE_ATOF_ACCEPTS_INF
458-
return atof("INF");
459-
#else
460-
return 1.0/0.0;
461-
#endif
462-
} /* }}} */
463-
#define ZEND_INFINITY (_zend_get_inf())
464-
465-
static zend_always_inline double _zend_get_nan(void) /* {{{ */
466-
{
467-
#ifdef NAN
468-
return NAN;
469-
#elif HAVE_HUGE_VAL_NAN
470-
return HUGE_VAL + -HUGE_VAL;
471-
#elif defined(__i386__) || defined(_X86_) || defined(ALPHA) || defined(_ALPHA) || defined(__alpha)
472-
# define _zend_DOUBLE_QUIET_NAN_HIGH 0xfff80000
473-
double val = 0.0;
474-
((uint32_t*)&val)[1] = _zend_DOUBLE_QUIET_NAN_HIGH;
475-
((uint32_t*)&val)[0] = 0;
476-
return val;
477-
#elif HAVE_ATOF_ACCEPTS_NAN
478-
return atof("NAN");
479-
#else
480-
return 0.0/0.0;
481-
#endif
482-
} /* }}} */
483-
#define ZEND_NAN (_zend_get_nan())
441+
#define ZEND_INFINITY INFINITY
442+
443+
#define ZEND_NAN NAN
484444

485445
#define ZEND_STRL(str) (str), (sizeof(str)-1)
486446
#define ZEND_STRS(str) (str), (sizeof(str))

0 commit comments

Comments
 (0)