com php-src: Drop support for GMP 4.1: UPGRADING ext/gmp/config.m4 ext/gmp/gmp.c ext/gmp/tests/bug50283.phpt
| From: | Nikita Popov | Date: | Sun, 28 Sep 2014 18:46:22 +0000 |
| Subject: | com php-src: Drop support for GMP 4.1: UPGRADING ext/gmp/config.m4 ext/gmp/gmp.c ext/gmp/tests/bug50283.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-81995@lists.php.net to get a copy of this message | ||
Commit: bb0c142156cde43203b1dbc53dc9fd40fca7332b
Author: Nikita Popov <nikic@php.net> Sun, 28 Sep 2014 20:39:19 +0200
Parents: 581c86c07fdbd37dbe22825282f9fc498f959ad6
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=bb0c142156cde43203b1dbc53dc9fd40fca7332b
Log:
Drop support for GMP 4.1
* Consistent base conversion support (max: 62)
* mpz_remroot always available
* Use gmp_randinit_mt instead of LCG
Changed paths:
M UPGRADING
M ext/gmp/config.m4
M ext/gmp/gmp.c
M ext/gmp/tests/bug50283.phpt
Diff:
diff --git a/UPGRADING b/UPGRADING
index dc2f8fe..1247b61 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -35,6 +35,7 @@ PHP X.Y UPGRADE NOTES
handler, too.
- GMP
+ . Requires libgmp version 4.2 or newer now.
. gmp_setbit() and gmp_clrbit() now return FALSE for negative indices, making
them consistent with other GMP functions.
diff --git a/ext/gmp/config.m4 b/ext/gmp/config.m4
index 2140aaf..0388d54 100644
--- a/ext/gmp/config.m4
+++ b/ext/gmp/config.m4
@@ -1,7 +1,3 @@
-dnl
-dnl $Id$
-dnl
-
PHP_ARG_WITH(gmp, for GNU MP support,
[ --with-gmp[=DIR] Include GNU MP support])
@@ -15,14 +11,9 @@ if test "$PHP_GMP" != "no"; then
AC_MSG_ERROR(Unable to locate gmp.h)
fi
- PHP_CHECK_LIBRARY(gmp, __gmp_randinit_lc_2exp_size,
+ PHP_CHECK_LIBRARY(gmp, __gmpz_rootrem,
[],[
- PHP_CHECK_LIBRARY(gmp, gmp_randinit_lc_2exp_size,
- [],[
- AC_MSG_ERROR([GNU MP Library version 4.1.2 or greater required.])
- ],[
- -L$GMP_DIR/$PHP_LIBDIR
- ])
+ AC_MSG_ERROR([GNU MP Library version 4.2 or greater required.])
],[
-L$GMP_DIR/$PHP_LIBDIR
])
diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c
index 320ac3e..b5c18ec 100644
--- a/ext/gmp/gmp.c
+++ b/ext/gmp/gmp.c
@@ -224,16 +224,7 @@ typedef struct _gmp_temp {
#define GMP_BIG_ENDIAN (1 << 3)
#define GMP_NATIVE_ENDIAN (1 << 4)
-#define GMP_42_OR_NEWER \
- ((__GNU_MP_VERSION >= 5) || (__GNU_MP_VERSION >= 4 && __GNU_MP_VERSION_MINOR >=
2))
-
-/* The maximum base for input and output conversions is 62 from GMP 4.2
- * onwards. */
-#if GMP_42_OR_NEWER
-# define MAX_BASE 62
-#else
-# define MAX_BASE 36
-#endif
+#define GMP_MAX_BASE 62
#define IS_GMP(zval) \
(Z_TYPE_P(zval) == IS_OBJECT && instanceof_function(Z_OBJCE_P(zval), gmp_ce TSRMLS_CC))
@@ -1048,8 +1039,8 @@ ZEND_FUNCTION(gmp_init)
return;
}
- if (base && (base < 2 || base > MAX_BASE)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %pd (should be between
2 and %d)", base, MAX_BASE);
+ if (base && (base < 2 || base > GMP_MAX_BASE)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %pd (should be between
2 and %d)", base, GMP_MAX_BASE);
RETURN_FALSE;
}
@@ -1204,15 +1195,10 @@ ZEND_FUNCTION(gmp_strval)
return;
}
-#if MAX_BASE == 62
- /* Although the maximum base in general in GMP >= 4.2 is 62, mpz_get_str()
+ /* Although the maximum base in general in GMP is 62, mpz_get_str()
* is explicitly limited to -36 when dealing with negative bases. */
- if ((base < 2 && base > -2) || base > MAX_BASE || base < -36) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %pd (should be between
2 and %d or -2 and -36)", base, MAX_BASE);
-#else
- if (base < 2 || base > MAX_BASE) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %pd (should be between
2 and %d)", base, MAX_BASE);
-#endif
+ if ((base < 2 && base > -2) || base > GMP_MAX_BASE || base < -36) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %pd (should be between
2 and %d or -2 and -36)", base, GMP_MAX_BASE);
RETURN_FALSE;
}
@@ -1596,14 +1582,7 @@ ZEND_FUNCTION(gmp_rootrem)
add_next_index_zval(return_value, &result1);
add_next_index_zval(return_value, &result2);
-#if GMP_42_OR_NEWER
mpz_rootrem(gmpnum_result1, gmpnum_result2, gmpnum_a, (gmp_ulong) nth);
-#else
- mpz_root(gmpnum_result1, gmpnum_a, (gmp_ulong) nth);
- mpz_pow_ui(gmpnum_result2, gmpnum_result1, (gmp_ulong) nth);
- mpz_sub(gmpnum_result2, gmpnum_a, gmpnum_result2);
- mpz_abs(gmpnum_result2, gmpnum_result2);
-#endif
FREE_GMP_TEMP(temp_a);
}
@@ -1779,7 +1758,7 @@ ZEND_FUNCTION(gmp_random)
if (!GMPG(rand_initialized)) {
/* Initialize */
- gmp_randinit_lc_2exp_size(GMPG(rand_state), 32L);
+ gmp_randinit_mt(GMPG(rand_state));
/* Seed */
gmp_randseed_ui(GMPG(rand_state), GENERATE_SEED());
diff --git a/ext/gmp/tests/bug50283.phpt b/ext/gmp/tests/bug50283.phpt
index 13eef54..561cd3d 100644
--- a/ext/gmp/tests/bug50283.phpt
+++ b/ext/gmp/tests/bug50283.phpt
@@ -2,7 +2,6 @@
Feature Request #50283 (allow base in gmp_strval to use full range: 2 to 62, and -2 to -36)
--SKIPIF--
<?php if (!extension_loaded("gmp")) print "skip"; ?>
-<?php if (version_compare(GMP_VERSION, "4.2.0", "<")) print
"skip"; ?>
--FILE--
<?php
$a = gmp_init("0x41682179fbf5");