]> granicus.if.org Git - php/commitdiff
fix 64bit issues & tests
authorAntony Dovgal <tony2001@php.net>
Thu, 1 Nov 2007 09:25:11 +0000 (09:25 +0000)
committerAntony Dovgal <tony2001@php.net>
Thu, 1 Nov 2007 09:25:11 +0000 (09:25 +0000)
ext/gmp/gmp.c
ext/gmp/tests/015.phpt
ext/gmp/tests/021.phpt
ext/gmp/tests/024.phpt
ext/gmp/tests/025.phpt
ext/gmp/tests/026.phpt

index 2b547d5549314d724e447bba50ff798ab0a7896b..7056fd4b2ef2003a261b51ae8e502834cfa7e8c6 100644 (file)
@@ -770,14 +770,14 @@ ZEND_FUNCTION(gmp_init)
 {
        zval **number_arg;
        mpz_t * gmpnumber;
-       int base=0;
+       long base=0;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|l", &number_arg, &base) == FAILURE) {
                return;
        }
 
        if (base && (base < 2 || base > 36)) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %d (should be between 2 and 36)", base);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %ld (should be between 2 and 36)", base);
                RETURN_FALSE;
        }
 
@@ -816,7 +816,8 @@ ZEND_FUNCTION(gmp_intval)
 ZEND_FUNCTION(gmp_strval)
 {
        zval **gmpnumber_arg;
-       int base=10, num_len;
+       int num_len;
+       long base = 10;
        mpz_t * gmpnum;
        char *out_string;
        int temp_a;
@@ -826,7 +827,7 @@ ZEND_FUNCTION(gmp_strval)
        }
 
        if (base < 2 || base > 36) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %d", base);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %ld", base);
                RETURN_FALSE;
        }
 
@@ -887,7 +888,7 @@ ZEND_FUNCTION(gmp_mul)
 ZEND_FUNCTION(gmp_div_qr)
 {
        zval **a_arg, **b_arg;
-       int round = GMP_ROUND_ZERO;
+       long round = GMP_ROUND_ZERO;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ|l", &a_arg, &b_arg, &round) == FAILURE) {
                return;
@@ -913,7 +914,7 @@ ZEND_FUNCTION(gmp_div_qr)
 ZEND_FUNCTION(gmp_div_r)
 {
        zval **a_arg, **b_arg;
-       int round = GMP_ROUND_ZERO;
+       long round = GMP_ROUND_ZERO;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ|l", &a_arg, &b_arg, &round) == FAILURE) {
                return;
@@ -938,7 +939,7 @@ ZEND_FUNCTION(gmp_div_r)
 ZEND_FUNCTION(gmp_div_q)
 {
        zval **a_arg, **b_arg;
-       int round = GMP_ROUND_ZERO;
+       long round = GMP_ROUND_ZERO;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ|l", &a_arg, &b_arg, &round) == FAILURE) {
                return;
@@ -1037,12 +1038,13 @@ ZEND_FUNCTION(gmp_fact)
    Raise base to power exp */
 ZEND_FUNCTION(gmp_pow)
 {
-       zval **base_arg, **exp_arg;
+       zval **base_arg;
        mpz_t *gmpnum_result, *gmpnum_base;
        int use_ui = 0;
        int temp_base;
+       long exp;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ", &base_arg, &exp_arg) == FAILURE){
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zl", &base_arg, &exp) == FAILURE) {
                return;
        }
 
@@ -1052,18 +1054,16 @@ ZEND_FUNCTION(gmp_pow)
                FETCH_GMP_ZVAL(gmpnum_base, base_arg, temp_base);
        }
 
-       convert_to_long_ex(exp_arg);
-
-       if (Z_LVAL_PP(exp_arg) < 0) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING,"Negative exponent not supported");
+       if (exp < 0) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Negative exponent not supported");
                RETURN_FALSE;
        }
        
        INIT_GMP_NUM(gmpnum_result);
        if (use_ui) {
-               mpz_ui_pow_ui(*gmpnum_result, Z_LVAL_PP(base_arg), Z_LVAL_PP(exp_arg));
+               mpz_ui_pow_ui(*gmpnum_result, Z_LVAL_PP(base_arg), exp);
        } else {
-               mpz_pow_ui(*gmpnum_result, *gmpnum_base, Z_LVAL_PP(exp_arg));
+               mpz_pow_ui(*gmpnum_result, *gmpnum_base, exp);
        }
        FREE_GMP_TEMP(temp_base);
        ZEND_REGISTER_RESOURCE(return_value, gmpnum_result, le_gmp);
@@ -1206,7 +1206,7 @@ ZEND_FUNCTION(gmp_prob_prime)
 {
        zval **gmpnumber_arg;
        mpz_t *gmpnum_a;
-       int reps = 10;
+       long reps = 10;
        int temp_a;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|l", &gmpnumber_arg, &reps) == FAILURE) {
@@ -1369,7 +1369,7 @@ ZEND_FUNCTION(gmp_sign)
    Gets random number */
 ZEND_FUNCTION(gmp_random)
 {
-       int limiter = 20;
+       long limiter = 20;
        mpz_t *gmpnum_result;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &limiter) == FAILURE) {
@@ -1463,7 +1463,8 @@ ZEND_FUNCTION(gmp_xor)
 ZEND_FUNCTION(gmp_setbit)
 {
        zval **a_arg;
-       int index, set = 1;
+       long index;
+       zend_bool set = 1;
        mpz_t *gmpnum_a;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zl|b", &a_arg, &index, &set) == FAILURE) {
@@ -1490,7 +1491,7 @@ ZEND_FUNCTION(gmp_setbit)
 ZEND_FUNCTION(gmp_clrbit)
 {
        zval **a_arg;
-       int index;
+       long index;
        mpz_t *gmpnum_a;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zl", &a_arg, &index) == FAILURE){
@@ -1555,7 +1556,7 @@ ZEND_FUNCTION(gmp_scan0)
        zval **a_arg;
        mpz_t *gmpnum_a;
        int temp_a;
-       int start;
+       long start;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zl", &a_arg, &start) == FAILURE){
                return;
@@ -1580,7 +1581,7 @@ ZEND_FUNCTION(gmp_scan1)
        zval **a_arg;
        mpz_t *gmpnum_a;
        int temp_a;
-       int start;
+       long start;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zl", &a_arg, &start) == FAILURE){
                return;
index b787a21b587edd1e7c6e1600582d6033a923831d..e17ecc7bad4193671a42a8403e8ff9e3831f18e3 100644 (file)
@@ -57,9 +57,11 @@ NULL
 Warning: gmp_pow() expects exactly 2 parameters, 0 given in %s on line %d
 NULL
 
-Warning: gmp_pow(): Unable to convert variable to GMP - wrong type in %s on line %d
-bool(false)
-resource(%d) of type (GMP integer)
+Warning: gmp_pow() expects parameter 2 to be long, array given in %s on line %d
+NULL
+
+Warning: gmp_pow() expects parameter 2 to be long, array given in %s on line %d
+NULL
 
 Warning: gmp_pow(): Unable to convert variable to GMP - wrong type in %s on line %d
 bool(false)
index 3ec947d6409b00166d2fabbc0eb3c72701b96196..275f0bca35d203d5a9af15aa6ecb3df12069a6b6 100644 (file)
@@ -38,7 +38,7 @@ string(1) "1"
 string(1) "2"
 string(1) "1"
 string(10) "8127346234"
-string(1) "0"
+string(10) "8127346234"
 
 Warning: gmp_gcd() expects exactly 2 parameters, 3 given in %s on line %d
 NULL
index f7d8d6f777d1213d31d97d57f7276bd3787b9039..04ddba4f08acc9b0cb3a5ea3b659eb62003cbf5d 100644 (file)
@@ -55,6 +55,9 @@ bool(false)
 Warning: gmp_jacobi(): Unable to convert variable to GMP - wrong type in %s on line %d
 bool(false)
 
+Warning: gmp_jacobi(): Unable to convert variable to GMP - wrong type in %s on line %d
+bool(false)
+
 Warning: gmp_jacobi() expects exactly 2 parameters, 3 given in %s on line %d
 NULL
 
index ec8bb8c24cfeddc26b9db8bb1b3b36a3901eafd9..6dde34e1e7ef6d5bf700daae058671206fea216b 100644 (file)
@@ -55,6 +55,9 @@ bool(false)
 Warning: gmp_legendre(): Unable to convert variable to GMP - wrong type in %s on line %d
 bool(false)
 
+Warning: gmp_legendre(): Unable to convert variable to GMP - wrong type in %s on line %d
+bool(false)
+
 Warning: gmp_legendre() expects exactly 2 parameters, 3 given in %s on line %d
 NULL
 
index 3c7cce8ae5f701447f91b9ab4d6f3133b8f144f1..e09766c8e0befe4be952a35f1d137a40e0ca464f 100644 (file)
@@ -31,7 +31,7 @@ int(-1)
 int(0)
 int(1)
 int(-1)
-int(-2)
+int(-1)
 int(0)
 
 Warning: gmp_cmp() expects exactly 2 parameters, 3 given in %s on line %d