com php-src: Normalize gmp_remroot() behavior to GM P 5.1: ext/gmp/gmp.c ext/gmp/tests/gmp_remroo t.phpt

From: Date: Thu, 16 Apr 2015 14:27:42 +0000
Subject: com php-src: Normalize gmp_remroot() behavior to GM P 5.1: ext/gmp/gmp.c ext/gmp/tests/gmp_remroo t.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-86334@lists.php.net to get a copy of this message
Commit: 7e049b04270b3f46970dcf68b8b2bf12e0c6babd Author: Nikita Popov <nikic@php.net> Thu, 16 Apr 2015 16:27:42 +0200 Parents: 8e167a2a00175753a26bd812fb4d2c881e68e3db Branches: PHP-5.6 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7e049b04270b3f46970dcf68b8b2bf12e0c6babd Log: Normalize gmp_remroot() behavior to GMP 5.1 Changed paths: M ext/gmp/gmp.c M ext/gmp/tests/gmp_remroot.phpt Diff: diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index 12b88c6..6bc1d3f 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -238,6 +238,9 @@ typedef struct _gmp_temp { #define GMP_42_OR_NEWER \ ((__GNU_MP_VERSION >= 5) || (__GNU_MP_VERSION >= 4 && __GNU_MP_VERSION_MINOR >= 2)) +#define GMP_51_OR_NEWER \ + ((__GNU_MP_VERSION >= 6) || (__GNU_MP_VERSION >= 5 && __GNU_MP_VERSION_MINOR >= 1)) + /* The maximum base for input and output conversions is 62 from GMP 4.2 * onwards. */ #if GMP_42_OR_NEWER @@ -1607,13 +1610,14 @@ ZEND_FUNCTION(gmp_rootrem) add_index_zval(return_value, 0, gmp_create(&gmpnum_result1 TSRMLS_CC)); add_index_zval(return_value, 1, gmp_create(&gmpnum_result2 TSRMLS_CC)); -#if GMP_42_OR_NEWER +#if GMP_51_OR_NEWER + /* mpz_rootrem() is supported since GMP 4.2, but buggy wrt odd roots + * of negative numbers */ mpz_rootrem(gmpnum_result1, gmpnum_result2, gmpnum_a, (unsigned long) nth); #else mpz_root(gmpnum_result1, gmpnum_a, (unsigned long) nth); mpz_pow_ui(gmpnum_result2, gmpnum_result1, (unsigned long) nth); mpz_sub(gmpnum_result2, gmpnum_a, gmpnum_result2); - mpz_abs(gmpnum_result2, gmpnum_result2); #endif FREE_GMP_TEMP(temp_a); diff --git a/ext/gmp/tests/gmp_remroot.phpt b/ext/gmp/tests/gmp_remroot.phpt index 4a3539d..331f447 100644 --- a/ext/gmp/tests/gmp_remroot.phpt +++ b/ext/gmp/tests/gmp_remroot.phpt @@ -56,7 +56,7 @@ array(2) { [1]=> object(GMP)#%d (1) { ["num"]=> - string(2) "36" + string(3) "-36" } } array(2) {

« previous php.cvs (#86334) next »