Skip to content

Remove unnecessary C99< checks for maths functions #4936

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

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
105 changes: 7 additions & 98 deletions ext/standard/math.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,83 +204,6 @@ PHPAPI double _php_math_round(double value, int places, int mode) {
}
/* }}} */

/* {{{ php_asinh
*/
static double php_asinh(double z)
{
#ifdef HAVE_ASINH
return(asinh(z));
#else
# ifdef _WIN64
if (z >= 0) {
return log(z + sqrt(z * z + 1));
}
else {
return -log(-z + sqrt(z * z + 1));
}
# else
return(log(z + sqrt(1 + pow(z, 2))) / log(M_E));
# endif
#endif
}
/* }}} */

/* {{{ php_acosh
*/
static double php_acosh(double x)
{
#ifdef HAVE_ACOSH
return(acosh(x));
#else
# ifdef _WIN64
if (x >= 1) {
return log(x + sqrt(x * x - 1));
} else {
return ZEND_NAN;
}
# else
return(log(x + sqrt(x * x - 1)));
# endif
#endif
}
/* }}} */

/* {{{ php_atanh
*/
static double php_atanh(double z)
{
#ifdef HAVE_ATANH
return(atanh(z));
#else
return(0.5 * log((1 + z) / (1 - z)));
#endif
}
/* }}} */

/* {{{ php_log1p
*/
static double php_log1p(double x)
{
#ifdef HAVE_LOG1P
return(log1p(x));
#else
return(log(1 + x));
#endif
}
/* }}} */

/* {{{ php_expm1
*/
static double php_expm1(double x)
{
#ifndef PHP_WIN32
return(expm1(x));
#else
return(exp(x) - 1);
#endif
}
/* }}}*/

/* {{{ proto int|float abs(int|float number)
Return the absolute value of the number */
PHP_FUNCTION(abs)
Expand Down Expand Up @@ -533,7 +456,7 @@ PHP_FUNCTION(asinh)
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_DOUBLE(num)
ZEND_PARSE_PARAMETERS_END();
RETURN_DOUBLE(php_asinh(num));
RETURN_DOUBLE(asinh(num));
}
/* }}} */

Expand All @@ -546,7 +469,7 @@ PHP_FUNCTION(acosh)
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_DOUBLE(num)
ZEND_PARSE_PARAMETERS_END();
RETURN_DOUBLE(php_acosh(num));
RETURN_DOUBLE(acosh(num));
}
/* }}} */

Expand All @@ -559,7 +482,7 @@ PHP_FUNCTION(atanh)
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_DOUBLE(num)
ZEND_PARSE_PARAMETERS_END();
RETURN_DOUBLE(php_atanh(num));
RETURN_DOUBLE(atanh(num));
}
/* }}} */

Expand Down Expand Up @@ -644,10 +567,7 @@ PHP_FUNCTION(exp)
/* }}} */

/* {{{ proto float expm1(float number)
Returns exp(number) - 1, computed in a way that accurate even when the value of number is close to zero */
/*
WARNING: this function is experimental: it could change its name or
disappear in the next version of PHP!
Returns exp(number) - 1, computed in a way that accurate even when the value of number is close to zero
*/
PHP_FUNCTION(expm1)
{
Expand All @@ -657,15 +577,12 @@ PHP_FUNCTION(expm1)
Z_PARAM_DOUBLE(num)
ZEND_PARSE_PARAMETERS_END();

RETURN_DOUBLE(php_expm1(num));
RETURN_DOUBLE(expm1(num));
}
/* }}} */

/* {{{ proto float log1p(float number)
Returns log(1 + number), computed in a way that accurate even when the value of number is close to zero */
/*
WARNING: this function is experimental: it could change its name or
disappear in the next version of PHP!
Returns log(1 + number), computed in a way that accurate even when the value of number is close to zero
*/
PHP_FUNCTION(log1p)
{
Expand All @@ -675,7 +592,7 @@ PHP_FUNCTION(log1p)
Z_PARAM_DOUBLE(num)
ZEND_PARSE_PARAMETERS_END();

RETURN_DOUBLE(php_log1p(num));
RETURN_DOUBLE(log1p(num));
}
/* }}} */

Expand All @@ -695,11 +612,9 @@ PHP_FUNCTION(log)
RETURN_DOUBLE(log(num));
}

#ifdef HAVE_LOG2
if (base == 2.0) {
RETURN_DOUBLE(log2(num));
}
#endif

if (base == 10.0) {
RETURN_DOUBLE(log10(num));
Expand Down Expand Up @@ -757,13 +672,7 @@ PHP_FUNCTION(hypot)
Z_PARAM_DOUBLE(num2)
ZEND_PARSE_PARAMETERS_END();

#if HAVE_HYPOT
RETURN_DOUBLE(hypot(num1, num2));
#elif defined(_MSC_VER)
RETURN_DOUBLE(_hypot(num1, num2));
#else
RETURN_DOUBLE(sqrt((num1 * num1) + (num2 * num2)));
#endif
}
/* }}} */

Expand Down