Skip to content

Commit c669aaa

Browse files
committed
Merge branch 'PHP-5.6'
Conflicts: ext/gmp/gmp.c
2 parents feaabd0 + 25e45a9 commit c669aaa

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

ext/gmp/gmp.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ typedef struct _gmp_temp {
245245

246246
#define GMP_MAX_BASE 62
247247

248+
#define GMP_51_OR_NEWER \
249+
((__GNU_MP_VERSION >= 6) || (__GNU_MP_VERSION >= 5 && __GNU_MP_VERSION_MINOR >= 1))
250+
248251
#define IS_GMP(zval) \
249252
(Z_TYPE_P(zval) == IS_OBJECT && instanceof_function(Z_OBJCE_P(zval), gmp_ce))
250253

@@ -1575,7 +1578,15 @@ ZEND_FUNCTION(gmp_rootrem)
15751578
add_next_index_zval(return_value, &result1);
15761579
add_next_index_zval(return_value, &result2);
15771580

1581+
#if GMP_51_OR_NEWER
1582+
/* mpz_rootrem() is supported since GMP 4.2, but buggy wrt odd roots
1583+
* of negative numbers */
15781584
mpz_rootrem(gmpnum_result1, gmpnum_result2, gmpnum_a, (gmp_ulong) nth);
1585+
#else
1586+
mpz_root(gmpnum_result1, gmpnum_a, (gmp_ulong) nth);
1587+
mpz_pow_ui(gmpnum_result2, gmpnum_result1, (gmp_ulong) nth);
1588+
mpz_sub(gmpnum_result2, gmpnum_a, gmpnum_result2);
1589+
#endif
15791590

15801591
FREE_GMP_TEMP(temp_a);
15811592
}

ext/gmp/tests/gmp_random_bits.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var_dump(gmp_random_bits(-1));
1313
gmp_random_bits(1);
1414
gmp_random_bits(1024);
1515

16-
// 2 seconds to make sure the numbers stay in range
16+
// 0.5 seconds to make sure the numbers stay in range
1717
$start = microtime(true);
1818
$limit = (2 ** 30) - 1;
1919
while (1) {
@@ -26,7 +26,7 @@ while (1) {
2626
}
2727
}
2828

29-
if (microtime(true) - $start > 2) {
29+
if (microtime(true) - $start > 0.5) {
3030
break;
3131
}
3232
}

ext/gmp/tests/gmp_random_range.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ gmp_random_range(-1, $plusTen);
3030
gmp_random_range($zero, $plusTen);
3131
gmp_random_range($minusTen, $plusTen);
3232

33-
// 2 seconds to make sure the numbers stay in range
33+
// 0.5 seconds to make sure the numbers stay in range
3434
$start = microtime(true);
3535
while (1) {
3636
for ($i = 0; $i < 5000; $i++) {
@@ -56,7 +56,7 @@ while (1) {
5656
}
5757
}
5858

59-
if (microtime(true) - $start > 2) {
59+
if (microtime(true) - $start > 0.5) {
6060
break;
6161
}
6262
}

ext/gmp/tests/gmp_remroot.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ array(2) {
5656
[1]=>
5757
object(GMP)#%d (1) {
5858
["num"]=>
59-
string(2) "36"
59+
string(3) "-36"
6060
}
6161
}
6262
array(2) {

0 commit comments

Comments
 (0)