PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - ext/standard - rand.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 10 14 71.4 %
Date: 2016-09-27 Functions: 2 3 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | PHP Version 7                                                        |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1997-2016 The PHP Group                                |
       6             :    +----------------------------------------------------------------------+
       7             :    | This source file is subject to version 3.01 of the PHP license,      |
       8             :    | that is bundled with this package in the file LICENSE, and is        |
       9             :    | available through the world-wide-web at the following url:           |
      10             :    | http://www.php.net/license/3_01.txt                                  |
      11             :    | If you did not receive a copy of the PHP license and are unable to   |
      12             :    | obtain it through the world-wide-web, please send a note to          |
      13             :    | license@php.net so we can mail you a copy immediately.               |
      14             :    +----------------------------------------------------------------------+
      15             :    | Authors: Rasmus Lerdorf <rasmus@php.net>                             |
      16             :    |          Zeev Suraski <zeev@zend.com>                                |
      17             :    |          Pedro Melo <melo@ip.pt>                                     |
      18             :    |          Sterling Hughes <sterling@php.net>                          |
      19             :    |                                                                      |
      20             :    | Based on code from: Richard J. Wagner <rjwagner@writeme.com>         |
      21             :    |                     Makoto Matsumoto <matumoto@math.keio.ac.jp>      |
      22             :    |                     Takuji Nishimura                                 |
      23             :    |                     Shawn Cokus <Cokus@math.washington.edu>          |
      24             :    +----------------------------------------------------------------------+
      25             :  */
      26             : /* $Id$ */
      27             : 
      28             : #include "php.h"
      29             : #include "php_rand.h"
      30             : #include "php_mt_rand.h"
      31             : 
      32             : /* {{{ php_srand
      33             :  */
      34           0 : PHPAPI void php_srand(zend_long seed)
      35             : {
      36           0 :         php_mt_srand(seed);
      37           0 : }
      38             : /* }}} */
      39             : 
      40             : /* {{{ php_rand
      41             :  */
      42      273194 : PHPAPI zend_long php_rand(void)
      43             : {
      44      273194 :         return php_mt_rand();
      45             : }
      46             : /* }}} */
      47             : 
      48             : /* {{{ proto int mt_rand([int min, int max])
      49             :    Returns a random number from Mersenne Twister */
      50      313306 : PHP_FUNCTION(rand)
      51             : {
      52             :         zend_long min;
      53             :         zend_long max;
      54      313306 :         int argc = ZEND_NUM_ARGS();
      55             : 
      56      313306 :         if (argc == 0) {
      57      195914 :                 RETURN_LONG(php_mt_rand() >> 1);
      58             :         }
      59             : 
      60      117392 :         if (zend_parse_parameters(argc, "ll", &min, &max) == FAILURE) {
      61           5 :                 return;
      62             :         }
      63             : 
      64      117387 :         if (max < min) {
      65           0 :                 RETURN_LONG(php_mt_rand_common(max, min));
      66             :         }
      67             : 
      68      117387 :         RETURN_LONG(php_mt_rand_common(min, max));
      69             : }
      70             : /* }}} */
      71             : 
      72             : /*
      73             :  * Local variables:
      74             :  * tab-width: 4
      75             :  * c-basic-offset: 4
      76             :  * End:
      77             :  * vim600: noet sw=4 ts=4 fdm=marker
      78             :  * vim<600: noet sw=4 ts=4
      79             :  */

Generated by: LCOV version 1.10

Generated at Tue, 27 Sep 2016 10:26:08 +0000 (3 days ago)

Copyright © 2005-2016 The PHP Group
All rights reserved.