RE: [PHP-CVS] com php-src: Fix build as done in master in commit 040331c36462eac94308bbef3200ee11389ca444: ext/standard/array.c
ext/standard/php_math.h
| From: | Anatol Belski | Date: | Wed, 17 Aug 2016 17:21:14 +0000 |
| Subject: | RE: [PHP-CVS] com php-src: Fix build as done in master in commit 040331c36462eac94308bbef3200ee11389ca444: ext/standard/array.c ext/standard/php_math.h |
||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-93913@lists.php.net to get a copy of this message | ||
Hi Kalle,
> -----Original Message-----
> From: Kalle Sommer Nielsen [mailto:kalle@php.net]
> Sent: Wednesday, August 17, 2016 2:10 PM
> To: php-cvs@lists.php.net
> Subject: [PHP-CVS] com php-src: Fix build as done in master in commit
> 040331c36462eac94308bbef3200ee11389ca444: ext/standard/array.c
> ext/standard/php_math.h
>
> Commit: 9b783107e550584b6e4b00d424d29c82b88a1286
> Author: Kalle Sommer Nielsen <kalle@php.net> Wed, 17 Aug 2016
> 14:10:24 +0200
> Parents: 8a1fbdda43ed3b36b9331aee1eaace3d961caee9
> Branches: PHP-7.1
>
> Link: http://git.php.net/?p=php-
> src.git;a=commitdiff;h=9b783107e550584b6e4b00d424d29c82b88a1286
>
> Log:
> Fix build as done in master in commit
> 040331c36462eac94308bbef3200ee11389ca444
>
> The reason why we cannot use round() here, is that it does not come with the
> standard C library on Windows, I don't think this affects other systems.
>
> At the same time, also expose _php_math_round()
>
> Changed paths:
> M ext/standard/array.c
> M ext/standard/php_math.h
>
>
> Diff:
> diff --git a/ext/standard/array.c b/ext/standard/array.c index 538460b..fbbf3cf
> 100644
> --- a/ext/standard/array.c
> +++ b/ext/standard/array.c
> @@ -45,6 +45,7 @@
> #include "basic_functions.h"
> #include "php_string.h"
> #include "php_rand.h"
> +#include "php_math.h"
> #include "zend_smart_str.h"
> #ifdef HAVE_SPL
> #include "ext/spl/spl_array.h"
> @@ -2106,7 +2107,7 @@ PHP_FUNCTION(array_fill_keys)
> php_error_docref(NULL, E_WARNING, "The supplied
> range exceeds the maximum array size: start=%0.0f end=%0.0f", end, start); \
> RETURN_FALSE; \
> } \
> - size = (uint32_t)round(__calc_size); \
> + size = (uint32_t)_php_math_round(__calc_size, 0,
> PHP_ROUND_HALF_UP);
> +\
> array_init_size(return_value, size); \
> zend_hash_real_init(Z_ARRVAL_P(return_value), 1); \
> } while (0)
> diff --git a/ext/standard/php_math.h b/ext/standard/php_math.h index
> 406fd49..62c089b 100644
> --- a/ext/standard/php_math.h
> +++ b/ext/standard/php_math.h
> @@ -22,6 +22,7 @@
> #ifndef PHP_MATH_H
> #define PHP_MATH_H
>
> +PHPAPI double _php_math_round(double, int, int);
> PHPAPI zend_string *_php_math_number_format(double, int, char, char);
> PHPAPI zend_string *_php_math_number_format_ex(double, int, char *, size_t,
> char *, size_t); PHPAPI zend_string * _php_math_longtobase(zval *arg, int
> base);
>
round() is fine with vc14. Still C99 though :(, so going formally it should be done. Otherwise, for
an older compiler one could macrify round() in place.
Regards
Anatol