php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
php_stream_mmap.h
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Author: Wez Furlong <wez@thebrainroom.com> |
14 +----------------------------------------------------------------------+
15*/
16
17/* Memory Mapping interface for streams.
18 * The intention is to provide a uniform interface over the most common
19 * operations that are used within PHP itself, rather than a complete
20 * API for all memory mapping needs.
21 *
22 * ATM, we support only mmap(), but win32 memory mapping support will
23 * follow soon.
24 * */
25
26typedef enum {
27 /* Does the stream support mmap ? */
29 /* Request a range and offset to be mapped;
30 * while mapped, you MUST NOT use any read/write functions
31 * on the stream (win9x compatibility) */
33 /* Unmap the last range that was mapped for the stream */
36
43
44typedef struct {
45 /* requested offset and length.
46 * If length is 0, the whole file is mapped */
47 size_t offset;
48 size_t length;
49
51
52 /* returned mapped address */
53 char *mapped;
54
56
57#define PHP_STREAM_MMAP_ALL 0
58
59#define PHP_STREAM_MMAP_MAX (512 * 1024 * 1024)
60
61#define php_stream_mmap_supported(stream) (_php_stream_set_option((stream), PHP_STREAM_OPTION_MMAP_API, PHP_STREAM_MMAP_SUPPORTED, NULL) == 0 ? 1 : 0)
62
63/* Returns 1 if the stream in its current state can be memory mapped,
64 * 0 otherwise */
65#define php_stream_mmap_possible(stream) (!php_stream_is_filtered((stream)) && php_stream_mmap_supported((stream)))
66
68PHPAPI char *_php_stream_mmap_range(php_stream *stream, size_t offset, size_t length, php_stream_mmap_access_t mode, size_t *mapped_len);
69#define php_stream_mmap_range(stream, offset, length, mode, mapped_len) _php_stream_mmap_range((stream), (offset), (length), (mode), (mapped_len))
70
71/* un-maps the last mapped range */
73#define php_stream_mmap_unmap(stream) _php_stream_mmap_unmap((stream))
74
76#define php_stream_mmap_unmap_ex(stream, readden) _php_stream_mmap_unmap_ex((stream), (readden))
zend_long offset
char * mode
PHPAPI char * _php_stream_mmap_range(php_stream *stream, size_t offset, size_t length, php_stream_mmap_access_t mode, size_t *mapped_len)
Definition mmap.c:21
#define PHPAPI
Definition php.h:71
PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, zend_off_t readden)
Definition mmap.c:44
php_stream_mmap_access_t
@ PHP_STREAM_MAP_MODE_READWRITE
@ PHP_STREAM_MAP_MODE_READONLY
@ PHP_STREAM_MAP_MODE_SHARED_READONLY
@ PHP_STREAM_MAP_MODE_SHARED_READWRITE
#define php_stream_mmap_range(stream, offset, length, mode, mapped_len)
php_stream_mmap_operation_t
@ PHP_STREAM_MMAP_UNMAP
@ PHP_STREAM_MMAP_SUPPORTED
@ PHP_STREAM_MMAP_MAP_RANGE
PHPAPI int _php_stream_mmap_unmap(php_stream *stream)
Definition mmap.c:39
struct _php_stream php_stream
Definition php_streams.h:96
php_stream_mmap_access_t mode
int32_t zend_off_t
Definition zend_long.h:44
#define END_EXTERN_C()
#define BEGIN_EXTERN_C()