- Notifications
You must be signed in to change notification settings - Fork 7.8k
/
Copy pathzend.h
456 lines (380 loc) · 17.3 KB
/
zend.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@php.net> |
| Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
#ifndefZEND_H
#defineZEND_H
#defineZEND_VERSION "4.4.3-dev"
#defineZEND_ENGINE_3
#include"zend_types.h"
#include"zend_map_ptr.h"
#include"zend_errors.h"
#include"zend_alloc.h"
#include"zend_llist.h"
#include"zend_string.h"
#include"zend_hash.h"
#include"zend_ast.h"
#include"zend_gc.h"
#include"zend_variables.h"
#include"zend_iterators.h"
#include"zend_stream.h"
#include"zend_smart_str_public.h"
#include"zend_smart_string_public.h"
#include"zend_signal.h"
#include"zend_max_execution_timer.h"
#definezend_sprintf sprintf
#defineHANDLE_BLOCK_INTERRUPTIONS() ZEND_SIGNAL_BLOCK_INTERRUPTIONS()
#defineHANDLE_UNBLOCK_INTERRUPTIONS() ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS()
#defineINTERNAL_FUNCTION_PARAMETERS zend_execute_data *execute_data, zval *return_value
#defineINTERNAL_FUNCTION_PARAM_PASSTHRU execute_data, return_value
#defineUSED_RET() \
(!EX(prev_execute_data) || \
!ZEND_USER_CODE(EX(prev_execute_data)->func->common.type) || \
(EX(prev_execute_data)->opline->result_type != IS_UNUSED))
#ifdefZEND_ENABLE_STATIC_TSRMLS_CACHE
#defineZEND_TSRMG TSRMG_STATIC
#defineZEND_TSRMG_FAST TSRMG_FAST_STATIC
#defineZEND_TSRMLS_CACHE_EXTERN() TSRMLS_CACHE_EXTERN()
#defineZEND_TSRMLS_CACHE_DEFINE() TSRMLS_CACHE_DEFINE()
#defineZEND_TSRMLS_CACHE_UPDATE() TSRMLS_CACHE_UPDATE()
#defineZEND_TSRMLS_CACHE TSRMLS_CACHE
#else
#defineZEND_TSRMG TSRMG
#defineZEND_TSRMG_FAST TSRMG_FAST
#defineZEND_TSRMLS_CACHE_EXTERN()
#defineZEND_TSRMLS_CACHE_DEFINE()
#defineZEND_TSRMLS_CACHE_UPDATE()
#defineZEND_TSRMLS_CACHE
#endif
#ifndefZEND_COMPILE_DL_EXT
TSRMLS_MAIN_CACHE_EXTERN()
#else
ZEND_TSRMLS_CACHE_EXTERN()
#endif
struct_zend_serialize_data;
struct_zend_unserialize_data;
typedefstruct_zend_serialize_datazend_serialize_data;
typedefstruct_zend_unserialize_datazend_unserialize_data;
typedefstruct_zend_class_name {
zend_string*name;
zend_string*lc_name;
} zend_class_name;
typedefstruct_zend_trait_method_reference {
zend_string*method_name;
zend_string*class_name;
} zend_trait_method_reference;
typedefstruct_zend_trait_precedence {
zend_trait_method_referencetrait_method;
uint32_tnum_excludes;
zend_string*exclude_class_names[1];
} zend_trait_precedence;
typedefstruct_zend_trait_alias {
zend_trait_method_referencetrait_method;
/**
* name for method to be added
*/
zend_string*alias;
/**
* modifiers to be set on trait method
*/
uint32_tmodifiers;
} zend_trait_alias;
typedefstruct_zend_class_mutable_data {
zval*default_properties_table;
HashTable*constants_table;
uint32_tce_flags;
HashTable*backed_enum_table;
} zend_class_mutable_data;
typedefstruct_zend_class_dependency {
zend_string*name;
zend_class_entry*ce;
} zend_class_dependency;
typedefstruct_zend_inheritance_cache_entryzend_inheritance_cache_entry;
typedefstruct_zend_error_info {
inttype;
uint32_tlineno;
zend_string*filename;
zend_string*message;
} zend_error_info;
struct_zend_inheritance_cache_entry {
zend_inheritance_cache_entry*next;
zend_class_entry*ce;
zend_class_entry*parent;
zend_class_dependency*dependencies;
uint32_tdependencies_count;
uint32_tnum_warnings;
zend_error_info**warnings;
zend_class_entry*traits_and_interfaces[1];
};
struct_zend_class_entry {
chartype;
zend_string*name;
/* class_entry or string depending on ZEND_ACC_LINKED */
union {
zend_class_entry*parent;
zend_string*parent_name;
};
intrefcount;
uint32_tce_flags;
intdefault_properties_count;
intdefault_static_members_count;
zval*default_properties_table;
zval*default_static_members_table;
ZEND_MAP_PTR_DEF(zval*, static_members_table);
HashTablefunction_table;
HashTableproperties_info;
HashTableconstants_table;
ZEND_MAP_PTR_DEF(zend_class_mutable_data*, mutable_data);
zend_inheritance_cache_entry*inheritance_cache;
struct_zend_property_info**properties_info_table;
zend_function*constructor;
zend_function*destructor;
zend_function*clone;
zend_function*__get;
zend_function*__set;
zend_function*__unset;
zend_function*__isset;
zend_function*__call;
zend_function*__callstatic;
zend_function*__tostring;
zend_function*__debugInfo;
zend_function*__serialize;
zend_function*__unserialize;
constzend_object_handlers*default_object_handlers;
/* allocated only if class implements Iterator or IteratorAggregate interface */
zend_class_iterator_funcs*iterator_funcs_ptr;
/* allocated only if class implements ArrayAccess interface */
zend_class_arrayaccess_funcs*arrayaccess_funcs_ptr;
/* handlers */
union {
zend_object* (*create_object)(zend_class_entry*class_type);
int (*interface_gets_implemented)(zend_class_entry*iface, zend_class_entry*class_type); /* a class implements this interface */
};
zend_object_iterator*(*get_iterator)(zend_class_entry*ce, zval*object, intby_ref);
zend_function*(*get_static_method)(zend_class_entry*ce, zend_string*method);
/* serializer callbacks */
int (*serialize)(zval*object, unsigned char**buffer, size_t*buf_len, zend_serialize_data*data);
int (*unserialize)(zval*object, zend_class_entry*ce, constunsigned char*buf, size_tbuf_len, zend_unserialize_data*data);
uint32_tnum_interfaces;
uint32_tnum_traits;
uint32_tnum_hooked_props;
uint32_tnum_hooked_prop_variance_checks;
/* class_entry or string(s) depending on ZEND_ACC_LINKED */
union {
zend_class_entry**interfaces;
zend_class_name*interface_names;
};
zend_class_name*trait_names;
zend_trait_alias**trait_aliases;
zend_trait_precedence**trait_precedences;
HashTable*attributes;
uint32_tenum_backing_type;
HashTable*backed_enum_table;
zend_string*doc_comment;
union {
struct {
zend_string*filename;
uint32_tline_start;
uint32_tline_end;
} user;
struct {
conststruct_zend_function_entry*builtin_functions;
struct_zend_module_entry*module;
} internal;
} info;
};
typedefunion {
zend_max_align_talign;
uint64_topaque[5];
} zend_random_bytes_insecure_state;
typedefstruct_zend_utility_functions {
void (*error_function)(inttype, zend_string*error_filename, constuint32_terror_lineno, zend_string*message);
size_t (*printf_function)(constchar*format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
size_t (*write_function)(constchar*str, size_tstr_length);
FILE*(*fopen_function)(zend_string*filename, zend_string**opened_path);
void (*message_handler)(zend_longmessage, constvoid*data);
zval*(*get_configuration_directive)(zend_string*name);
void (*ticks_function)(intticks);
void (*on_timeout)(intseconds);
zend_result (*stream_open_function)(zend_file_handle*handle);
void (*printf_to_smart_string_function)(smart_string*buf, constchar*format, va_listap);
void (*printf_to_smart_str_function)(smart_str*buf, constchar*format, va_listap);
char*(*getenv_function)(constchar*name, size_tname_len);
zend_string*(*resolve_path_function)(zend_string*filename);
zend_result (*random_bytes_function)(void*bytes, size_tsize, char*errstr, size_terrstr_size);
void (*random_bytes_insecure_function)(zend_random_bytes_insecure_state*state, void*bytes, size_tsize);
} zend_utility_functions;
typedefstruct_zend_utility_values {
boolhtml_errors;
} zend_utility_values;
typedefsize_t (*zend_write_func_t)(constchar*str, size_tstr_length);
#definezend_bailout() _zend_bailout(__FILE__, __LINE__)
#definezend_try \
{ \
JMP_BUF *__orig_bailout = EG(bailout); \
JMP_BUF __bailout; \
\
EG(bailout) = &__bailout; \
if (SETJMP(__bailout)==0) {
#definezend_catch \
} else { \
EG(bailout) = __orig_bailout;
#definezend_end_try() \
} \
EG(bailout) = __orig_bailout; \
}
#definezend_first_try EG(bailout)=NULL; zend_try
BEGIN_EXTERN_C()
voidzend_startup(zend_utility_functions*utility_functions);
voidzend_shutdown(void);
voidzend_register_standard_ini_entries(void);
zend_resultzend_post_startup(void);
voidzend_set_utility_values(zend_utility_values*utility_values);
voidzend_unload_modules(void);
ZEND_APIZEND_COLDZEND_NORETURNvoid_zend_bailout(constchar*filename, uint32_tlineno);
ZEND_APIsize_tzend_get_page_size(void);
ZEND_APIsize_tzend_vspprintf(char**pbuf, size_tmax_len, constchar*format, va_listap);
ZEND_APIsize_tzend_spprintf(char**message, size_tmax_len, constchar*format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 3, 4);
ZEND_APIzend_string*zend_vstrpprintf(size_tmax_len, constchar*format, va_listap);
ZEND_APIzend_string*zend_strpprintf(size_tmax_len, constchar*format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
/* Same as zend_spprintf and zend_strpprintf, without checking of format validity.
* For use with custom printf specifiers such as %H. */
ZEND_APIsize_tzend_spprintf_unchecked(char**message, size_tmax_len, constchar*format, ...);
ZEND_APIzend_string*zend_strpprintf_unchecked(size_tmax_len, constchar*format, ...);
ZEND_APIconstchar*get_zend_version(void);
ZEND_APIboolzend_make_printable_zval(zval*expr, zval*expr_copy);
ZEND_APIsize_tzend_print_zval(zval*expr, intindent);
ZEND_APIvoidzend_print_zval_r(zval*expr, intindent);
ZEND_APIzend_string*zend_print_zval_r_to_str(zval*expr, intindent);
ZEND_APIvoidzend_print_flat_zval_r(zval*expr);
voidzend_print_flat_zval_r_to_buf(smart_str*str, zval*expr);
staticzend_always_inlinesize_tzend_print_variable(zval*var) {
returnzend_print_zval(var, 0);
}
ZEND_APIZEND_COLDvoidzend_output_debug_string(booltrigger_break, constchar*format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
ZEND_APIvoidzend_activate(void);
ZEND_APIvoidzend_deactivate(void);
ZEND_APIvoidzend_call_destructors(void);
ZEND_APIvoidzend_activate_modules(void);
ZEND_APIvoidzend_deactivate_modules(void);
ZEND_APIvoidzend_post_deactivate_modules(void);
ZEND_APIvoidfree_estring(char**str_p);
END_EXTERN_C()
/* output support */
#defineZEND_WRITE(str, str_len) zend_write((str), (str_len))
#defineZEND_WRITE_EX(str, str_len) write_func((str), (str_len))
#defineZEND_PUTS(str) zend_write((str), strlen((str)))
#defineZEND_PUTS_EX(str) write_func((str), strlen((str)))
#defineZEND_PUTC(c) zend_write(&(c), 1)
BEGIN_EXTERN_C()
externZEND_APIsize_t (*zend_printf)(constchar*format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
externZEND_APIzend_write_func_tzend_write;
externZEND_APIFILE*(*zend_fopen)(zend_string*filename, zend_string**opened_path);
externZEND_APIvoid (*zend_ticks_function)(intticks);
/* Called by the VM in certain places like at the loop header, user function
* entry, and after internal function calls, if EG(vm_interrupt) has been set.
*
* If this is used to switch the EG(current_execute_data), such as implementing
* a coroutine scheduler, then it needs to check the top frame to see if it's
* an internal function. If an internal function is on top, then the frame
* shouldn't be switched away.
*
* Prior to PHP 8.0, this check was not necessary. In PHP 8.0,
* zend_call_function started calling zend_interrupt_function, and in 8.4 the
* DO_*CALL* opcodes started calling the zend_interrupt_function while the
* internal frame is still on top.
*/
externZEND_APIvoid (*zend_interrupt_function)(zend_execute_data*execute_data);
externZEND_APIvoid (*zend_error_cb)(inttype, zend_string*error_filename, constuint32_terror_lineno, zend_string*message);
externZEND_APIvoid (*zend_on_timeout)(intseconds);
externZEND_APIzend_result (*zend_stream_open_function)(zend_file_handle*handle);
externvoid (*zend_printf_to_smart_string)(smart_string*buf, constchar*format, va_listap);
externvoid (*zend_printf_to_smart_str)(smart_str*buf, constchar*format, va_listap);
externZEND_APIchar*(*zend_getenv)(constchar*name, size_tname_len);
externZEND_APIzend_string*(*zend_resolve_path)(zend_string*filename);
/* Generate 'size' random bytes into 'bytes' with the OS CSPRNG. */
externZEND_ATTRIBUTE_NONNULLZEND_APIzend_result (*zend_random_bytes)(
void*bytes, size_tsize, char*errstr, size_terrstr_size);
/* Generate 'size' random bytes into 'bytes' with a general purpose PRNG (not
* crypto safe). 'state' must be zeroed before the first call and can be reused.
*/
externZEND_ATTRIBUTE_NONNULLZEND_APIvoid (*zend_random_bytes_insecure)(
zend_random_bytes_insecure_state*state, void*bytes, size_tsize);
/* These two callbacks are especially for opcache */
externZEND_APIzend_result (*zend_post_startup_cb)(void);
externZEND_APIvoid (*zend_post_shutdown_cb)(void);
externZEND_APIvoid (*zend_accel_schedule_restart_hook)(intreason);
ZEND_APIZEND_COLDvoidzend_error(inttype, constchar*format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
ZEND_APIZEND_COLDZEND_NORETURNvoidzend_error_noreturn(inttype, constchar*format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
ZEND_APIZEND_COLDZEND_NORETURNvoidzend_error_noreturn_unchecked(inttype, constchar*format, ...);
/* For custom format specifiers like H */
ZEND_APIZEND_COLDvoidzend_error_unchecked(inttype, constchar*format, ...);
/* If filename is NULL the default filename is used. */
ZEND_APIZEND_COLDvoidzend_error_at(inttype, zend_string*filename, uint32_tlineno, constchar*format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 4, 5);
ZEND_APIZEND_COLDZEND_NORETURNvoidzend_error_at_noreturn(inttype, zend_string*filename, uint32_tlineno, constchar*format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 4, 5);
ZEND_APIZEND_COLDvoidzend_error_zstr(inttype, zend_string*message);
ZEND_APIZEND_COLDvoidzend_error_zstr_at(inttype, zend_string*filename, uint32_tlineno, zend_string*message);
ZEND_APIZEND_COLDvoidzend_throw_error(zend_class_entry*exception_ce, constchar*format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
ZEND_APIZEND_COLDvoidzend_type_error(constchar*format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 1, 2);
ZEND_APIZEND_COLDvoidzend_argument_count_error(constchar*format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 1, 2);
ZEND_APIZEND_COLDvoidzend_value_error(constchar*format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 1, 2);
/* type should be one of the BP_VAR_* constants, only special messages happen for isset/empty and unset */
ZEND_APIZEND_COLDvoidzend_illegal_container_offset(constzend_string*container, constzval*offset, inttype);
ZEND_COLDvoidzenderror(constchar*error);
/* For internal C errors */
ZEND_APIZEND_COLDZEND_NORETURNvoidzend_strerror_noreturn(inttype, interrn, constchar*message);
/* The following #define is used for code duality in PHP for Engine 1 & 2 */
#defineZEND_STANDARD_CLASS_DEF_PTR zend_standard_class_def
externZEND_APIzend_class_entry*zend_standard_class_def;
externZEND_APIzend_utility_valueszend_uv;
/* If DTrace is available and enabled */
externZEND_APIboolzend_dtrace_enabled;
END_EXTERN_C()
#defineZEND_UV(name) (zend_uv.name)
BEGIN_EXTERN_C()
ZEND_APIvoidzend_message_dispatcher(zend_longmessage, constvoid*data);
ZEND_APIzval*zend_get_configuration_directive(zend_string*name);
END_EXTERN_C()
/* Messages for applications of Zend */
#defineZMSG_FAILED_INCLUDE_FOPEN 1L
#defineZMSG_FAILED_REQUIRE_FOPEN 2L
#defineZMSG_FAILED_HIGHLIGHT_FOPEN 3L
#defineZMSG_MEMORY_LEAK_DETECTED 4L
#defineZMSG_MEMORY_LEAK_REPEATED 5L
#defineZMSG_LOG_SCRIPT_NAME 6L
#defineZMSG_MEMORY_LEAKS_GRAND_TOTAL 7L
typedefenum {
EH_NORMAL=0,
EH_THROW
} zend_error_handling_t;
typedefstruct {
zend_error_handling_thandling;
zend_class_entry*exception;
} zend_error_handling;
BEGIN_EXTERN_C()
ZEND_APIvoidzend_save_error_handling(zend_error_handling*current);
ZEND_APIvoidzend_replace_error_handling(zend_error_handling_terror_handling, zend_class_entry*exception_class, zend_error_handling*current);
ZEND_APIvoidzend_restore_error_handling(zend_error_handling*saved);
ZEND_APIvoidzend_begin_record_errors(void);
ZEND_APIvoidzend_emit_recorded_errors(void);
ZEND_APIvoidzend_free_recorded_errors(void);
END_EXTERN_C()
#defineDEBUG_BACKTRACE_PROVIDE_OBJECT (1<<0)
#defineDEBUG_BACKTRACE_IGNORE_ARGS (1<<1)
#include"zend_object_handlers.h"
#include"zend_operators.h"
#endif/* ZEND_H */