~ubuntu-branches/ubuntu/vivid/php-apcu/vivid

« back to all changes in this revision

Viewing changes to apcu-4.0.6/apc_pool_api.h

  • Committer: Package Import Robot
  • Author(s): Ondřej Surý
  • Date: 2014-06-24 10:52:52 UTC
  • mfrom: (7.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20140624105252-vsqs1r4og4ykucqg
Tags: 4.0.6-1
* New upstream version 4.0.6
* Remove PHP 5.6 support patch - merged upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  +----------------------------------------------------------------------+
 
3
  | APC                                                                  |
 
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
  +----------------------------------------------------------------------+
 
17
 
 
18
   This software was contributed to PHP by Yahoo! Inc. in 2008.
 
19
 
 
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.
 
23
 
 
24
   All other licensing and usage conditions are those of the PHP Group.
 
25
 
 
26
 */
 
27
 
 
28
/* $Id: apc_pool.h 307048 2011-01-03 23:53:17Z kalle $ */
 
29
 
 
30
#ifndef APC_POOL_API_H
 
31
#define APC_POOL_API_H
 
32
 
 
33
#if APC_POOL_DEBUG
 
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)
 
36
#else
 
37
/* let gcc optimize away the optional features */
 
38
#define APC_POOL_HAS_SIZEINFO(pool) (0)
 
39
#define APC_POOL_HAS_REDZONES(pool) (0)
 
40
#endif
 
41
 
 
42
/* {{{ */
 
43
typedef struct _apc_pool apc_pool; /* }}} */
 
44
 
 
45
/* {{{ functions */
 
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); /* }}} */
 
51
 
 
52
/* {{{ enum definition: apc_pool_type */
 
53
typedef enum {
 
54
    APC_UNPOOL         = 0x0,
 
55
    APC_SMALL_POOL     = 0x1,
 
56
    APC_MEDIUM_POOL    = 0x2,
 
57
    APC_LARGE_POOL     = 0x3,
 
58
    APC_POOL_SIZE_MASK = 0x7,   /* waste a bit */
 
59
#if APC_POOL_DEBUG
 
60
    APC_POOL_REDZONES  = 0x08,
 
61
    APC_POOL_SIZEINFO  = 0x10,
 
62
    APC_POOL_OPT_MASK  = 0x18
 
63
#endif
 
64
} apc_pool_type; /* }}} */
 
65
 
 
66
/* {{{ structure definition: apc_pool */ 
 
67
struct _apc_pool {
 
68
        /* denotes the size and debug flags for a pool */
 
69
    apc_pool_type   type;
 
70
        
 
71
        /* handler functions */
 
72
    apc_malloc_t    allocate;
 
73
    apc_free_t      deallocate;
 
74
 
 
75
    apc_palloc_t    palloc;
 
76
    apc_pfree_t     pfree;
 
77
 
 
78
        apc_protect_t   protect;
 
79
        apc_unprotect_t unprotect;
 
80
 
 
81
    apc_pcleanup_t  cleanup;
 
82
 
 
83
        /* total */
 
84
    size_t          size;
 
85
        /* remaining */
 
86
    size_t          used;
 
87
 
 
88
    /* apc_realpool and apc_unpool add more here */
 
89
}; /* }}} */
 
90
 
 
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 {
 
95
    APC_NO_COPY = 0,
 
96
    APC_COPY_IN,
 
97
    APC_COPY_OUT,
 
98
        APC_COPY_OTHER
 
99
} apc_copy_type; /* }}} */
 
100
 
 
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,
 
106
    APC_CONTEXT_SHARE,
 
107
        APC_CONTEXT_NOSHARE
 
108
} apc_context_type; /* }}} */
 
109
 
 
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; /* }}} */
 
119
 
 
120
/*
 
121
 apc_pool_create creates a pool of the specified type, setting the handlers passed on the pool, returns apc_pool*
 
122
*/
 
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);
 
128
 
 
129
/*
 
130
 apc_pool_destroy first calls apc_cleanup_t set during apc_pool_create, then apc_free_t
 
131
*/
 
132
PHP_APCU_API void apc_pool_destroy(apc_pool* pool TSRMLS_DC);
 
133
 
 
134
/*
 
135
 apc_pmemcpy performs memcpy using resources provided by pool
 
136
*/
 
137
PHP_APCU_API void* apc_pmemcpy(const void* p, 
 
138
                               size_t n, 
 
139
                               apc_pool* pool TSRMLS_DC);
 
140
 
 
141
/*
 
142
 apc_pstrdup performs strdup using resources provided by pool
 
143
*/
 
144
PHP_APCU_API void* apc_pstrdup(const char* s, 
 
145
                               apc_pool* pool TSRMLS_DC);
 
146
 
 
147
#endif
 
148