Coverage Report

Created: 2025-06-13 06:43

/src/php-src/Zend/zend_constants.h
Line
Count
Source
1
/*
2
   +----------------------------------------------------------------------+
3
   | Zend Engine                                                          |
4
   +----------------------------------------------------------------------+
5
   | Copyright (c) Zend Technologies Ltd. (http://www.zend.com)           |
6
   +----------------------------------------------------------------------+
7
   | This source file is subject to version 2.00 of the Zend 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.zend.com/license/2_00.txt.                                |
11
   | If you did not receive a copy of the Zend license and are unable to  |
12
   | obtain it through the world-wide-web, please send a note to          |
13
   | license@zend.com so we can mail you a copy immediately.              |
14
   +----------------------------------------------------------------------+
15
   | Authors: Andi Gutmans <andi@php.net>                                 |
16
   |          Zeev Suraski <zeev@php.net>                                 |
17
   +----------------------------------------------------------------------+
18
*/
19
20
#ifndef ZEND_CONSTANTS_H
21
#define ZEND_CONSTANTS_H
22
23
#include "zend_globals.h"
24
25
#define CONST_CS        0         /* No longer used -- always case sensitive */
26
29.5k
#define CONST_PERSISTENT    (1<<0)        /* Persistent */
27
9.10k
#define CONST_NO_FILE_CACHE   (1<<1)        /* Can't be saved in file cache */
28
13.0k
#define CONST_DEPRECATED    (1<<2)        /* Deprecated */
29
8.05k
#define CONST_OWNED       (1<<3)        /* constant should be destroyed together with class */
30
668
#define CONST_RECURSIVE     (1<<4)        /* Recursion protection for constant evaluation */
31
32
236
#define CONST_IS_RECURSIVE(c) (Z_CONSTANT_FLAGS((c)->value) & CONST_RECURSIVE)
33
#define CONST_PROTECT_RECURSION(c) \
34
216
  do { \
35
216
    Z_CONSTANT_FLAGS((c)->value) |= CONST_RECURSIVE; \
36
216
  } while (0)
37
#define CONST_UNPROTECT_RECURSION(c) \
38
216
  do { \
39
216
    Z_CONSTANT_FLAGS((c)->value) &= ~CONST_RECURSIVE; \
40
216
  } while (0)
41
42
13.9k
#define PHP_USER_CONSTANT   0x7fffff /* a constant defined in user space */
43
44
typedef struct _zend_constant {
45
  zval value;
46
  zend_string *name;
47
  zend_string *filename;
48
  HashTable *attributes;
49
} zend_constant;
50
51
#define ZEND_CONSTANT_FLAGS(c) \
52
42.9k
  (Z_CONSTANT_FLAGS((c)->value) & 0xff)
53
54
#define ZEND_CONSTANT_MODULE_NUMBER(c) \
55
19.3k
  (Z_CONSTANT_FLAGS((c)->value) >> 8)
56
57
11.1k
#define ZEND_CONSTANT_SET_FLAGS(c, _flags, _module_number) do { \
58
11.1k
    Z_CONSTANT_FLAGS((c)->value) = \
59
11.1k
      ((_flags) & 0xff) | ((_module_number) << 8); \
60
11.1k
  } while (0)
61
62
16
#define REGISTER_NULL_CONSTANT(name, flags)  zend_register_null_constant((name), sizeof(name)-1, (flags), module_number)
63
112
#define REGISTER_BOOL_CONSTANT(name, bval, flags)  zend_register_bool_constant((name), sizeof(name)-1, (bval), (flags), module_number)
64
7.53k
#define REGISTER_LONG_CONSTANT(name, lval, flags)  zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), module_number)
65
352
#define REGISTER_DOUBLE_CONSTANT(name, dval, flags)  zend_register_double_constant((name), sizeof(name)-1, (dval), (flags), module_number)
66
672
#define REGISTER_STRING_CONSTANT(name, str, flags)  zend_register_string_constant((name), sizeof(name)-1, (str), (flags), module_number)
67
#define REGISTER_STRINGL_CONSTANT(name, str, len, flags)  zend_register_stringl_constant((name), sizeof(name)-1, (str), (len), (flags), module_number)
68
69
#define REGISTER_NS_NULL_CONSTANT(ns, name, flags)  zend_register_null_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (flags), module_number)
70
#define REGISTER_NS_BOOL_CONSTANT(ns, name, bval, flags)  zend_register_bool_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (bval), (flags), module_number)
71
#define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
72
#define REGISTER_NS_DOUBLE_CONSTANT(ns, name, dval, flags)  zend_register_double_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (dval), (flags), module_number)
73
#define REGISTER_NS_STRING_CONSTANT(ns, name, str, flags)  zend_register_string_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (str), (flags), module_number)
74
#define REGISTER_NS_STRINGL_CONSTANT(ns, name, str, len, flags)  zend_register_stringl_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (str), (len), (flags), module_number)
75
76
#define REGISTER_MAIN_NULL_CONSTANT(name, flags)  zend_register_null_constant((name), sizeof(name)-1, (flags), 0)
77
#define REGISTER_MAIN_BOOL_CONSTANT(name, bval, flags)  zend_register_bool_constant((name), sizeof(name)-1, (bval), (flags), 0)
78
#define REGISTER_MAIN_LONG_CONSTANT(name, lval, flags)  zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), 0)
79
#define REGISTER_MAIN_DOUBLE_CONSTANT(name, dval, flags)  zend_register_double_constant((name), sizeof(name)-1, (dval), (flags), 0)
80
#define REGISTER_MAIN_STRING_CONSTANT(name, str, flags)  zend_register_string_constant((name), sizeof(name)-1, (str), (flags), 0)
81
#define REGISTER_MAIN_STRINGL_CONSTANT(name, str, len, flags)  zend_register_stringl_constant((name), sizeof(name)-1, (str), (len), (flags), 0)
82
83
BEGIN_EXTERN_C()
84
void clean_module_constants(int module_number);
85
void free_zend_constant(zval *zv);
86
void zend_startup_constants(void);
87
void zend_register_standard_constants(void);
88
ZEND_API bool zend_verify_const_access(zend_class_constant *c, zend_class_entry *ce);
89
ZEND_API zval *zend_get_constant(zend_string *name);
90
ZEND_API zend_constant *zend_get_constant_ptr(zend_string *name);
91
ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len);
92
ZEND_API zval *zend_get_constant_ex(zend_string *name, zend_class_entry *scope, uint32_t flags);
93
ZEND_API zval *zend_get_class_constant_ex(zend_string *class_name, zend_string *constant_name, zend_class_entry *scope, uint32_t flags);
94
ZEND_API void zend_register_bool_constant(const char *name, size_t name_len, bool bval, int flags, int module_number);
95
ZEND_API void zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number);
96
ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number);
97
ZEND_API void zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number);
98
ZEND_API void zend_register_string_constant(const char *name, size_t name_len, const char *strval, int flags, int module_number);
99
ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, const char *strval, size_t strlen, int flags, int module_number);
100
ZEND_API zend_result zend_register_constant(zend_constant *c);
101
void zend_constant_add_attributes(zend_constant *c, HashTable *attributes);
102
#ifdef ZTS
103
void zend_copy_constants(HashTable *target, HashTable *source);
104
#endif
105
106
ZEND_API zend_constant *_zend_get_special_const(const char *name, size_t name_len);
107
108
static zend_always_inline zend_constant *zend_get_special_const(
109
746k
    const char *name, size_t name_len) {
110
746k
  if (name_len == 4 || name_len == 5) {
111
71.6k
    return _zend_get_special_const(name, name_len);
112
71.6k
  }
113
674k
  return NULL;
114
746k
}
Unexecuted instantiation: php_date.c:zend_get_special_const
Unexecuted instantiation: php_pcre.c:zend_get_special_const
Unexecuted instantiation: exif.c:zend_get_special_const
Unexecuted instantiation: hash_adler32.c:zend_get_special_const
Unexecuted instantiation: hash_crc32.c:zend_get_special_const
Unexecuted instantiation: hash_fnv.c:zend_get_special_const
Unexecuted instantiation: hash_gost.c:zend_get_special_const
Unexecuted instantiation: hash_haval.c:zend_get_special_const
Unexecuted instantiation: hash_joaat.c:zend_get_special_const
Unexecuted instantiation: hash_md.c:zend_get_special_const
Unexecuted instantiation: hash_murmur.c:zend_get_special_const
Unexecuted instantiation: hash_ripemd.c:zend_get_special_const
Unexecuted instantiation: hash_sha_ni.c:zend_get_special_const
Unexecuted instantiation: hash_sha_sse2.c:zend_get_special_const
Unexecuted instantiation: hash_sha.c:zend_get_special_const
Unexecuted instantiation: hash_sha3.c:zend_get_special_const
Unexecuted instantiation: hash_snefru.c:zend_get_special_const
Unexecuted instantiation: hash_tiger.c:zend_get_special_const
Unexecuted instantiation: hash_whirlpool.c:zend_get_special_const
Unexecuted instantiation: hash_xxhash.c:zend_get_special_const
Unexecuted instantiation: hash.c:zend_get_special_const
Unexecuted instantiation: json_encoder.c:zend_get_special_const
Unexecuted instantiation: json_parser.tab.c:zend_get_special_const
Unexecuted instantiation: json_scanner.c:zend_get_special_const
Unexecuted instantiation: json.c:zend_get_special_const
Unexecuted instantiation: php_lexbor.c:zend_get_special_const
Unexecuted instantiation: csprng.c:zend_get_special_const
Unexecuted instantiation: engine_mt19937.c:zend_get_special_const
Unexecuted instantiation: engine_pcgoneseq128xslrr64.c:zend_get_special_const
Unexecuted instantiation: engine_secure.c:zend_get_special_const
Unexecuted instantiation: engine_user.c:zend_get_special_const
Unexecuted instantiation: engine_xoshiro256starstar.c:zend_get_special_const
Unexecuted instantiation: gammasection.c:zend_get_special_const
Unexecuted instantiation: random.c:zend_get_special_const
Unexecuted instantiation: randomizer.c:zend_get_special_const
Unexecuted instantiation: zend_utils.c:zend_get_special_const
Unexecuted instantiation: php_reflection.c:zend_get_special_const
Unexecuted instantiation: php_spl.c:zend_get_special_const
Unexecuted instantiation: spl_array.c:zend_get_special_const
Unexecuted instantiation: spl_directory.c:zend_get_special_const
Unexecuted instantiation: spl_dllist.c:zend_get_special_const
Unexecuted instantiation: spl_exceptions.c:zend_get_special_const
Unexecuted instantiation: spl_fixedarray.c:zend_get_special_const
Unexecuted instantiation: spl_functions.c:zend_get_special_const
Unexecuted instantiation: spl_heap.c:zend_get_special_const
Unexecuted instantiation: spl_iterators.c:zend_get_special_const
Unexecuted instantiation: spl_observer.c:zend_get_special_const
Unexecuted instantiation: array.c:zend_get_special_const
Unexecuted instantiation: assert.c:zend_get_special_const
Unexecuted instantiation: base64.c:zend_get_special_const
Unexecuted instantiation: basic_functions.c:zend_get_special_const
Unexecuted instantiation: browscap.c:zend_get_special_const
Unexecuted instantiation: crc32_x86.c:zend_get_special_const
Unexecuted instantiation: crc32.c:zend_get_special_const
Unexecuted instantiation: credits.c:zend_get_special_const
Unexecuted instantiation: crypt.c:zend_get_special_const
Unexecuted instantiation: css.c:zend_get_special_const
Unexecuted instantiation: datetime.c:zend_get_special_const
Unexecuted instantiation: dir.c:zend_get_special_const
Unexecuted instantiation: dl.c:zend_get_special_const
Unexecuted instantiation: dns.c:zend_get_special_const
Unexecuted instantiation: exec.c:zend_get_special_const
Unexecuted instantiation: file.c:zend_get_special_const
Unexecuted instantiation: filestat.c:zend_get_special_const
Unexecuted instantiation: filters.c:zend_get_special_const
Unexecuted instantiation: flock_compat.c:zend_get_special_const
Unexecuted instantiation: formatted_print.c:zend_get_special_const
Unexecuted instantiation: fsock.c:zend_get_special_const
Unexecuted instantiation: ftok.c:zend_get_special_const
Unexecuted instantiation: ftp_fopen_wrapper.c:zend_get_special_const
Unexecuted instantiation: head.c:zend_get_special_const
Unexecuted instantiation: hrtime.c:zend_get_special_const
Unexecuted instantiation: html.c:zend_get_special_const
Unexecuted instantiation: http_fopen_wrapper.c:zend_get_special_const
Unexecuted instantiation: http.c:zend_get_special_const
Unexecuted instantiation: image.c:zend_get_special_const
Unexecuted instantiation: incomplete_class.c:zend_get_special_const
Unexecuted instantiation: info.c:zend_get_special_const
Unexecuted instantiation: iptc.c:zend_get_special_const
Unexecuted instantiation: levenshtein.c:zend_get_special_const
Unexecuted instantiation: link.c:zend_get_special_const
Unexecuted instantiation: mail.c:zend_get_special_const
Unexecuted instantiation: math.c:zend_get_special_const
Unexecuted instantiation: md5.c:zend_get_special_const
Unexecuted instantiation: metaphone.c:zend_get_special_const
Unexecuted instantiation: microtime.c:zend_get_special_const
Unexecuted instantiation: net.c:zend_get_special_const
Unexecuted instantiation: pack.c:zend_get_special_const
Unexecuted instantiation: pageinfo.c:zend_get_special_const
Unexecuted instantiation: password.c:zend_get_special_const
Unexecuted instantiation: php_fopen_wrapper.c:zend_get_special_const
Unexecuted instantiation: proc_open.c:zend_get_special_const
Unexecuted instantiation: quot_print.c:zend_get_special_const
Unexecuted instantiation: scanf.c:zend_get_special_const
Unexecuted instantiation: sha1.c:zend_get_special_const
Unexecuted instantiation: soundex.c:zend_get_special_const
Unexecuted instantiation: streamsfuncs.c:zend_get_special_const
Unexecuted instantiation: string.c:zend_get_special_const
Unexecuted instantiation: strnatcmp.c:zend_get_special_const
Unexecuted instantiation: syslog.c:zend_get_special_const
Unexecuted instantiation: type.c:zend_get_special_const
Unexecuted instantiation: uniqid.c:zend_get_special_const
Unexecuted instantiation: url_scanner_ex.c:zend_get_special_const
Unexecuted instantiation: url.c:zend_get_special_const
Unexecuted instantiation: user_filters.c:zend_get_special_const
Unexecuted instantiation: uuencode.c:zend_get_special_const
Unexecuted instantiation: var_unserializer.c:zend_get_special_const
Unexecuted instantiation: var.c:zend_get_special_const
Unexecuted instantiation: versioning.c:zend_get_special_const
Unexecuted instantiation: crypt_sha256.c:zend_get_special_const
Unexecuted instantiation: crypt_sha512.c:zend_get_special_const
Unexecuted instantiation: php_crypt_r.c:zend_get_special_const
Unexecuted instantiation: php_uri.c:zend_get_special_const
Unexecuted instantiation: php_uri_common.c:zend_get_special_const
Unexecuted instantiation: explicit_bzero.c:zend_get_special_const
Unexecuted instantiation: fopen_wrappers.c:zend_get_special_const
Unexecuted instantiation: getopt.c:zend_get_special_const
Unexecuted instantiation: main.c:zend_get_special_const
Unexecuted instantiation: network.c:zend_get_special_const
Unexecuted instantiation: output.c:zend_get_special_const
Unexecuted instantiation: php_content_types.c:zend_get_special_const
Unexecuted instantiation: php_ini_builder.c:zend_get_special_const
Unexecuted instantiation: php_ini.c:zend_get_special_const
Unexecuted instantiation: php_glob.c:zend_get_special_const
Unexecuted instantiation: php_odbc_utils.c:zend_get_special_const
Unexecuted instantiation: php_open_temporary_file.c:zend_get_special_const
Unexecuted instantiation: php_scandir.c:zend_get_special_const
Unexecuted instantiation: php_syslog.c:zend_get_special_const
Unexecuted instantiation: php_ticks.c:zend_get_special_const
Unexecuted instantiation: php_variables.c:zend_get_special_const
Unexecuted instantiation: reentrancy.c:zend_get_special_const
Unexecuted instantiation: rfc1867.c:zend_get_special_const
Unexecuted instantiation: safe_bcmp.c:zend_get_special_const
Unexecuted instantiation: SAPI.c:zend_get_special_const
Unexecuted instantiation: snprintf.c:zend_get_special_const
Unexecuted instantiation: spprintf.c:zend_get_special_const
Unexecuted instantiation: strlcat.c:zend_get_special_const
Unexecuted instantiation: strlcpy.c:zend_get_special_const
Unexecuted instantiation: cast.c:zend_get_special_const
Unexecuted instantiation: filter.c:zend_get_special_const
Unexecuted instantiation: glob_wrapper.c:zend_get_special_const
Unexecuted instantiation: memory.c:zend_get_special_const
Unexecuted instantiation: mmap.c:zend_get_special_const
Unexecuted instantiation: plain_wrapper.c:zend_get_special_const
Unexecuted instantiation: streams.c:zend_get_special_const
Unexecuted instantiation: transports.c:zend_get_special_const
Unexecuted instantiation: userspace.c:zend_get_special_const
Unexecuted instantiation: xp_socket.c:zend_get_special_const
block_pass.c:zend_get_special_const
Line
Count
Source
109
30.8k
    const char *name, size_t name_len) {
110
30.8k
  if (name_len == 4 || name_len == 5) {
111
4.71k
    return _zend_get_special_const(name, name_len);
112
4.71k
  }
113
26.1k
  return NULL;
114
30.8k
}
Unexecuted instantiation: compact_literals.c:zend_get_special_const
Unexecuted instantiation: compact_vars.c:zend_get_special_const
Unexecuted instantiation: dfa_pass.c:zend_get_special_const
Unexecuted instantiation: nop_removal.c:zend_get_special_const
Unexecuted instantiation: optimize_func_calls.c:zend_get_special_const
Unexecuted instantiation: optimize_temp_vars_5.c:zend_get_special_const
Unexecuted instantiation: pass1.c:zend_get_special_const
Unexecuted instantiation: pass3.c:zend_get_special_const
Unexecuted instantiation: sccp.c:zend_get_special_const
Unexecuted instantiation: zend_optimizer.c:zend_get_special_const
Unexecuted instantiation: zend_API.c:zend_get_special_const
Unexecuted instantiation: zend_ast.c:zend_get_special_const
Unexecuted instantiation: zend_attributes.c:zend_get_special_const
Unexecuted instantiation: zend_builtin_functions.c:zend_get_special_const
Unexecuted instantiation: zend_closures.c:zend_get_special_const
zend_compile.c:zend_get_special_const
Line
Count
Source
109
561k
    const char *name, size_t name_len) {
110
561k
  if (name_len == 4 || name_len == 5) {
111
60.5k
    return _zend_get_special_const(name, name_len);
112
60.5k
  }
113
500k
  return NULL;
114
561k
}
zend_constants.c:zend_get_special_const
Line
Count
Source
109
154k
    const char *name, size_t name_len) {
110
154k
  if (name_len == 4 || name_len == 5) {
111
6.38k
    return _zend_get_special_const(name, name_len);
112
6.38k
  }
113
147k
  return NULL;
114
154k
}
Unexecuted instantiation: zend_default_classes.c:zend_get_special_const
Unexecuted instantiation: zend_dtrace.c:zend_get_special_const
Unexecuted instantiation: zend_enum.c:zend_get_special_const
Unexecuted instantiation: zend_exceptions.c:zend_get_special_const
Unexecuted instantiation: zend_execute_API.c:zend_get_special_const
Unexecuted instantiation: zend_execute.c:zend_get_special_const
Unexecuted instantiation: zend_fibers.c:zend_get_special_const
Unexecuted instantiation: zend_gc.c:zend_get_special_const
Unexecuted instantiation: zend_generators.c:zend_get_special_const
Unexecuted instantiation: zend_inheritance.c:zend_get_special_const
Unexecuted instantiation: zend_ini_parser.c:zend_get_special_const
Unexecuted instantiation: zend_ini_scanner.c:zend_get_special_const
Unexecuted instantiation: zend_ini.c:zend_get_special_const
Unexecuted instantiation: zend_interfaces.c:zend_get_special_const
Unexecuted instantiation: zend_iterators.c:zend_get_special_const
Unexecuted instantiation: zend_language_parser.c:zend_get_special_const
Unexecuted instantiation: zend_language_scanner.c:zend_get_special_const
Unexecuted instantiation: zend_lazy_objects.c:zend_get_special_const
Unexecuted instantiation: zend_list.c:zend_get_special_const
Unexecuted instantiation: zend_object_handlers.c:zend_get_special_const
Unexecuted instantiation: zend_objects_API.c:zend_get_special_const
Unexecuted instantiation: zend_objects.c:zend_get_special_const
Unexecuted instantiation: zend_observer.c:zend_get_special_const
Unexecuted instantiation: zend_opcode.c:zend_get_special_const
Unexecuted instantiation: zend_operators.c:zend_get_special_const
Unexecuted instantiation: zend_property_hooks.c:zend_get_special_const
Unexecuted instantiation: zend_smart_str.c:zend_get_special_const
Unexecuted instantiation: zend_system_id.c:zend_get_special_const
Unexecuted instantiation: zend_variables.c:zend_get_special_const
Unexecuted instantiation: zend_weakrefs.c:zend_get_special_const
Unexecuted instantiation: zend.c:zend_get_special_const
Unexecuted instantiation: internal_functions_cli.c:zend_get_special_const
Unexecuted instantiation: fuzzer-parser.c:zend_get_special_const
Unexecuted instantiation: fuzzer-sapi.c:zend_get_special_const
Unexecuted instantiation: fuzzer-tracing-jit.c:zend_get_special_const
Unexecuted instantiation: fuzzer-exif.c:zend_get_special_const
Unexecuted instantiation: fuzzer-unserialize.c:zend_get_special_const
Unexecuted instantiation: fuzzer-function-jit.c:zend_get_special_const
Unexecuted instantiation: fuzzer-json.c:zend_get_special_const
Unexecuted instantiation: fuzzer-unserializehash.c:zend_get_special_const
Unexecuted instantiation: fuzzer-execute.c:zend_get_special_const
115
116
END_EXTERN_C()
117
118
#define ZEND_CONSTANT_DTOR free_zend_constant
119
120
#endif