Skip to content

Commit aed3acf

Browse files
committed
ext/opcache: add const qualifiers
1 parent fd1c366 commit aed3acf

8 files changed

+53
-53
lines changed

ext/opcache/zend_accelerator_blacklist.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ void zend_accel_blacklist_shutdown(zend_blacklist *blacklist)
205205
return;
206206
}
207207

208-
zend_blacklist_entry *p = blacklist->entries, *end = blacklist->entries + blacklist->pos;
208+
const zend_blacklist_entry *p = blacklist->entries, *end = blacklist->entries + blacklist->pos;
209209
while (p<end) {
210210
free(p->path);
211211
p++;
@@ -336,10 +336,10 @@ void zend_accel_blacklist_load(zend_blacklist *blacklist, char *filename)
336336
zend_accel_blacklist_update_regexp(blacklist);
337337
}
338338

339-
bool zend_accel_blacklist_is_blacklisted(zend_blacklist *blacklist, char *verify_path, size_t verify_path_len)
339+
bool zend_accel_blacklist_is_blacklisted(const zend_blacklist *blacklist, const char *verify_path, size_t verify_path_len)
340340
{
341341
int ret = 0;
342-
zend_regexp_list *regexp_list_it = blacklist->regexp_list;
342+
const zend_regexp_list *regexp_list_it = blacklist->regexp_list;
343343
pcre2_match_context *mctx = php_pcre_mctx();
344344

345345
if (regexp_list_it == NULL) {
@@ -363,7 +363,7 @@ bool zend_accel_blacklist_is_blacklisted(zend_blacklist *blacklist, char *verify
363363
return ret;
364364
}
365365

366-
void zend_accel_blacklist_apply(zend_blacklist *blacklist, blacklist_apply_func_arg_t func, void *argument)
366+
void zend_accel_blacklist_apply(const zend_blacklist *blacklist, blacklist_apply_func_arg_t func, void *argument)
367367
{
368368
int i;
369369

ext/opcache/zend_accelerator_blacklist.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void zend_accel_blacklist_init(zend_blacklist *blacklist);
4545
void zend_accel_blacklist_shutdown(zend_blacklist *blacklist);
4646

4747
void zend_accel_blacklist_load(zend_blacklist *blacklist, char *filename);
48-
bool zend_accel_blacklist_is_blacklisted(zend_blacklist *blacklist, char *verify_path, size_t verify_path_len);
49-
void zend_accel_blacklist_apply(zend_blacklist *blacklist, blacklist_apply_func_arg_t func, void *argument);
48+
bool zend_accel_blacklist_is_blacklisted(const zend_blacklist *blacklist, const char *verify_path, size_t verify_path_len);
49+
void zend_accel_blacklist_apply(const zend_blacklist *blacklist, blacklist_apply_func_arg_t func, void *argument);
5050

5151
#endif /* ZEND_ACCELERATOR_BLACKLIST_H */

ext/opcache/zend_accelerator_hash.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ zend_accel_hash_entry* zend_accel_hash_update(zend_accel_hash *accel_hash, zend_
138138
return entry;
139139
}
140140

141-
static zend_always_inline void* zend_accel_hash_find_ex(zend_accel_hash *accel_hash, zend_string *key, int data)
141+
static zend_always_inline void* zend_accel_hash_find_ex(const zend_accel_hash *accel_hash, zend_string *key, int data)
142142
{
143143
zend_ulong index;
144144
zend_accel_hash_entry *entry;
@@ -176,15 +176,15 @@ static zend_always_inline void* zend_accel_hash_find_ex(zend_accel_hash *accel_h
176176
/* Returns the data associated with key on success
177177
* Returns NULL if data doesn't exist
178178
*/
179-
void* zend_accel_hash_find(zend_accel_hash *accel_hash, zend_string *key)
179+
void* zend_accel_hash_find(const zend_accel_hash *accel_hash, zend_string *key)
180180
{
181181
return zend_accel_hash_find_ex(accel_hash, key, 1);
182182
}
183183

184184
/* Returns the hash entry associated with key on success
185185
* Returns NULL if it doesn't exist
186186
*/
187-
zend_accel_hash_entry* zend_accel_hash_find_entry(zend_accel_hash *accel_hash, zend_string *key)
187+
zend_accel_hash_entry* zend_accel_hash_find_entry(const zend_accel_hash *accel_hash, zend_string *key)
188188
{
189189
return (zend_accel_hash_entry *)zend_accel_hash_find_ex(accel_hash, key, 0);
190190
}

ext/opcache/zend_accelerator_hash.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,18 @@ zend_accel_hash_entry* zend_accel_hash_update(
7272
void *data);
7373

7474
void* zend_accel_hash_find(
75-
zend_accel_hash *accel_hash,
75+
const zend_accel_hash *accel_hash,
7676
zend_string *key);
7777

7878
zend_accel_hash_entry* zend_accel_hash_find_entry(
79-
zend_accel_hash *accel_hash,
79+
const zend_accel_hash *accel_hash,
8080
zend_string *key);
8181

8282
int zend_accel_hash_unlink(
8383
zend_accel_hash *accel_hash,
8484
zend_string *key);
8585

86-
static inline bool zend_accel_hash_is_full(zend_accel_hash *accel_hash)
86+
static inline bool zend_accel_hash_is_full(const zend_accel_hash *accel_hash)
8787
{
8888
if (accel_hash->num_entries == accel_hash->max_num_entries) {
8989
return true;

ext/opcache/zend_accelerator_util_funcs.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void zend_accel_move_user_classes(HashTable *src, uint32_t count, zend_script *s
105105
{
106106
Bucket *p, *end;
107107
HashTable *dst;
108-
zend_string *filename;
108+
const zend_string *filename;
109109
dtor_func_t orig_dtor;
110110
zend_class_entry *ce;
111111

@@ -132,10 +132,10 @@ void zend_accel_move_user_classes(HashTable *src, uint32_t count, zend_script *s
132132
src->pDestructor = orig_dtor;
133133
}
134134

135-
static zend_always_inline void _zend_accel_function_hash_copy(HashTable *target, HashTable *source, bool call_observers)
135+
static zend_always_inline void _zend_accel_function_hash_copy(HashTable *target, const HashTable *source, bool call_observers)
136136
{
137137
zend_function *function1, *function2;
138-
Bucket *p, *end;
138+
const Bucket *p, *end;
139139
zval *t;
140140

141141
zend_hash_extend(target, target->nNumUsed + source->nNumUsed, 0);
@@ -174,20 +174,20 @@ static zend_always_inline void _zend_accel_function_hash_copy(HashTable *target,
174174
}
175175
}
176176

177-
static zend_always_inline void zend_accel_function_hash_copy(HashTable *target, HashTable *source)
177+
static zend_always_inline void zend_accel_function_hash_copy(HashTable *target, const HashTable *source)
178178
{
179179
_zend_accel_function_hash_copy(target, source, false);
180180
}
181181

182-
static zend_never_inline void zend_accel_function_hash_copy_notify(HashTable *target, HashTable *source)
182+
static zend_never_inline void zend_accel_function_hash_copy_notify(HashTable *target, const HashTable *source)
183183
{
184184
_zend_accel_function_hash_copy(target, source, true);
185185
}
186186

187-
static zend_always_inline void _zend_accel_class_hash_copy(HashTable *target, HashTable *source, bool call_observers)
187+
static zend_always_inline void _zend_accel_class_hash_copy(HashTable *target, const HashTable *source, bool call_observers)
188188
{
189-
Bucket *p, *end;
190-
zval *t;
189+
const Bucket *p, *end;
190+
const zval *t;
191191

192192
zend_hash_extend(target, target->nNumUsed + source->nNumUsed, 0);
193193
p = source->arData;
@@ -209,7 +209,7 @@ static zend_always_inline void _zend_accel_class_hash_copy(HashTable *target, Ha
209209
* value. */
210210
continue;
211211
} else if (UNEXPECTED(!ZCG(accel_directives).ignore_dups)) {
212-
zend_class_entry *ce1 = Z_PTR(p->val);
212+
const zend_class_entry *ce1 = Z_PTR(p->val);
213213
if (!(ce1->ce_flags & ZEND_ACC_ANON_CLASS)) {
214214
CG(in_compilation) = 1;
215215
zend_set_compiled_filename(ce1->info.user.filename);
@@ -235,25 +235,25 @@ static zend_always_inline void _zend_accel_class_hash_copy(HashTable *target, Ha
235235
target->nInternalPointer = 0;
236236
}
237237

238-
static zend_always_inline void zend_accel_class_hash_copy(HashTable *target, HashTable *source)
238+
static zend_always_inline void zend_accel_class_hash_copy(HashTable *target, const HashTable *source)
239239
{
240240
_zend_accel_class_hash_copy(target, source, false);
241241
}
242242

243-
static zend_never_inline void zend_accel_class_hash_copy_notify(HashTable *target, HashTable *source)
243+
static zend_never_inline void zend_accel_class_hash_copy_notify(HashTable *target, const HashTable *source)
244244
{
245245
_zend_accel_class_hash_copy(target, source, true);
246246
}
247247

248248
void zend_accel_build_delayed_early_binding_list(zend_persistent_script *persistent_script)
249249
{
250-
zend_op_array *op_array = &persistent_script->script.main_op_array;
250+
const zend_op_array *op_array = &persistent_script->script.main_op_array;
251251
if (!(op_array->fn_flags & ZEND_ACC_EARLY_BINDING)) {
252252
return;
253253
}
254254

255-
zend_op *end = op_array->opcodes + op_array->last;
256-
for (zend_op *opline = op_array->opcodes; opline < end; opline++) {
255+
const zend_op *end = op_array->opcodes + op_array->last;
256+
for (const zend_op *opline = op_array->opcodes; opline < end; opline++) {
257257
if (opline->opcode == ZEND_DECLARE_CLASS_DELAYED) {
258258
persistent_script->num_early_bindings++;
259259
}
@@ -264,7 +264,7 @@ void zend_accel_build_delayed_early_binding_list(zend_persistent_script *persist
264264

265265
for (zend_op *opline = op_array->opcodes; opline < end; opline++) {
266266
if (opline->opcode == ZEND_DECLARE_CLASS_DELAYED) {
267-
zval *lcname = RT_CONSTANT(opline, opline->op1);
267+
const zval *lcname = RT_CONSTANT(opline, opline->op1);
268268
early_binding->lcname = zend_string_copy(Z_STR_P(lcname));
269269
early_binding->rtd_key = zend_string_copy(Z_STR_P(lcname + 1));
270270
early_binding->lc_parent_name =
@@ -275,19 +275,19 @@ void zend_accel_build_delayed_early_binding_list(zend_persistent_script *persist
275275
}
276276
}
277277

278-
void zend_accel_finalize_delayed_early_binding_list(zend_persistent_script *persistent_script)
278+
void zend_accel_finalize_delayed_early_binding_list(const zend_persistent_script *persistent_script)
279279
{
280280
if (!persistent_script->num_early_bindings) {
281281
return;
282282
}
283283

284284
zend_early_binding *early_binding = persistent_script->early_bindings;
285-
zend_early_binding *early_binding_end = early_binding + persistent_script->num_early_bindings;
286-
zend_op_array *op_array = &persistent_script->script.main_op_array;
287-
zend_op *opline_end = op_array->opcodes + op_array->last;
285+
const zend_early_binding *early_binding_end = early_binding + persistent_script->num_early_bindings;
286+
const zend_op_array *op_array = &persistent_script->script.main_op_array;
287+
const zend_op *opline_end = op_array->opcodes + op_array->last;
288288
for (zend_op *opline = op_array->opcodes; opline < opline_end; opline++) {
289289
if (opline->opcode == ZEND_DECLARE_CLASS_DELAYED) {
290-
zend_string *rtd_key = Z_STR_P(RT_CONSTANT(opline, opline->op1) + 1);
290+
const zend_string *rtd_key = Z_STR_P(RT_CONSTANT(opline, opline->op1) + 1);
291291
/* Skip early_binding entries that don't match, maybe their DECLARE_CLASS_DELAYED
292292
* was optimized away. */
293293
while (!zend_string_equals(early_binding->rtd_key, rtd_key)) {
@@ -310,7 +310,7 @@ void zend_accel_free_delayed_early_binding_list(zend_persistent_script *persiste
310310
{
311311
if (persistent_script->num_early_bindings) {
312312
for (uint32_t i = 0; i < persistent_script->num_early_bindings; i++) {
313-
zend_early_binding *early_binding = &persistent_script->early_bindings[i];
313+
const zend_early_binding *early_binding = &persistent_script->early_bindings[i];
314314
zend_string_release(early_binding->lcname);
315315
zend_string_release(early_binding->rtd_key);
316316
zend_string_release(early_binding->lc_parent_name);
@@ -322,7 +322,7 @@ void zend_accel_free_delayed_early_binding_list(zend_persistent_script *persiste
322322
}
323323

324324
static void zend_accel_do_delayed_early_binding(
325-
zend_persistent_script *persistent_script, zend_op_array *op_array)
325+
const zend_persistent_script *persistent_script, zend_op_array *op_array)
326326
{
327327
ZEND_ASSERT(!ZEND_MAP_PTR(op_array->run_time_cache));
328328
ZEND_ASSERT(op_array->fn_flags & ZEND_ACC_HEAP_RT_CACHE);
@@ -336,7 +336,7 @@ static void zend_accel_do_delayed_early_binding(
336336
CG(compiled_filename) = persistent_script->script.filename;
337337
CG(in_compilation) = 1;
338338
for (uint32_t i = 0; i < persistent_script->num_early_bindings; i++) {
339-
zend_early_binding *early_binding = &persistent_script->early_bindings[i];
339+
const zend_early_binding *early_binding = &persistent_script->early_bindings[i];
340340
zend_class_entry *ce = zend_hash_find_ex_ptr(EG(class_table), early_binding->lcname, 1);
341341
if (!ce) {
342342
zval *zv = zend_hash_find_known_hash(EG(class_table), early_binding->rtd_key);
@@ -448,7 +448,7 @@ zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script,
448448
#define ADLER32_SCALAR_DO8(buf, i) ADLER32_SCALAR_DO4(buf, i); ADLER32_SCALAR_DO4(buf, i + 4);
449449
#define ADLER32_SCALAR_DO16(buf) ADLER32_SCALAR_DO8(buf, 0); ADLER32_SCALAR_DO8(buf, 8);
450450

451-
static zend_always_inline void adler32_do16_loop(unsigned char *buf, unsigned char *end, unsigned int *s1_out, unsigned int *s2_out)
451+
static zend_always_inline void adler32_do16_loop(unsigned char *buf, const unsigned char *end, unsigned int *s1_out, unsigned int *s2_out)
452452
{
453453
unsigned int s1 = *s1_out;
454454
unsigned int s2 = *s2_out;

ext/opcache/zend_accelerator_util_funcs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void free_persistent_script(zend_persistent_script *persistent_script, int destr
3333
void zend_accel_move_user_functions(HashTable *str, uint32_t count, zend_script *script);
3434
void zend_accel_move_user_classes(HashTable *str, uint32_t count, zend_script *script);
3535
void zend_accel_build_delayed_early_binding_list(zend_persistent_script *persistent_script);
36-
void zend_accel_finalize_delayed_early_binding_list(zend_persistent_script *persistent_script);
36+
void zend_accel_finalize_delayed_early_binding_list(const zend_persistent_script *persistent_script);
3737
void zend_accel_free_delayed_early_binding_list(zend_persistent_script *persistent_script);
3838

3939
zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script, int from_shared_memory);

ext/opcache/zend_persist.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ static void zend_persist_op_array(zval *zv)
732732
}
733733
}
734734

735-
static zend_op_array *zend_persist_class_method(zend_op_array *op_array, zend_class_entry *ce)
735+
static zend_op_array *zend_persist_class_method(zend_op_array *op_array, const zend_class_entry *ce)
736736
{
737737
zend_op_array *old_op_array;
738738

@@ -834,7 +834,7 @@ static zend_property_info *zend_persist_property_info(zend_property_info *prop)
834834
prop->attributes = zend_persist_attributes(prop->attributes);
835835
}
836836
if (prop->prototype) {
837-
zend_property_info *new_prototype = (zend_property_info *) zend_shared_alloc_get_xlat_entry(prop->prototype);
837+
const zend_property_info *new_prototype = (const zend_property_info *) zend_shared_alloc_get_xlat_entry(prop->prototype);
838838
if (new_prototype) {
839839
prop->prototype = new_prototype;
840840
}
@@ -854,7 +854,7 @@ static zend_property_info *zend_persist_property_info(zend_property_info *prop)
854854
}
855855
}
856856
#endif
857-
zend_property_info *new_prop_info = (zend_property_info *) zend_shared_alloc_get_xlat_entry(hook->prop_info);
857+
const zend_property_info *new_prop_info = (const zend_property_info *) zend_shared_alloc_get_xlat_entry(hook->prop_info);
858858
if (new_prop_info) {
859859
hook->prop_info = new_prop_info;
860860
}
@@ -868,7 +868,7 @@ static zend_property_info *zend_persist_property_info(zend_property_info *prop)
868868

869869
static void zend_persist_class_constant(zval *zv)
870870
{
871-
zend_class_constant *orig_c = Z_PTR_P(zv);
871+
const zend_class_constant *orig_c = Z_PTR_P(zv);
872872
zend_class_constant *c = zend_shared_alloc_get_xlat_entry(orig_c);
873873
zend_class_entry *ce;
874874

@@ -1287,7 +1287,7 @@ void zend_update_parent_ce(zend_class_entry *ce)
12871287
}
12881288

12891289
#ifdef HAVE_JIT
1290-
static void zend_accel_persist_jit_op_array(zend_op_array *op_array, zend_class_entry *ce)
1290+
static void zend_accel_persist_jit_op_array(zend_op_array *op_array, const zend_class_entry *ce)
12911291
{
12921292
if (op_array->type == ZEND_USER_FUNCTION) {
12931293
if (op_array->scope == ce
@@ -1301,7 +1301,7 @@ static void zend_accel_persist_jit_op_array(zend_op_array *op_array, zend_class_
13011301
}
13021302
}
13031303

1304-
static void zend_accel_persist_link_func_info(zend_op_array *op_array, zend_class_entry *ce)
1304+
static void zend_accel_persist_link_func_info(zend_op_array *op_array, const zend_class_entry *ce)
13051305
{
13061306
if (op_array->type == ZEND_USER_FUNCTION
13071307
&& !(op_array->fn_flags & ZEND_ACC_ABSTRACT)) {

ext/opcache/zend_persist_calc.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
} while (0)
4848

4949
static void zend_persist_zval_calc(zval *z);
50-
static void zend_persist_op_array_calc(zval *zv);
50+
static void zend_persist_op_array_calc(const zval *zv);
5151

52-
static void zend_hash_persist_calc(HashTable *ht)
52+
static void zend_hash_persist_calc(const HashTable *ht)
5353
{
5454
if ((HT_FLAGS(ht) & HASH_FLAG_UNINITIALIZED) || ht->nNumUsed == 0) {
5555
return;
@@ -79,7 +79,7 @@ static void zend_persist_ast_calc(zend_ast *ast)
7979
ADD_SIZE(sizeof(zend_ast_zval));
8080
zend_persist_zval_calc(&((zend_ast_zval*)(ast))->val);
8181
} else if (zend_ast_is_list(ast)) {
82-
zend_ast_list *list = zend_ast_get_list(ast);
82+
const zend_ast_list *list = zend_ast_get_list(ast);
8383
ADD_SIZE(sizeof(zend_ast_list) - sizeof(zend_ast *) + sizeof(zend_ast *) * list->children);
8484
for (i = 0; i < list->children; i++) {
8585
if (list->child[i]) {
@@ -125,7 +125,7 @@ static void zend_persist_zval_calc(zval *z)
125125
}
126126
size = zend_shared_memdup_size(Z_ARR_P(z), sizeof(zend_array));
127127
if (size) {
128-
HashTable *ht = Z_ARRVAL_P(z);
128+
const HashTable *ht = Z_ARRVAL_P(z);
129129

130130
ADD_SIZE(size);
131131
zend_hash_persist_calc(ht);
@@ -218,7 +218,7 @@ static void zend_persist_type_calc(zend_type *type)
218218
static void zend_persist_op_array_calc_ex(zend_op_array *op_array)
219219
{
220220
if (op_array->function_name) {
221-
zend_string *old_name = op_array->function_name;
221+
const zend_string *old_name = op_array->function_name;
222222
ADD_INTERNED_STRING(op_array->function_name);
223223
/* Remember old function name, so it can be released multiple times if shared. */
224224
if (op_array->function_name != old_name
@@ -258,7 +258,7 @@ static void zend_persist_op_array_calc_ex(zend_op_array *op_array)
258258

259259
if (op_array->literals) {
260260
zval *p = op_array->literals;
261-
zval *end = p + op_array->last_literal;
261+
const zval *end = p + op_array->last_literal;
262262
ADD_SIZE(sizeof(zval) * op_array->last_literal);
263263
while (p < end) {
264264
zend_persist_zval_calc(p);
@@ -272,7 +272,7 @@ static void zend_persist_op_array_calc_ex(zend_op_array *op_array)
272272
/* ZEND_ACC_PTR_OPS and ZEND_ACC_OVERRIDE use the same value */
273273
if ((op_array->fn_flags & ZEND_ACC_PTR_OPS) && !op_array->function_name) {
274274
zend_op *op = op_array->opcodes;
275-
zend_op *end = op + op_array->last;
275+
const zend_op *end = op + op_array->last;
276276
while (op < end) {
277277
if (op->opcode == ZEND_DECLARE_ATTRIBUTED_CONST) {
278278
HashTable *attributes = Z_PTR_P(RT_CONSTANT(op+1, (op+1)->op1));
@@ -344,7 +344,7 @@ static void zend_persist_op_array_calc_ex(zend_op_array *op_array)
344344
ADD_SIZE(ZEND_ALIGNED_SIZE(zend_extensions_op_array_persist_calc(op_array)));
345345
}
346346

347-
static void zend_persist_op_array_calc(zval *zv)
347+
static void zend_persist_op_array_calc(const zval *zv)
348348
{
349349
zend_op_array *op_array = Z_PTR_P(zv);
350350
ZEND_ASSERT(op_array->type == ZEND_USER_FUNCTION);
@@ -417,7 +417,7 @@ static void zend_persist_property_info_calc(zend_property_info *prop)
417417
}
418418
}
419419

420-
static void zend_persist_class_constant_calc(zval *zv)
420+
static void zend_persist_class_constant_calc(const zval *zv)
421421
{
422422
zend_class_constant *c = Z_PTR_P(zv);
423423

@@ -596,7 +596,7 @@ void zend_persist_class_entry_calc(zend_class_entry *ce)
596596
}
597597
}
598598

599-
static void zend_accel_persist_class_table_calc(HashTable *class_table)
599+
static void zend_accel_persist_class_table_calc(const HashTable *class_table)
600600
{
601601
Bucket *p;
602602

0 commit comments

Comments
 (0)