New PHP5 APC - version 3.0.19, using PHP5 5.2.0-8+etch11,
[php5-apc.git] / apc_compile.h
1 /*
2   +----------------------------------------------------------------------+
3   | APC                                                                  |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 2008 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: Daniel Cowgill <dcowgill@communityconnect.com>              |
16   |          Arun C. Murthy <arunc@yahoo-inc.com>                        |
17   |          Gopal Vijayaraghavan <gopalv@yahoo-inc.com>                 |
18   +----------------------------------------------------------------------+
19
20    This software was contributed to PHP by Community Connect Inc. in 2002
21    and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1.
22    Future revisions and derivatives of this source code must acknowledge
23    Community Connect Inc. as the original contributor of this module by
24    leaving this note intact in the source code.
25
26    All other licensing and usage conditions are those of the PHP Group.
27
28  */
29
30 /* $Id: apc_compile.h,v 3.19.2.1 2008/05/11 18:57:00 rasmus Exp $ */
31
32 #ifndef APC_COMPILE_H
33 #define APC_COMPILE_H
34
35 /*
36  * This module encapsulates most of the complexity involved in deep-copying
37  * the Zend compiler data structures. The routines are allocator-agnostic, so
38  * the same function can be used for copying to and from shared memory.
39  */
40
41 #include "apc.h"
42 #include "apc_php.h"
43
44 /* {{{ struct definition: apc_function_t */
45 typedef struct apc_function_t apc_function_t;
46 struct apc_function_t {
47     char* name;                 /* the function name */
48     int name_len;               /* length of name */
49     zend_function* function;    /* the zend function data structure */
50 };
51 /* }}} */
52
53 /* {{{ struct definition: apc_class_t */
54 typedef struct apc_class_t apc_class_t;
55 struct apc_class_t {
56     char* name;                     /* the class name */
57     int name_len;                   /* length of name */
58     int is_derived;                 /* true if this is a derived class */
59     char* parent_name;              /* the parent class name */
60     zend_class_entry* class_entry;  /* the zend class data structure */
61 };
62 /* }}} */
63
64 /* {{{ struct definition: apc_opflags_t */
65 typedef struct apc_opflags_t apc_opflags_t;
66 struct apc_opflags_t {
67     unsigned int has_jumps      : 1; /* has jump offsets */
68     unsigned int deep_copy      : 1; /* needs deep copy */
69
70     /* autoglobal bits */
71     unsigned int _POST          : 1;
72     unsigned int _GET           : 1;
73     unsigned int _COOKIE        : 1;
74     unsigned int _SERVER        : 1;
75     unsigned int _ENV           : 1;
76     unsigned int _FILES         : 1;
77     unsigned int _REQUEST       : 1;
78     unsigned int unknown_global : 1;
79 };
80 /* }}} */
81
82 /*
83  * These are the top-level copy functions.
84  */
85
86 extern zend_op_array* apc_copy_op_array(zend_op_array* dst, zend_op_array* src, apc_malloc_t allocate, apc_free_t deallocate TSRMLS_DC);
87 extern zend_class_entry* apc_copy_class_entry(zend_class_entry* dst, zend_class_entry* src, apc_malloc_t allocate, apc_free_t deallocate);
88 extern apc_function_t* apc_copy_new_functions(int old_count, apc_malloc_t allocate, apc_free_t deallocate TSRMLS_DC);
89 extern apc_class_t* apc_copy_new_classes(zend_op_array* op_array, int old_count, apc_malloc_t allocate, apc_free_t deallocate TSRMLS_DC);
90 extern zval* apc_copy_zval(zval* dst, const zval* src, apc_malloc_t allocate, apc_free_t deallocate);
91
92 /*
93  * Deallocation functions corresponding to the copy functions above.
94  */
95
96 extern void apc_free_op_array(zend_op_array* src, apc_free_t deallocate);
97 extern void apc_free_functions(apc_function_t* src, apc_free_t deallocate);
98 extern void apc_free_classes(apc_class_t* src, apc_free_t deallocate);
99 extern void apc_free_zval(zval* src, apc_free_t deallocate);
100
101 /*
102  * These "copy-for-execution" functions must be called after retrieving an
103  * object from the shared cache. They do the minimal amount of work necessary
104  * to allow multiple processes to concurrently execute the same VM data
105  * structures.
106  */
107
108 extern zend_op_array* apc_copy_op_array_for_execution(zend_op_array* dst, zend_op_array* src TSRMLS_DC);
109 extern zend_function* apc_copy_function_for_execution(zend_function* src);
110 extern zend_class_entry* apc_copy_class_entry_for_execution(zend_class_entry* src, int is_derived);
111
112 /*
113  * The "free-after-execution" function performs a cursory clean up of the class data
114  * This is required to minimize memory leak warnings and to ensure correct destructor
115  * ordering of some variables.
116  */
117 extern void apc_free_class_entry_after_execution(zend_class_entry* src);
118
119 /*
120  * Optimization callback definition and registration function. 
121  */
122 typedef zend_op_array* (*apc_optimize_function_t) (zend_op_array* TSRMLS_DC);
123 extern apc_optimize_function_t apc_register_optimizer(apc_optimize_function_t optimizer TSRMLS_DC);
124
125 #endif
126
127 /*
128  * Local variables:
129  * tab-width: 4
130  * c-basic-offset: 4
131  * End:
132  * vim600: expandtab sw=4 ts=4 sts=4 fdm=marker
133  * vim<600: expandtab sw=4 ts=4 sts=4
134  */