Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ext/opcache/zend_accelerator_blacklist.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void zend_accel_blacklist_shutdown(zend_blacklist *blacklist)
return;
}

zend_blacklist_entry *p = blacklist->entries, *end = blacklist->entries + blacklist->pos;
const zend_blacklist_entry *p = blacklist->entries, *end = blacklist->entries + blacklist->pos;
while (p<end) {
free(p->path);
p++;
Expand Down Expand Up @@ -336,10 +336,10 @@ void zend_accel_blacklist_load(zend_blacklist *blacklist, char *filename)
zend_accel_blacklist_update_regexp(blacklist);
}

bool zend_accel_blacklist_is_blacklisted(zend_blacklist *blacklist, char *verify_path, size_t verify_path_len)
bool zend_accel_blacklist_is_blacklisted(const zend_blacklist *blacklist, const char *verify_path, size_t verify_path_len)
{
int ret = 0;
zend_regexp_list *regexp_list_it = blacklist->regexp_list;
const zend_regexp_list *regexp_list_it = blacklist->regexp_list;
pcre2_match_context *mctx = php_pcre_mctx();

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

void zend_accel_blacklist_apply(zend_blacklist *blacklist, blacklist_apply_func_arg_t func, void *argument)
void zend_accel_blacklist_apply(const zend_blacklist *blacklist, blacklist_apply_func_arg_t func, void *argument)
{
int i;

Expand Down
4 changes: 2 additions & 2 deletions ext/opcache/zend_accelerator_blacklist.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void zend_accel_blacklist_init(zend_blacklist *blacklist);
void zend_accel_blacklist_shutdown(zend_blacklist *blacklist);

void zend_accel_blacklist_load(zend_blacklist *blacklist, char *filename);
bool zend_accel_blacklist_is_blacklisted(zend_blacklist *blacklist, char *verify_path, size_t verify_path_len);
void zend_accel_blacklist_apply(zend_blacklist *blacklist, blacklist_apply_func_arg_t func, void *argument);
bool zend_accel_blacklist_is_blacklisted(const zend_blacklist *blacklist, const char *verify_path, size_t verify_path_len);
void zend_accel_blacklist_apply(const zend_blacklist *blacklist, blacklist_apply_func_arg_t func, void *argument);

#endif /* ZEND_ACCELERATOR_BLACKLIST_H */
12 changes: 6 additions & 6 deletions ext/opcache/zend_accelerator_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ zend_accel_hash_entry* zend_accel_hash_update(zend_accel_hash *accel_hash, zend_
return entry;
}

static zend_always_inline void* zend_accel_hash_find_ex(zend_accel_hash *accel_hash, zend_string *key, int data)
static zend_always_inline void* zend_accel_hash_find_ex(const zend_accel_hash *accel_hash, zend_string *key, bool data)
{
zend_ulong index;
zend_accel_hash_entry *entry;
Expand Down Expand Up @@ -176,20 +176,20 @@ static zend_always_inline void* zend_accel_hash_find_ex(zend_accel_hash *accel_h
/* Returns the data associated with key on success
* Returns NULL if data doesn't exist
*/
void* zend_accel_hash_find(zend_accel_hash *accel_hash, zend_string *key)
void* zend_accel_hash_find(const zend_accel_hash *accel_hash, zend_string *key)
{
return zend_accel_hash_find_ex(accel_hash, key, 1);
return zend_accel_hash_find_ex(accel_hash, key, true);
}

/* Returns the hash entry associated with key on success
* Returns NULL if it doesn't exist
*/
zend_accel_hash_entry* zend_accel_hash_find_entry(zend_accel_hash *accel_hash, zend_string *key)
zend_accel_hash_entry* zend_accel_hash_find_entry(const zend_accel_hash *accel_hash, zend_string *key)
{
return (zend_accel_hash_entry *)zend_accel_hash_find_ex(accel_hash, key, 0);
return (zend_accel_hash_entry *)zend_accel_hash_find_ex(accel_hash, key, false);
}

int zend_accel_hash_unlink(zend_accel_hash *accel_hash, zend_string *key)
zend_result zend_accel_hash_unlink(zend_accel_hash *accel_hash, zend_string *key)
{
zend_ulong hash_value;
zend_ulong index;
Expand Down
8 changes: 4 additions & 4 deletions ext/opcache/zend_accelerator_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ zend_accel_hash_entry* zend_accel_hash_update(
void *data);

void* zend_accel_hash_find(
zend_accel_hash *accel_hash,
const zend_accel_hash *accel_hash,
zend_string *key);

zend_accel_hash_entry* zend_accel_hash_find_entry(
zend_accel_hash *accel_hash,
const zend_accel_hash *accel_hash,
zend_string *key);

int zend_accel_hash_unlink(
zend_result zend_accel_hash_unlink(
zend_accel_hash *accel_hash,
zend_string *key);

static inline bool zend_accel_hash_is_full(zend_accel_hash *accel_hash)
static inline bool zend_accel_hash_is_full(const zend_accel_hash *accel_hash)
{
if (accel_hash->num_entries == accel_hash->max_num_entries) {
return true;
Expand Down
36 changes: 15 additions & 21 deletions ext/opcache/zend_accelerator_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "SAPI.h"
#include "zend_virtual_cwd.h"
#include "ext/standard/info.h"
#include "ext/standard/php_filestat.h"
#include "ext/date/php_date.h"
#include "opcache_arginfo.h"

Expand Down Expand Up @@ -62,7 +61,7 @@ static zif_handler orig_file_exists = NULL;
static zif_handler orig_is_file = NULL;
static zif_handler orig_is_readable = NULL;

static int validate_api_restriction(void)
static bool validate_api_restriction(void)
{
if (ZCG(accel_directives).restrict_api && *ZCG(accel_directives).restrict_api) {
size_t len = strlen(ZCG(accel_directives).restrict_api);
Expand All @@ -71,10 +70,10 @@ static int validate_api_restriction(void)
strlen(SG(request_info).path_translated) < len ||
memcmp(SG(request_info).path_translated, ZCG(accel_directives).restrict_api, len) != 0) {
zend_error(E_WARNING, ACCELERATOR_PRODUCT_NAME " API is restricted by \"restrict_api\" configuration directive");
return 0;
return false;
}
}
return 1;
return true;
}

static ZEND_INI_MH(OnUpdateMemoryConsumption)
Expand Down Expand Up @@ -178,8 +177,8 @@ static ZEND_INI_MH(OnEnable)
}
return FAILURE;
} else {
*p = 0;
ZCG(accelerator_enabled) = 0;
*p = false;
ZCG(accelerator_enabled) = false;
return SUCCESS;
}
}
Expand Down Expand Up @@ -363,7 +362,7 @@ ZEND_INI_BEGIN()
#endif
ZEND_INI_END()

static int filename_is_in_cache(zend_string *filename)
static bool filename_is_in_cache(zend_string *filename)
{
zend_string *key;

Expand All @@ -373,27 +372,26 @@ static int filename_is_in_cache(zend_string *filename)
if (persistent_script && !persistent_script->corrupted) {
if (ZCG(accel_directives).validate_timestamps) {
zend_file_handle handle;
int ret;
bool ret;

zend_stream_init_filename_ex(&handle, filename);
ret = validate_timestamp_and_record_ex(persistent_script, &handle) == SUCCESS
? 1 : 0;
ret = validate_timestamp_and_record_ex(persistent_script, &handle) == SUCCESS;
zend_destroy_file_handle(&handle);
return ret;
}

return 1;
return true;
}
}

return 0;
return false;
}

static int filename_is_in_file_cache(zend_string *filename)
static bool filename_is_in_file_cache(zend_string *filename)
{
zend_string *realpath = zend_resolve_path(filename);
if (!realpath) {
return 0;
return false;
}

zend_file_handle handle;
Expand All @@ -406,7 +404,7 @@ static int filename_is_in_file_cache(zend_string *filename)
return result != NULL;
}

static int accel_file_in_cache(INTERNAL_FUNCTION_PARAMETERS)
static bool accel_file_in_cache(INTERNAL_FUNCTION_PARAMETERS)
{
if (ZEND_NUM_ARGS() == 1) {
zval *zv = ZEND_CALL_ARG(execute_data , 1);
Expand All @@ -415,7 +413,7 @@ static int accel_file_in_cache(INTERNAL_FUNCTION_PARAMETERS)
return filename_is_in_cache(Z_STR_P(zv));
}
}
return 0;
return false;
}

static ZEND_NAMED_FUNCTION(accel_file_exists)
Expand Down Expand Up @@ -947,11 +945,7 @@ ZEND_FUNCTION(opcache_invalidate)
RETURN_FALSE;
}

if (zend_accel_invalidate(script_name, force) == SUCCESS) {
RETURN_TRUE;
} else {
RETURN_FALSE;
}
RETURN_BOOL(zend_accel_invalidate(script_name, force) == SUCCESS);
}

/* {{{ Prevents JIT on function. Call it before the first invocation of the given function. */
Expand Down
52 changes: 26 additions & 26 deletions ext/opcache/zend_accelerator_util_funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ zend_persistent_script* create_persistent_script(void)
return persistent_script;
}

void free_persistent_script(zend_persistent_script *persistent_script, int destroy_elements)
void free_persistent_script(zend_persistent_script *persistent_script, bool destroy_elements)
{
if (!destroy_elements) {
/* Both the keys and values have been transferred into the global tables.
Expand Down Expand Up @@ -105,7 +105,7 @@ void zend_accel_move_user_classes(HashTable *src, uint32_t count, zend_script *s
{
Bucket *p, *end;
HashTable *dst;
zend_string *filename;
const zend_string *filename;
dtor_func_t orig_dtor;
zend_class_entry *ce;

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

static zend_always_inline void _zend_accel_function_hash_copy(HashTable *target, HashTable *source, bool call_observers)
static zend_always_inline void _zend_accel_function_hash_copy(HashTable *target, const HashTable *source, bool call_observers)
{
zend_function *function1, *function2;
Bucket *p, *end;
const Bucket *p, *end;
zval *t;

zend_hash_extend(target, target->nNumUsed + source->nNumUsed, 0);
Expand Down Expand Up @@ -174,20 +174,20 @@ static zend_always_inline void _zend_accel_function_hash_copy(HashTable *target,
}
}

static zend_always_inline void zend_accel_function_hash_copy(HashTable *target, HashTable *source)
static zend_always_inline void zend_accel_function_hash_copy(HashTable *target, const HashTable *source)
{
_zend_accel_function_hash_copy(target, source, false);
}

static zend_never_inline void zend_accel_function_hash_copy_notify(HashTable *target, HashTable *source)
static zend_never_inline void zend_accel_function_hash_copy_notify(HashTable *target, const HashTable *source)
{
_zend_accel_function_hash_copy(target, source, true);
}

static zend_always_inline void _zend_accel_class_hash_copy(HashTable *target, HashTable *source, bool call_observers)
static zend_always_inline void _zend_accel_class_hash_copy(HashTable *target, const HashTable *source, bool call_observers)
{
Bucket *p, *end;
zval *t;
const Bucket *p, *end;
const zval *t;

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

static zend_always_inline void zend_accel_class_hash_copy(HashTable *target, HashTable *source)
static zend_always_inline void zend_accel_class_hash_copy(HashTable *target, const HashTable *source)
{
_zend_accel_class_hash_copy(target, source, false);
}

static zend_never_inline void zend_accel_class_hash_copy_notify(HashTable *target, HashTable *source)
static zend_never_inline void zend_accel_class_hash_copy_notify(HashTable *target, const HashTable *source)
{
_zend_accel_class_hash_copy(target, source, true);
}

void zend_accel_build_delayed_early_binding_list(zend_persistent_script *persistent_script)
{
zend_op_array *op_array = &persistent_script->script.main_op_array;
const zend_op_array *op_array = &persistent_script->script.main_op_array;
if (!(op_array->fn_flags & ZEND_ACC_EARLY_BINDING)) {
return;
}

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

for (zend_op *opline = op_array->opcodes; opline < end; opline++) {
if (opline->opcode == ZEND_DECLARE_CLASS_DELAYED) {
zval *lcname = RT_CONSTANT(opline, opline->op1);
const zval *lcname = RT_CONSTANT(opline, opline->op1);
early_binding->lcname = zend_string_copy(Z_STR_P(lcname));
early_binding->rtd_key = zend_string_copy(Z_STR_P(lcname + 1));
early_binding->lc_parent_name =
Expand All @@ -275,19 +275,19 @@ void zend_accel_build_delayed_early_binding_list(zend_persistent_script *persist
}
}

void zend_accel_finalize_delayed_early_binding_list(zend_persistent_script *persistent_script)
void zend_accel_finalize_delayed_early_binding_list(const zend_persistent_script *persistent_script)
{
if (!persistent_script->num_early_bindings) {
return;
}

zend_early_binding *early_binding = persistent_script->early_bindings;
zend_early_binding *early_binding_end = early_binding + persistent_script->num_early_bindings;
zend_op_array *op_array = &persistent_script->script.main_op_array;
zend_op *opline_end = op_array->opcodes + op_array->last;
const zend_early_binding *early_binding_end = early_binding + persistent_script->num_early_bindings;
const zend_op_array *op_array = &persistent_script->script.main_op_array;
const zend_op *opline_end = op_array->opcodes + op_array->last;
for (zend_op *opline = op_array->opcodes; opline < opline_end; opline++) {
if (opline->opcode == ZEND_DECLARE_CLASS_DELAYED) {
zend_string *rtd_key = Z_STR_P(RT_CONSTANT(opline, opline->op1) + 1);
const zend_string *rtd_key = Z_STR_P(RT_CONSTANT(opline, opline->op1) + 1);
/* Skip early_binding entries that don't match, maybe their DECLARE_CLASS_DELAYED
* was optimized away. */
while (!zend_string_equals(early_binding->rtd_key, rtd_key)) {
Expand All @@ -310,7 +310,7 @@ void zend_accel_free_delayed_early_binding_list(zend_persistent_script *persiste
{
if (persistent_script->num_early_bindings) {
for (uint32_t i = 0; i < persistent_script->num_early_bindings; i++) {
zend_early_binding *early_binding = &persistent_script->early_bindings[i];
const zend_early_binding *early_binding = &persistent_script->early_bindings[i];
zend_string_release(early_binding->lcname);
zend_string_release(early_binding->rtd_key);
zend_string_release(early_binding->lc_parent_name);
Expand All @@ -322,7 +322,7 @@ void zend_accel_free_delayed_early_binding_list(zend_persistent_script *persiste
}

static void zend_accel_do_delayed_early_binding(
zend_persistent_script *persistent_script, zend_op_array *op_array)
const zend_persistent_script *persistent_script, zend_op_array *op_array)
{
ZEND_ASSERT(!ZEND_MAP_PTR(op_array->run_time_cache));
ZEND_ASSERT(op_array->fn_flags & ZEND_ACC_HEAP_RT_CACHE);
Expand All @@ -336,7 +336,7 @@ static void zend_accel_do_delayed_early_binding(
CG(compiled_filename) = persistent_script->script.filename;
CG(in_compilation) = 1;
for (uint32_t i = 0; i < persistent_script->num_early_bindings; i++) {
zend_early_binding *early_binding = &persistent_script->early_bindings[i];
const zend_early_binding *early_binding = &persistent_script->early_bindings[i];
zend_class_entry *ce = zend_hash_find_ex_ptr(EG(class_table), early_binding->lcname, 1);
if (!ce) {
zval *zv = zend_hash_find_known_hash(EG(class_table), early_binding->rtd_key);
Expand All @@ -358,7 +358,7 @@ static void zend_accel_do_delayed_early_binding(
CG(in_compilation) = orig_in_compilation;
}

zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script, int from_shared_memory)
zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script, bool from_shared_memory)
{
zend_op_array *op_array;

Expand Down Expand Up @@ -448,7 +448,7 @@ zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script,
#define ADLER32_SCALAR_DO8(buf, i) ADLER32_SCALAR_DO4(buf, i); ADLER32_SCALAR_DO4(buf, i + 4);
#define ADLER32_SCALAR_DO16(buf) ADLER32_SCALAR_DO8(buf, 0); ADLER32_SCALAR_DO8(buf, 8);

static zend_always_inline void adler32_do16_loop(unsigned char *buf, unsigned char *end, unsigned int *s1_out, unsigned int *s2_out)
static zend_always_inline void adler32_do16_loop(unsigned char *buf, const unsigned char *end, unsigned int *s1_out, unsigned int *s2_out)
{
unsigned int s1 = *s1_out;
unsigned int s2 = *s2_out;
Expand Down
Loading