@@ -224,16 +224,7 @@ typedef struct _gmp_temp {
224
224
#define GMP_BIG_ENDIAN (1 << 3)
225
225
#define GMP_NATIVE_ENDIAN (1 << 4)
226
226
227
- #define GMP_42_OR_NEWER \
228
- ((__GNU_MP_VERSION >= 5) || (__GNU_MP_VERSION >= 4 && __GNU_MP_VERSION_MINOR >= 2))
229
-
230
- /* The maximum base for input and output conversions is 62 from GMP 4.2
231
- * onwards. */
232
- #if GMP_42_OR_NEWER
233
- # define MAX_BASE 62
234
- #else
235
- # define MAX_BASE 36
236
- #endif
227
+ #define GMP_MAX_BASE 62
237
228
238
229
#define IS_GMP (zval ) \
239
230
(Z_TYPE_P(zval) == IS_OBJECT && instanceof_function(Z_OBJCE_P(zval), gmp_ce TSRMLS_CC))
@@ -1048,8 +1039,8 @@ ZEND_FUNCTION(gmp_init)
1048
1039
return ;
1049
1040
}
1050
1041
1051
- if (base && (base < 2 || base > MAX_BASE )) {
1052
- php_error_docref (NULL TSRMLS_CC , E_WARNING , "Bad base for conversion: %pd (should be between 2 and %d)" , base , MAX_BASE );
1042
+ if (base && (base < 2 || base > GMP_MAX_BASE )) {
1043
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "Bad base for conversion: %pd (should be between 2 and %d)" , base , GMP_MAX_BASE );
1053
1044
RETURN_FALSE ;
1054
1045
}
1055
1046
@@ -1204,15 +1195,10 @@ ZEND_FUNCTION(gmp_strval)
1204
1195
return ;
1205
1196
}
1206
1197
1207
- #if MAX_BASE == 62
1208
- /* Although the maximum base in general in GMP >= 4.2 is 62, mpz_get_str()
1198
+ /* Although the maximum base in general in GMP is 62, mpz_get_str()
1209
1199
* is explicitly limited to -36 when dealing with negative bases. */
1210
- if ((base < 2 && base > -2 ) || base > MAX_BASE || base < -36 ) {
1211
- 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 );
1212
- #else
1213
- if (base < 2 || base > MAX_BASE ) {
1214
- php_error_docref (NULL TSRMLS_CC , E_WARNING , "Bad base for conversion: %pd (should be between 2 and %d)" , base , MAX_BASE );
1215
- #endif
1200
+ if ((base < 2 && base > -2 ) || base > GMP_MAX_BASE || base < -36 ) {
1201
+ 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 );
1216
1202
RETURN_FALSE ;
1217
1203
}
1218
1204
@@ -1596,14 +1582,7 @@ ZEND_FUNCTION(gmp_rootrem)
1596
1582
add_next_index_zval (return_value , & result1 );
1597
1583
add_next_index_zval (return_value , & result2 );
1598
1584
1599
- #if GMP_42_OR_NEWER
1600
1585
mpz_rootrem (gmpnum_result1 , gmpnum_result2 , gmpnum_a , (gmp_ulong ) nth );
1601
- #else
1602
- mpz_root (gmpnum_result1 , gmpnum_a , (gmp_ulong ) nth );
1603
- mpz_pow_ui (gmpnum_result2 , gmpnum_result1 , (gmp_ulong ) nth );
1604
- mpz_sub (gmpnum_result2 , gmpnum_a , gmpnum_result2 );
1605
- mpz_abs (gmpnum_result2 , gmpnum_result2 );
1606
- #endif
1607
1586
1608
1587
FREE_GMP_TEMP (temp_a );
1609
1588
}
@@ -1779,7 +1758,7 @@ ZEND_FUNCTION(gmp_random)
1779
1758
1780
1759
if (!GMPG (rand_initialized )) {
1781
1760
/* Initialize */
1782
- gmp_randinit_lc_2exp_size (GMPG (rand_state ), 32L );
1761
+ gmp_randinit_mt (GMPG (rand_state ));
1783
1762
1784
1763
/* Seed */
1785
1764
gmp_randseed_ui (GMPG (rand_state ), GENERATE_SEED ());
0 commit comments