Annotation of embedaddon/php/main/streams/php_stream_mmap.h, revision 1.1.1.4
1.1 misho 1: /*
2: +----------------------------------------------------------------------+
3: | PHP Version 5 |
4: +----------------------------------------------------------------------+
1.1.1.4 ! misho 5: | Copyright (c) 1997-2014 The PHP Group |
1.1 misho 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:
1.1.1.2 misho 19: /* $Id$ */
1.1 misho 20:
21: /* Memory Mapping interface for streams.
22: * The intention is to provide a uniform interface over the most common
23: * operations that are used within PHP itself, rather than a complete
24: * API for all memory mapping needs.
25: *
26: * ATM, we support only mmap(), but win32 memory mapping support will
27: * follow soon.
28: * */
29:
30: typedef enum {
31: /* Does the stream support mmap ? */
32: PHP_STREAM_MMAP_SUPPORTED,
33: /* Request a range and offset to be mapped;
34: * while mapped, you MUST NOT use any read/write functions
35: * on the stream (win9x compatibility) */
36: PHP_STREAM_MMAP_MAP_RANGE,
37: /* Unmap the last range that was mapped for the stream */
38: PHP_STREAM_MMAP_UNMAP
39: } php_stream_mmap_operation_t;
40:
41: typedef enum {
42: PHP_STREAM_MAP_MODE_READONLY,
43: PHP_STREAM_MAP_MODE_READWRITE,
44: PHP_STREAM_MAP_MODE_SHARED_READONLY,
45: PHP_STREAM_MAP_MODE_SHARED_READWRITE
46: } php_stream_mmap_access_t;
47:
48: typedef struct {
49: /* requested offset and length.
50: * If length is 0, the whole file is mapped */
51: size_t offset;
52: size_t length;
53:
54: php_stream_mmap_access_t mode;
55:
56: /* returned mapped address */
57: char *mapped;
58:
59: } php_stream_mmap_range;
60:
61: #define PHP_STREAM_MMAP_ALL 0
62:
63: #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)
64:
65: /* Returns 1 if the stream in its current state can be memory mapped,
66: * 0 otherwise */
67: #define php_stream_mmap_possible(stream) (!php_stream_is_filtered((stream)) && php_stream_mmap_supported((stream)))
68:
69: BEGIN_EXTERN_C()
70: 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);
71: #define php_stream_mmap_range(stream, offset, length, mode, mapped_len) _php_stream_mmap_range((stream), (offset), (length), (mode), (mapped_len) TSRMLS_CC)
72:
73: /* un-maps the last mapped range */
74: PHPAPI int _php_stream_mmap_unmap(php_stream *stream TSRMLS_DC);
75: #define php_stream_mmap_unmap(stream) _php_stream_mmap_unmap((stream) TSRMLS_CC)
76:
77: PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, off_t readden TSRMLS_DC);
78: #define php_stream_mmap_unmap_ex(stream, readden) _php_stream_mmap_unmap_ex((stream), (readden) TSRMLS_CC)
79: END_EXTERN_C()
80:
81: /*
82: * Local variables:
83: * tab-width: 4
84: * c-basic-offset: 4
85: * End:
86: * vim600: noet sw=4 ts=4 fdm=marker
87: * vim<600: noet sw=4 ts=4
88: */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>