summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-08-20 00:23:37 +0200
committerAnatol Belski <ab@php.net>2014-08-20 00:23:37 +0200
commit476bdbf85b86a3664ac81b5bca3e3899475f16de (patch)
tree9215eb4349d1b64ce9a130505ad2ddcc24de3b6d /ext
parent61c8af6a9d4376e5f233db775e4a0ebf47942830 (diff)
downloadphp-git-476bdbf85b86a3664ac81b5bca3e3899475f16de.tar.gz
ported opcache
Diffstat (limited to 'ext')
-rw-r--r--ext/opcache/Optimizer/zend_optimizer.c4
-rw-r--r--ext/opcache/ZendAccelerator.c2
-rw-r--r--ext/opcache/ZendAccelerator.h40
-rw-r--r--ext/opcache/zend_accelerator_debug.c2
-rw-r--r--ext/opcache/zend_accelerator_hash.c16
-rw-r--r--ext/opcache/zend_accelerator_hash.h2
-rw-r--r--ext/opcache/zend_accelerator_module.c38
-rw-r--r--ext/opcache/zend_accelerator_util_funcs.c16
-rw-r--r--ext/opcache/zend_shared_alloc.c10
-rw-r--r--ext/opcache/zend_shared_alloc.h2
10 files changed, 66 insertions, 66 deletions
diff --git a/ext/opcache/Optimizer/zend_optimizer.c b/ext/opcache/Optimizer/zend_optimizer.c
index bb41900d2e..a4bf4223a7 100644
--- a/ext/opcache/Optimizer/zend_optimizer.c
+++ b/ext/opcache/Optimizer/zend_optimizer.c
@@ -61,7 +61,7 @@ static int zend_optimizer_get_collected_constant(HashTable *constants, zval *nam
static int zend_optimizer_lookup_cv(zend_op_array *op_array, zend_string* name)
{
int i = 0;
- ulong hash_value = STR_HASH_VAL(name);
+ zend_uint_t hash_value = STR_HASH_VAL(name);
while (i < op_array->last_var) {
if (op_array->vars[i] == name ||
@@ -273,7 +273,7 @@ static void update_op2_const(zend_op_array *op_array,
case ZEND_FETCH_DIM_TMP_VAR:
check_numeric:
{
- ulong index;
+ zend_uint_t index;
if (ZEND_HANDLE_NUMERIC(Z_STR_P(val), index)) {
zval_dtor(val);
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index c6a9e1ce43..b8f9f08b36 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -299,7 +299,7 @@ zend_string *accel_new_interned_string(zend_string *str TSRMLS_DC)
{
/* for now interned strings are supported only for non-ZTS build */
#ifndef ZTS
- ulong h;
+ zend_uint_t h;
uint nIndex;
uint idx;
Bucket *p;
diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h
index 94c467e5fb..79f352e5b7 100644
--- a/ext/opcache/ZendAccelerator.h
+++ b/ext/opcache/ZendAccelerator.h
@@ -157,7 +157,7 @@ typedef struct _zend_persistent_script {
zend_op_array main_op_array;
HashTable function_table;
HashTable class_table;
- long compiler_halt_offset; /* position of __HALT_COMPILER or -1 */
+ zend_int_t compiler_halt_offset; /* position of __HALT_COMPILER or -1 */
int ping_auto_globals_mask; /* which autoglobals are used by the script */
accel_time_t timestamp; /* the script modification time */
zend_bool corrupted;
@@ -170,7 +170,7 @@ typedef struct _zend_persistent_script {
*/
struct zend_persistent_script_dynamic_members {
time_t last_used;
- ulong hits;
+ zend_uint_t hits;
unsigned int memory_consumption;
unsigned int checksum;
time_t revalidate;
@@ -178,12 +178,12 @@ typedef struct _zend_persistent_script {
} zend_persistent_script;
typedef struct _zend_accel_directives {
- long memory_consumption;
- long max_accelerated_files;
+ zend_int_t memory_consumption;
+ zend_int_t max_accelerated_files;
double max_wasted_percentage;
char *user_blacklist_filename;
- long consistency_checks;
- long force_restart_timeout;
+ zend_int_t consistency_checks;
+ zend_int_t force_restart_timeout;
zend_bool use_cwd;
zend_bool ignore_dups;
zend_bool validate_timestamps;
@@ -195,18 +195,18 @@ typedef struct _zend_accel_directives {
zend_bool file_override_enabled;
zend_bool inherited_hack;
zend_bool enable_cli;
- unsigned long revalidate_freq;
- unsigned long file_update_protection;
+ zend_uint_t revalidate_freq;
+ zend_uint_t file_update_protection;
char *error_log;
#ifdef ZEND_WIN32
char *mmap_base;
#endif
char *memory_model;
- long log_verbosity_level;
+ zend_int_t log_verbosity_level;
- long optimization_level;
- long max_file_size;
- long interned_strings_buffer;
+ zend_int_t optimization_level;
+ zend_int_t max_file_size;
+ zend_int_t interned_strings_buffer;
char *restrict_api;
} zend_accel_directives;
@@ -240,12 +240,12 @@ typedef struct _zend_accel_globals {
typedef struct _zend_accel_shared_globals {
/* Cache Data Structures */
- unsigned long hits;
- unsigned long misses;
- unsigned long blacklist_misses;
- unsigned long oom_restarts; /* number of restarts because of out of memory */
- unsigned long hash_restarts; /* number of restarts because of hash overflow */
- unsigned long manual_restarts; /* number of restarts scheduled by opcache_reset() */
+ zend_uint_t hits;
+ zend_uint_t misses;
+ zend_uint_t blacklist_misses;
+ zend_uint_t oom_restarts; /* number of restarts because of out of memory */
+ zend_uint_t hash_restarts; /* number of restarts because of hash overflow */
+ zend_uint_t manual_restarts; /* number of restarts scheduled by opcache_reset() */
zend_accel_hash hash; /* hash table for cached scripts */
zend_accel_hash include_paths; /* used "include_path" values */
@@ -258,8 +258,8 @@ typedef struct _zend_accel_shared_globals {
zend_accel_restart_reason restart_reason;
zend_bool cache_status_before_restart;
#ifdef ZEND_WIN32
- unsigned long mem_usage;
- unsigned long restart_in;
+ zend_uint_t mem_usage;
+ zend_uint_t restart_in;
#endif
zend_bool restart_in_progress;
time_t revalidate_at;
diff --git a/ext/opcache/zend_accelerator_debug.c b/ext/opcache/zend_accelerator_debug.c
index d0198dccb3..dd3193a100 100644
--- a/ext/opcache/zend_accelerator_debug.c
+++ b/ext/opcache/zend_accelerator_debug.c
@@ -57,7 +57,7 @@ void zend_accel_error(int type, const char *format, ...)
}
#ifdef ZTS
- fprintf(fLog, "%s (%lu): ", time_string, (unsigned long)tsrm_thread_id());
+ fprintf(fLog, "%s (" ZEND_UINT_FMT "): ", time_string, (zend_uint_t)tsrm_thread_id());
#else
fprintf(fLog, "%s (%d): ", time_string, getpid());
#endif
diff --git a/ext/opcache/zend_accelerator_hash.c b/ext/opcache/zend_accelerator_hash.c
index b75377d61b..71dd997b79 100644
--- a/ext/opcache/zend_accelerator_hash.c
+++ b/ext/opcache/zend_accelerator_hash.c
@@ -73,8 +73,8 @@ void zend_accel_hash_init(zend_accel_hash *accel_hash, zend_uint hash_size)
*/
zend_accel_hash_entry* zend_accel_hash_update(zend_accel_hash *accel_hash, char *key, zend_uint key_length, zend_bool indirect, void *data)
{
- zend_ulong hash_value;
- zend_ulong index;
+ zend_uint_t hash_value;
+ zend_uint_t index;
zend_accel_hash_entry *entry;
zend_accel_hash_entry *indirect_bucket = NULL;
@@ -142,8 +142,8 @@ zend_accel_hash_entry* zend_accel_hash_update(zend_accel_hash *accel_hash, char
*/
void* zend_accel_hash_find(zend_accel_hash *accel_hash, char *key, zend_uint key_length)
{
- zend_ulong hash_value;
- zend_ulong index;
+ zend_uint_t hash_value;
+ zend_uint_t index;
zend_accel_hash_entry *entry;
hash_value = zend_inline_hash_func(key, key_length);
@@ -170,8 +170,8 @@ void* zend_accel_hash_find(zend_accel_hash *accel_hash, char *key, zend_uint key
*/
zend_accel_hash_entry* zend_accel_hash_find_entry(zend_accel_hash *accel_hash, char *key, zend_uint key_length)
{
- zend_ulong hash_value;
- zend_ulong index;
+ zend_uint_t hash_value;
+ zend_uint_t index;
zend_accel_hash_entry *entry;
hash_value = zend_inline_hash_func(key, key_length);
@@ -195,8 +195,8 @@ zend_accel_hash_entry* zend_accel_hash_find_entry(zend_accel_hash *accel_hash, c
int zend_accel_hash_unlink(zend_accel_hash *accel_hash, char *key, zend_uint key_length)
{
- zend_ulong hash_value;
- zend_ulong index;
+ zend_uint_t hash_value;
+ zend_uint_t index;
zend_accel_hash_entry *entry, *last_entry=NULL;
hash_value = zend_inline_hash_func(key, key_length);
diff --git a/ext/opcache/zend_accelerator_hash.h b/ext/opcache/zend_accelerator_hash.h
index 2de28bffa7..99e92cd194 100644
--- a/ext/opcache/zend_accelerator_hash.h
+++ b/ext/opcache/zend_accelerator_hash.h
@@ -45,7 +45,7 @@
typedef struct _zend_accel_hash_entry zend_accel_hash_entry;
struct _zend_accel_hash_entry {
- zend_ulong hash_value;
+ zend_uint_t hash_value;
char *key;
zend_uint key_length;
zend_accel_hash_entry *next;
diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c
index da2c04fdf7..f6581c1ba6 100644
--- a/ext/opcache/zend_accelerator_module.c
+++ b/ext/opcache/zend_accelerator_module.c
@@ -100,8 +100,8 @@ static int validate_api_restriction(TSRMLS_D)
static ZEND_INI_MH(OnUpdateMemoryConsumption)
{
- long *p;
- long memsize;
+ php_int_t *p;
+ php_int_t memsize;
#ifndef ZTS
char *base = (char *) mh_arg2;
#else
@@ -111,7 +111,7 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption)
/* keep the compiler happy */
(void)entry; (void)new_value_length; (void)mh_arg2; (void)mh_arg3; (void)stage;
- p = (long *) (base + (size_t)mh_arg1);
+ p = (php_int_t *) (base + (size_t)mh_arg1);
memsize = atoi(new_value);
/* sanity check we must use at least 8 MB */
if (memsize < 8) {
@@ -137,8 +137,8 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption)
static ZEND_INI_MH(OnUpdateMaxAcceleratedFiles)
{
- long *p;
- long size;
+ php_int_t *p;
+ php_int_t size;
#ifndef ZTS
char *base = (char *) mh_arg2;
#else
@@ -148,7 +148,7 @@ static ZEND_INI_MH(OnUpdateMaxAcceleratedFiles)
/* keep the compiler happy */
(void)entry; (void)new_value_length; (void)mh_arg2; (void)mh_arg3; (void)stage;
- p = (long *) (base + (size_t)mh_arg1);
+ p = (php_int_t *) (base + (size_t)mh_arg1);
size = atoi(new_value);
/* sanity check we must use a value between MIN_ACCEL_FILES and MAX_ACCEL_FILES */
@@ -183,7 +183,7 @@ static ZEND_INI_MH(OnUpdateMaxAcceleratedFiles)
static ZEND_INI_MH(OnUpdateMaxWastedPercentage)
{
double *p;
- long percentage;
+ php_int_t percentage;
#ifndef ZTS
char *base = (char *) mh_arg2;
#else
@@ -407,33 +407,33 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS)
char buf[32];
php_info_print_table_row(2, "Startup", "OK");
php_info_print_table_row(2, "Shared memory model", zend_accel_get_shared_model());
- snprintf(buf, sizeof(buf), "%ld", ZCSG(hits));
+ snprintf(buf, sizeof(buf), ZEND_UINT_FMT, ZCSG(hits));
php_info_print_table_row(2, "Cache hits", buf);
- snprintf(buf, sizeof(buf), "%ld", ZSMMG(memory_exhausted)?ZCSG(misses):ZCSG(misses)-ZCSG(blacklist_misses));
+ snprintf(buf, sizeof(buf), "%pd", ZSMMG(memory_exhausted)?ZCSG(misses):ZCSG(misses)-ZCSG(blacklist_misses));
php_info_print_table_row(2, "Cache misses", buf);
snprintf(buf, sizeof(buf), "%ld", ZCG(accel_directives).memory_consumption-zend_shared_alloc_get_free_memory()-ZSMMG(wasted_shared_memory));
php_info_print_table_row(2, "Used memory", buf);
- snprintf(buf, sizeof(buf), "%ld", zend_shared_alloc_get_free_memory());
+ snprintf(buf, sizeof(buf), "%pd", zend_shared_alloc_get_free_memory());
php_info_print_table_row(2, "Free memory", buf);
- snprintf(buf, sizeof(buf), "%ld", ZSMMG(wasted_shared_memory));
+ snprintf(buf, sizeof(buf), "%pd", ZSMMG(wasted_shared_memory));
php_info_print_table_row(2, "Wasted memory", buf);
if (ZCSG(interned_strings_start) && ZCSG(interned_strings_end) && ZCSG(interned_strings_top)) {
- snprintf(buf, sizeof(buf), "%ld", ZCSG(interned_strings_top) - ZCSG(interned_strings_start));
+ snprintf(buf, sizeof(buf), "%pd", ZCSG(interned_strings_top) - ZCSG(interned_strings_start));
php_info_print_table_row(2, "Interned Strings Used memory", buf);
- snprintf(buf, sizeof(buf), "%ld", ZCSG(interned_strings_end) - ZCSG(interned_strings_top));
+ snprintf(buf, sizeof(buf), "%pd", ZCSG(interned_strings_end) - ZCSG(interned_strings_top));
php_info_print_table_row(2, "Interned Strings Free memory", buf);
}
snprintf(buf, sizeof(buf), "%ld", ZCSG(hash).num_direct_entries);
php_info_print_table_row(2, "Cached scripts", buf);
snprintf(buf, sizeof(buf), "%ld", ZCSG(hash).num_entries);
php_info_print_table_row(2, "Cached keys", buf);
- snprintf(buf, sizeof(buf), "%ld", ZCSG(hash).max_num_entries);
+ snprintf(buf, sizeof(buf), "%pd", ZCSG(hash).max_num_entries);
php_info_print_table_row(2, "Max keys", buf);
- snprintf(buf, sizeof(buf), "%ld", ZCSG(oom_restarts));
+ snprintf(buf, sizeof(buf), "%pd", ZCSG(oom_restarts));
php_info_print_table_row(2, "OOM restarts", buf);
- snprintf(buf, sizeof(buf), "%ld", ZCSG(hash_restarts));
+ snprintf(buf, sizeof(buf), "%pd", ZCSG(hash_restarts));
php_info_print_table_row(2, "Hash keys restarts", buf);
- snprintf(buf, sizeof(buf), "%ld", ZCSG(manual_restarts));
+ snprintf(buf, sizeof(buf), "%pd", ZCSG(manual_restarts));
php_info_print_table_row(2, "Manual restarts", buf);
}
}
@@ -497,7 +497,7 @@ static int accelerator_get_scripts(zval *return_value TSRMLS_DC)
add_assoc_stringl(&persistent_script_report, "last_used", str, len);
add_assoc_int(&persistent_script_report, "last_used_timestamp", script->dynamic_members.last_used);
if (ZCG(accel_directives).validate_timestamps) {
- add_assoc_int(&persistent_script_report, "timestamp", (long)script->timestamp);
+ add_assoc_int(&persistent_script_report, "timestamp", (zend_int_t)script->timestamp);
}
timerclear(&exec_time);
timerclear(&fetch_time);
@@ -514,7 +514,7 @@ static int accelerator_get_scripts(zval *return_value TSRMLS_DC)
Obtain statistics information regarding code acceleration */
static ZEND_FUNCTION(opcache_get_status)
{
- long reqs;
+ zend_int_t reqs;
zval memory_usage, statistics, scripts;
zend_bool fetch_scripts = 1;
diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c
index 345393f946..c6534ca6c1 100644
--- a/ext/opcache/zend_accelerator_util_funcs.c
+++ b/ext/opcache/zend_accelerator_util_funcs.c
@@ -29,13 +29,13 @@
static zend_uint zend_accel_refcount = ZEND_PROTECTED_REFCOUNT;
-#if SIZEOF_SIZE_T <= SIZEOF_ZEND_INT || defined PHP_WIN32
+#if SIZEOF_SIZE_T <= SIZEOF_ZEND_INT
/* If sizeof(void*) == sizeof(ulong) we can use zend_hash index functions */
-# define accel_xlat_set(old, new) zend_hash_index_update_ptr(&ZCG(bind_hash), (ulong)(zend_uintptr_t)(old), (new))
-# define accel_xlat_get(old) zend_hash_index_find_ptr(&ZCG(bind_hash), (ulong)(zend_uintptr_t)(old))
+# define accel_xlat_set(old, new) zend_hash_index_update_ptr(&ZCG(bind_hash), (zend_uint_t)(zend_uintptr_t)(old), (new))
+# define accel_xlat_get(old) zend_hash_index_find_ptr(&ZCG(bind_hash), (zend_uint_t)(zend_uintptr_t)(old))
#else
-# define accel_xlat_set(old, new) (zend_hash_str_add_ptr(&ZCG(bind_hash), (char*)&(old), sizeof(void*), (ulong)(zend_uintptr_t)(old), (void**)&(new))
-# define accel_xlat_get(old, new) ((new) = zend_hash_str_find_ptr(&ZCG(bind_hash), (char*)&(old), sizeof(void*), (ulong)(zend_uintptr_t)(old), (void**)&(new)))
+# define accel_xlat_set(old, new) (zend_hash_str_add_ptr(&ZCG(bind_hash), (char*)&(old), sizeof(void*), (zend_uint_t)(zend_uintptr_t)(old), (void**)&(new))
+# define accel_xlat_get(old, new) ((new) = zend_hash_str_find_ptr(&ZCG(bind_hash), (char*)&(old), sizeof(void*), (zend_uint_t)(zend_uintptr_t)(old), (void**)&(new)))
#endif
typedef int (*id_function_t)(void *, void *);
@@ -333,7 +333,7 @@ static void zend_hash_clone_zval(HashTable *ht, HashTable *source, int bind)
{
uint idx;
Bucket *p, *q, *r;
- ulong nIndex;
+ zend_uint_t nIndex;
TSRMLS_FETCH();
ht->nTableSize = source->nTableSize;
@@ -412,7 +412,7 @@ static void zend_hash_clone_methods(HashTable *ht, HashTable *source, zend_class
{
uint idx;
Bucket *p, *q;
- ulong nIndex;
+ zend_uint_t nIndex;
zend_class_entry *new_ce;
zend_function *new_prototype;
zend_op_array *new_entry;
@@ -490,7 +490,7 @@ static void zend_hash_clone_prop_info(HashTable *ht, HashTable *source, zend_cla
{
uint idx;
Bucket *p, *q;
- ulong nIndex;
+ zend_uint_t nIndex;
zend_class_entry *new_ce;
zend_property_info *prop_info;
diff --git a/ext/opcache/zend_shared_alloc.c b/ext/opcache/zend_shared_alloc.c
index 0faabee8b2..8a60d75736 100644
--- a/ext/opcache/zend_shared_alloc.c
+++ b/ext/opcache/zend_shared_alloc.c
@@ -288,7 +288,7 @@ static size_t zend_shared_alloc_get_largest_free_block(void)
#define MIN_FREE_MEMORY 64*1024
#define SHARED_ALLOC_FAILED() do { \
- zend_accel_error(ACCEL_LOG_WARNING, "Not enough free shared space to allocate %ld bytes (%ld bytes free)", (long)size, (long)ZSMMG(shared_free)); \
+ zend_accel_error(ACCEL_LOG_WARNING, "Not enough free shared space to allocate %pd bytes (%pd bytes free)", (zend_int_t)size, (zend_int_t)ZSMMG(shared_free)); \
if (zend_shared_alloc_get_largest_free_block() < MIN_FREE_MEMORY) { \
ZSMMG(memory_exhausted) = 1; \
} \
@@ -327,7 +327,7 @@ int zend_shared_memdup_size(void *source, size_t size)
{
void *old_p;
- if ((old_p = zend_hash_index_find_ptr(&xlat_table, (ulong)source)) != NULL) {
+ if ((old_p = zend_hash_index_find_ptr(&xlat_table, (zend_uint_t)source)) != NULL) {
/* we already duplicated this pointer */
return 0;
}
@@ -339,7 +339,7 @@ void *_zend_shared_memdup(void *source, size_t size, zend_bool free_source TSRML
{
void *old_p, *retval;
- if ((old_p = zend_hash_index_find_ptr(&xlat_table, (ulong)source)) != NULL) {
+ if ((old_p = zend_hash_index_find_ptr(&xlat_table, (zend_uint_t)source)) != NULL) {
/* we already duplicated this pointer */
return old_p;
}
@@ -431,14 +431,14 @@ void zend_shared_alloc_clear_xlat_table(void)
void zend_shared_alloc_register_xlat_entry(const void *old, const void *new)
{
- zend_hash_index_update_ptr(&xlat_table, (ulong)old, (void*)new);
+ zend_hash_index_update_ptr(&xlat_table, (zend_uint_t)old, (void*)new);
}
void *zend_shared_alloc_get_xlat_entry(const void *old)
{
void *retval;
- if ((retval = zend_hash_index_find_ptr(&xlat_table, (ulong)old)) == NULL) {
+ if ((retval = zend_hash_index_find_ptr(&xlat_table, (zend_uint_t)old)) == NULL) {
return NULL;
}
return retval;
diff --git a/ext/opcache/zend_shared_alloc.h b/ext/opcache/zend_shared_alloc.h
index 57ea8d3fdd..b16b1a30dd 100644
--- a/ext/opcache/zend_shared_alloc.h
+++ b/ext/opcache/zend_shared_alloc.h
@@ -130,7 +130,7 @@ int zend_shared_memdup_size(void *p, size_t size);
typedef union _align_test {
void *ptr;
double dbl;
- long lng;
+ zend_int_t lng;
} align_test;
#if ZEND_GCC_VERSION >= 2000