2
+----------------------------------------------------------------------+
4
+----------------------------------------------------------------------+
5
| Copyright (c) 2006-2011 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
| Authors: Gopal Vijayaraghavan <gopalv@yahoo-inc.com> |
16
+----------------------------------------------------------------------+
18
This software was contributed to PHP by Yahoo! Inc. in 2008.
20
Future revisions and derivatives of this source code must acknowledge
21
Yahoo! Inc. as the original contributor of this module by
22
leaving this note intact in the source code.
24
All other licensing and usage conditions are those of the PHP Group.
28
/* $Id: apc_pool.h 307048 2011-01-03 23:53:17Z kalle $ */
30
#ifndef APC_POOL_API_H
31
#define APC_POOL_API_H
34
#define APC_POOL_HAS_SIZEINFO(pool) ((pool->type & APC_POOL_SIZEINFO)!=0)
35
#define APC_POOL_HAS_REDZONES(pool) ((pool->type & APC_POOL_REDZONES)!=0)
37
/* let gcc optimize away the optional features */
38
#define APC_POOL_HAS_SIZEINFO(pool) (0)
39
#define APC_POOL_HAS_REDZONES(pool) (0)
43
typedef struct _apc_pool apc_pool; /* }}} */
46
typedef void (*apc_pcleanup_t)(apc_pool *pool TSRMLS_DC);
47
typedef void* (*apc_palloc_t)(apc_pool *pool, size_t size TSRMLS_DC);
48
typedef void (*apc_pfree_t) (apc_pool *pool, void* p TSRMLS_DC);
49
typedef void* (*apc_protect_t) (void *p);
50
typedef void* (*apc_unprotect_t)(void *p); /* }}} */
52
/* {{{ enum definition: apc_pool_type */
56
APC_MEDIUM_POOL = 0x2,
58
APC_POOL_SIZE_MASK = 0x7, /* waste a bit */
60
APC_POOL_REDZONES = 0x08,
61
APC_POOL_SIZEINFO = 0x10,
62
APC_POOL_OPT_MASK = 0x18
64
} apc_pool_type; /* }}} */
66
/* {{{ structure definition: apc_pool */
68
/* denotes the size and debug flags for a pool */
71
/* handler functions */
72
apc_malloc_t allocate;
73
apc_free_t deallocate;
78
apc_protect_t protect;
79
apc_unprotect_t unprotect;
81
apc_pcleanup_t cleanup;
88
/* apc_realpool and apc_unpool add more here */
91
/* {{{ enum definition: apc_copy_type */
92
/* APC_COPY_IN should be used when copying into APC
93
APC_COPY_OUT should be used when copying out of APC */
94
typedef enum _apc_copy_type {
99
} apc_copy_type; /* }}} */
101
/* {{{ enum definition: apc_context_type
102
APC_CONTEXT_SHARE should be used to create contexts using shared memory
103
APC_CONTEXT_NOSHARE should be used to create contexts using standard allocators */
104
typedef enum _apc_context_type {
105
APC_CONTEXT_NONE = 0,
108
} apc_context_type; /* }}} */
110
/* {{{ struct definition: apc_context_t */
111
typedef struct _apc_context_t {
112
apc_pool* pool; /* pool of memory for context */
113
apc_copy_type copy; /* copying type for context */
114
unsigned int force_update:1; /* flag to force updates */
115
HashTable copied; /* copied zvals for recursion support */
116
apc_serializer_t* serializer; /* serializer */
117
void* key; /* set before serializer API is invoked */
118
} apc_context_t; /* }}} */
121
apc_pool_create creates a pool of the specified type, setting the handlers passed on the pool, returns apc_pool*
123
PHP_APCU_API apc_pool* apc_pool_create(apc_pool_type pool_type,
124
apc_malloc_t allocate,
125
apc_free_t deallocate,
126
apc_protect_t protect,
127
apc_unprotect_t unprotect TSRMLS_DC);
130
apc_pool_destroy first calls apc_cleanup_t set during apc_pool_create, then apc_free_t
132
PHP_APCU_API void apc_pool_destroy(apc_pool* pool TSRMLS_DC);
135
apc_pmemcpy performs memcpy using resources provided by pool
137
PHP_APCU_API void* apc_pmemcpy(const void* p,
139
apc_pool* pool TSRMLS_DC);
142
apc_pstrdup performs strdup using resources provided by pool
144
PHP_APCU_API void* apc_pstrdup(const char* s,
145
apc_pool* pool TSRMLS_DC);