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

LTP GCOV extension - code coverage report
Current view: directory - var/php_gcov/PHP_HEAD/main/streams - mmap.c
Test: PHP Code Coverage
Date: 2009-11-23 Instrumented lines: 21
Code covered: 85.7 % Executed lines: 18
Legend: not executed executed

       1                 : /*
       2                 :   +----------------------------------------------------------------------+
       3                 :   | PHP Version 6                                                        |
       4                 :   +----------------------------------------------------------------------+
       5                 :   | Copyright (c) 1997-2009 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                 :   | Author: Wez Furlong <wez@thebrainroom.com>                           |
      16                 :   +----------------------------------------------------------------------+
      17                 : */
      18                 : 
      19                 : /* $Id: mmap.c 280677 2009-05-17 14:57:05Z lbarnaud $ */
      20                 : 
      21                 : /* Memory Mapping interface for streams */
      22                 : #include "php.h"
      23                 : #include "php_streams_int.h"
      24                 : 
      25                 : PHPAPI char *_php_stream_mmap_range(php_stream *stream, size_t offset, size_t length, php_stream_mmap_operation_t mode, size_t *mapped_len TSRMLS_DC)
      26           26171 : {
      27                 :         php_stream_mmap_range range;
      28                 :         
      29           26171 :         range.offset = offset;
      30           26171 :         range.length = length;
      31           26171 :         range.mode = mode;
      32           26171 :         range.mapped = NULL;
      33                 : 
      34                 :         /* For now, we impose an arbitrary limit to avoid
      35                 :          * runaway swapping when large files are passed thru. */
      36           26171 :         if (length > 4 * 1024 * 1024) {
      37               0 :                 return NULL;
      38                 :         }
      39                 :         
      40           26171 :         if (PHP_STREAM_OPTION_RETURN_OK == php_stream_set_option(stream, PHP_STREAM_OPTION_MMAP_API, PHP_STREAM_MMAP_MAP_RANGE, &range)) {
      41           21526 :                 if (mapped_len) {
      42           21526 :                         *mapped_len = range.length;
      43                 :                 }
      44           21526 :                 return range.mapped;
      45                 :         }
      46            4645 :         return NULL;
      47                 : }
      48                 : 
      49                 : PHPAPI int _php_stream_mmap_unmap(php_stream *stream TSRMLS_DC)
      50           21526 : {
      51           21526 :         return php_stream_set_option(stream, PHP_STREAM_OPTION_MMAP_API, PHP_STREAM_MMAP_UNMAP, NULL) == PHP_STREAM_OPTION_RETURN_OK ? 1 : 0;
      52                 : }
      53                 : 
      54                 : PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, off_t readden TSRMLS_DC)
      55           14276 : {
      56           14276 :         int ret = 1;
      57                 : 
      58           14276 :         if (php_stream_seek(stream, readden, SEEK_CUR) != 0) {
      59               0 :                 ret = 0;
      60                 :         }
      61           14276 :         if (php_stream_mmap_unmap(stream) == 0) {
      62               0 :                 ret = 0;
      63                 :         }
      64                 : 
      65           14276 :         return ret;
      66                 : }
      67                 : 
      68                 : /*
      69                 :  * Local variables:
      70                 :  * tab-width: 4
      71                 :  * c-basic-offset: 4
      72                 :  * End:
      73                 :  * vim600: noet sw=4 ts=4 fdm=marker
      74                 :  * vim<600: noet sw=4 ts=4
      75                 :  */

Generated by: LTP GCOV extension version 1.5

Generated at Mon, 23 Nov 2009 17:39:47 +0000 (33 hours ago)

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