stas            Thu Nov  1 17:51:34 2007 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/gmp    gmp.c 
  Log:
  merge gmp_testbit()
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/gmp/gmp.c?r1=1.49.2.2.2.11.2.4&r2=1.49.2.2.2.11.2.5&diff_format=u
Index: php-src/ext/gmp/gmp.c
diff -u php-src/ext/gmp/gmp.c:1.49.2.2.2.11.2.4 
php-src/ext/gmp/gmp.c:1.49.2.2.2.11.2.5
--- php-src/ext/gmp/gmp.c:1.49.2.2.2.11.2.4     Thu Nov  1 09:34:18 2007
+++ php-src/ext/gmp/gmp.c       Thu Nov  1 17:51:34 2007
@@ -238,6 +238,12 @@
 ZEND_END_ARG_INFO()
 
 static
+ZEND_BEGIN_ARG_INFO(arginfo_gmp_testbit, 0)
+       ZEND_ARG_INFO(0, a)
+       ZEND_ARG_INFO(0, index)
+ZEND_END_ARG_INFO()
+
+static
 ZEND_BEGIN_ARG_INFO(arginfo_gmp_popcount, 0)
        ZEND_ARG_INFO(0, a)
 ZEND_END_ARG_INFO()
@@ -308,8 +314,9 @@
        ZEND_FE(gmp_xor,        arginfo_gmp_xor)
        ZEND_FE(gmp_setbit,     arginfo_gmp_setbit)
        ZEND_FE(gmp_clrbit,     arginfo_gmp_clrbit)
-       ZEND_FE(gmp_scan0, arginfo_gmp_scan0)
-       ZEND_FE(gmp_scan1, arginfo_gmp_scan1)
+       ZEND_FE(gmp_scan0,  arginfo_gmp_scan0)
+       ZEND_FE(gmp_scan1,  arginfo_gmp_scan1)
+       ZEND_FE(gmp_testbit,arginfo_gmp_testbit)
        ZEND_FE(gmp_popcount, arginfo_gmp_popcount)
        ZEND_FE(gmp_hamdist, arginfo_gmp_hamdist)
        ZEND_FE(gmp_nextprime, arginfo_gmp_nextprime)
@@ -1511,6 +1518,32 @@
 }
 /* }}} */
 
+/* {{{ proto bool gmp_testbit(resource a, int index)
+   Tests if bit is set in a */
+ZEND_FUNCTION(gmp_testbit)
+{
+       zval **a_arg;
+       int index;
+       mpz_t *gmpnum_a;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zl", &a_arg, 
&index) == FAILURE){
+               return;
+       }
+
+       ZEND_FETCH_RESOURCE(gmpnum_a, mpz_t *, a_arg, -1, GMP_RESOURCE_NAME, 
le_gmp);
+
+       if (index < 0) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Index must be 
greater than or equal to zero");
+               RETURN_FALSE;
+       }
+
+       if (mpz_tstbit(*gmpnum_a, index)) {
+               RETURN_TRUE;
+       }
+       RETURN_FALSE;
+}
+/* }}} */
+
 /* {{{ proto int gmp_popcount(resource a)
    Calculates the population count of a */
 ZEND_FUNCTION(gmp_popcount)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to