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

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Nov 20, 2019

As I'm not sure if we are moving to C99 in master/PHP 8 so I'm putting this up for review.

@cmb69
Copy link
Member

cmb69 commented Nov 20, 2019

For MSVC (can't speek for other compilers/libraries), this should be fine, since all of these functions are supposed to be supported by VS 2015 and up. This code should be removed as well, though.

@Girgias
Copy link
Member Author

Girgias commented Nov 20, 2019

For MSVC (can't speek for other compilers/libraries), this should be fine, since all of these functions are supposed to be supported by VS 2015 and up. This code should be removed as well, though.

Will remove this piece of code then

@carusogabriel
Copy link
Contributor

As I'm not sure if we are moving to C99 in master/PHP

AFAIK we have moved. See b51a99a.

@Girgias
Copy link
Member Author

Girgias commented Nov 20, 2019

@cmb69 should I modify https://php-lxr.adamharvey.name/source/xref/master/Zend/zend_config.w32.h#53 too?

I'm also asking myself if the special zend_isinf, zend_isnan and zend_isfinite usage shouldn't be phased out? At least in code that we control.

@cmb69
Copy link
Member

cmb69 commented Nov 20, 2019

@Girgias, it seems to me that this is needed for C++ compatibility, and as such should not be removed.

@Girgias
Copy link
Member Author

Girgias commented Nov 20, 2019

@Girgias, it seems to me that this is needed for C++ compatibility, and as such should not be removed.

Makes sense will leave it then :)

dnl log2 could be used to improve the log function, however it requires C99. The
dnl check for log2 should be turned on, as soon as we support C99.
AC_CHECK_FUNCS(asinh acosh atanh log1p hypot)
AC_FUNC_FNMATCH
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming the removal of AC_FUNC_FNMATCH here was not intentional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes indeed

@@ -422,16 +414,7 @@ AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <math.h>
#include <stdlib.h>

#ifdef HAVE_ISINF
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to C99 the INFINITY macro should always exist, so it should be possibly to adjust the _zend_get_inf implementation to always use that and drop the two autoconf checks for infinity representations here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly for NAN. That one is not guaranteed to exist, but as PHP assumes it's running on a platform with IEEE 754 compliant floats, it should be defined on platforms we target.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I would suggest doing this separately, before handling zend_isinf and friends, as it removes some of the more ugly users...)

@nikic
Copy link
Member

nikic commented Dec 4, 2019

Apart from the AC_FUNC_FNMATCH removal, the asinh etc part here looks fine, can you please land it separately?

@Girgias
Copy link
Member Author

Girgias commented Dec 4, 2019

Apart from the AC_FUNC_FNMATCH removal, the asinh etc part here looks fine, can you please land it separately?

Just to be sure do you want me to split the changes from math.c and the others one into two different commits or should I split every AC check removal into it's own commit?

@nikic
Copy link
Member

nikic commented Dec 4, 2019

All the changes for math.c in one commit (feel free to directly commit that as well).

@Girgias
Copy link
Member Author

Girgias commented Dec 4, 2019

Merged the math.c changes as 2d0b0d6
Will open a new PR for the configure scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants