Back to index

php5  5.3.10
Classes | Defines | Enumerations | Functions
php_stream_mmap.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  php_stream_mmap_range

Defines

#define PHP_STREAM_MMAP_ALL   0
#define php_stream_mmap_supported(stream)   (_php_stream_set_option((stream), PHP_STREAM_OPTION_MMAP_API, PHP_STREAM_MMAP_SUPPORTED, NULL TSRMLS_CC) == 0 ? 1 : 0)
#define php_stream_mmap_possible(stream)   (!php_stream_is_filtered((stream)) && php_stream_mmap_supported((stream)))
#define php_stream_mmap_range(stream, offset, length, mode, mapped_len)   _php_stream_mmap_range((stream), (offset), (length), (mode), (mapped_len) TSRMLS_CC)
#define php_stream_mmap_unmap(stream)   _php_stream_mmap_unmap((stream) TSRMLS_CC)
#define php_stream_mmap_unmap_ex(stream, readden)   _php_stream_mmap_unmap_ex((stream), (readden) TSRMLS_CC)

Enumerations

enum  php_stream_mmap_operation_t { PHP_STREAM_MMAP_SUPPORTED, PHP_STREAM_MMAP_MAP_RANGE, PHP_STREAM_MMAP_UNMAP }
enum  php_stream_mmap_access_t { PHP_STREAM_MAP_MODE_READONLY, PHP_STREAM_MAP_MODE_READWRITE, PHP_STREAM_MAP_MODE_SHARED_READONLY, PHP_STREAM_MAP_MODE_SHARED_READWRITE }

Functions

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)
PHPAPI int _php_stream_mmap_unmap (php_stream *stream TSRMLS_DC)
PHPAPI int _php_stream_mmap_unmap_ex (php_stream *stream, off_t readden TSRMLS_DC)

Class Documentation

struct php_stream_mmap_range

Definition at line 48 of file php_stream_mmap.h.

Class Members
size_t length
char * mapped
php_stream_mmap_access_t mode
size_t offset

Define Documentation

#define PHP_STREAM_MMAP_ALL   0

Definition at line 61 of file php_stream_mmap.h.

Definition at line 67 of file php_stream_mmap.h.

#define php_stream_mmap_range (   stream,
  offset,
  length,
  mode,
  mapped_len 
)    _php_stream_mmap_range((stream), (offset), (length), (mode), (mapped_len) TSRMLS_CC)

Definition at line 71 of file php_stream_mmap.h.

Definition at line 63 of file php_stream_mmap.h.

Definition at line 75 of file php_stream_mmap.h.

#define php_stream_mmap_unmap_ex (   stream,
  readden 
)    _php_stream_mmap_unmap_ex((stream), (readden) TSRMLS_CC)

Definition at line 78 of file php_stream_mmap.h.


Enumeration Type Documentation

Enumerator:
PHP_STREAM_MAP_MODE_READONLY 
PHP_STREAM_MAP_MODE_READWRITE 
PHP_STREAM_MAP_MODE_SHARED_READONLY 
PHP_STREAM_MAP_MODE_SHARED_READWRITE 

Definition at line 41 of file php_stream_mmap.h.

Enumerator:
PHP_STREAM_MMAP_SUPPORTED 
PHP_STREAM_MMAP_MAP_RANGE 
PHP_STREAM_MMAP_UNMAP 

Definition at line 30 of file php_stream_mmap.h.

             {
       /* Does the stream support mmap ? */
       PHP_STREAM_MMAP_SUPPORTED,
       /* Request a range and offset to be mapped;
        * while mapped, you MUST NOT use any read/write functions
        * on the stream (win9x compatibility) */
       PHP_STREAM_MMAP_MAP_RANGE,
       /* Unmap the last range that was mapped for the stream */
       PHP_STREAM_MMAP_UNMAP
} php_stream_mmap_operation_t;

Function Documentation

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 
)

Definition at line 25 of file mmap.c.

{
       php_stream_mmap_range range;
       
       range.offset = offset;
       range.length = length;
       range.mode = mode;
       range.mapped = NULL;

       /* For now, we impose an arbitrary limit to avoid
        * runaway swapping when large files are passed thru. */
       if (length > 4 * 1024 * 1024) {
              return NULL;
       }
       
       if (PHP_STREAM_OPTION_RETURN_OK == php_stream_set_option(stream, PHP_STREAM_OPTION_MMAP_API, PHP_STREAM_MMAP_MAP_RANGE, &range)) {
              if (mapped_len) {
                     *mapped_len = range.length;
              }
              return range.mapped;
       }
       return NULL;
}
PHPAPI int _php_stream_mmap_unmap ( php_stream *stream  TSRMLS_DC)
PHPAPI int _php_stream_mmap_unmap_ex ( php_stream *  stream,
off_t readden  TSRMLS_DC 
)

Definition at line 54 of file mmap.c.

{
       int ret = 1;

       if (php_stream_seek(stream, readden, SEEK_CUR) != 0) {
              ret = 0;
       }
       if (php_stream_mmap_unmap(stream) == 0) {
              ret = 0;
       }

       return ret;
}