/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Wez Furlong <wez@thebrainroom.com> | +----------------------------------------------------------------------+ */ /* $Id$ */ /* Memory Mapping interface for streams */ #include "php.h" #include "php_streams_int.h" 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) { 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) { return php_stream_set_option(stream, PHP_STREAM_OPTION_MMAP_API, PHP_STREAM_MMAP_UNMAP, NULL) == PHP_STREAM_OPTION_RETURN_OK ? 1 : 0; } PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, off_t readden TSRMLS_DC) { 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; } /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
cast.c | File | 11.79 KB | 0644 |
|
filter.c | File | 16.15 KB | 0644 |
|
glob_wrapper.c | File | 6.54 KB | 0644 |
|
memory.c | File | 19.66 KB | 0644 |
|
mmap.c | File | 2.43 KB | 0644 |
|
php_stream_context.h | File | 5.83 KB | 0644 |
|
php_stream_filter_api.h | File | 7.04 KB | 0644 |
|
php_stream_glob_wrapper.h | File | 2.07 KB | 0644 |
|
php_stream_mmap.h | File | 3.43 KB | 0644 |
|
php_stream_plain_wrapper.h | File | 3.71 KB | 0644 |
|
php_stream_transport.h | File | 7.71 KB | 0644 |
|
php_streams_int.h | File | 2.96 KB | 0644 |
|
plain_wrapper.c | File | 38.8 KB | 0644 |
|
streams.c | File | 64.41 KB | 0644 |
|
transports.c | File | 14 KB | 0644 |
|
userspace.c | File | 45.06 KB | 0644 |
|
xp_socket.c | File | 22.77 KB | 0644 |
|