*strict_class = 1;
ret = 1;
} else {
- if (error) zend_spprintf(error, 0, "class '%.*s' not found", name_len, ZSTR_VAL(name));
+ if (error) zend_spprintf(error, 0, "class '%.*s' not found", (int)name_len, ZSTR_VAL(name));
}
ZSTR_ALLOCA_FREE(lcname, use_heap);
return ret;
zend_mm_heap *heap;
zend_mm_chunk *next;
zend_mm_chunk *prev;
- int free_pages; /* number of free pages */
- int free_tail; /* number of free pages at the end of chunk */
- int num;
+ uint32_t free_pages; /* number of free pages */
+ uint32_t free_tail; /* number of free pages at the end of chunk */
+ uint32_t num;
char reserve[64 - (sizeof(void*) * 3 + sizeof(int) * 3)];
zend_mm_heap heap_slot; /* used only in main chunk */
zend_mm_page_map free_map; /* 512 bits or 64 bytes */
((void*)(((zend_mm_page*)(chunk)) + (page_num)))
#define _BIN_DATA_SIZE(num, size, elements, pages, x, y) size,
-static const unsigned int bin_data_size[] = {
+static const uint32_t bin_data_size[] = {
ZEND_MM_BINS_INFO(_BIN_DATA_SIZE, x, y)
};
#define _BIN_DATA_ELEMENTS(num, size, elements, pages, x, y) elements,
-static const int bin_elements[] = {
+static const uint32_t bin_elements[] = {
ZEND_MM_BINS_INFO(_BIN_DATA_ELEMENTS, x, y)
};
#define _BIN_DATA_PAGES(num, size, elements, pages, x, y) pages,
-static const int bin_pages[] = {
+static const uint32_t bin_pages[] = {
ZEND_MM_BINS_INFO(_BIN_DATA_PAGES, x, y)
};
/**************/
#if ZEND_DEBUG
-static void *zend_mm_alloc_pages(zend_mm_heap *heap, int pages_count, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+static void *zend_mm_alloc_pages(zend_mm_heap *heap, uint32_t pages_count, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
#else
-static void *zend_mm_alloc_pages(zend_mm_heap *heap, int pages_count ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+static void *zend_mm_alloc_pages(zend_mm_heap *heap, uint32_t pages_count ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
#endif
{
zend_mm_chunk *chunk = heap->main_chunk;
- int page_num, len;
+ uint32_t page_num, len;
while (1) {
if (UNEXPECTED(chunk->free_pages < pages_count)) {
} else {
/* Best-Fit Search */
int best = -1;
- int best_len = ZEND_MM_PAGES;
- int free_tail = chunk->free_tail;
+ uint32_t best_len = ZEND_MM_PAGES;
+ uint32_t free_tail = chunk->free_tail;
zend_mm_bitset *bitset = chunk->free_map;
zend_mm_bitset tmp = *(bitset++);
- int i = 0;
+ uint32_t i = 0;
while (1) {
/* skip allocated blocks */
}
}
-static zend_always_inline void zend_mm_free_pages_ex(zend_mm_heap *heap, zend_mm_chunk *chunk, int page_num, int pages_count, int free_chunk)
+static zend_always_inline void zend_mm_free_pages_ex(zend_mm_heap *heap, zend_mm_chunk *chunk, uint32_t page_num, uint32_t pages_count, int free_chunk)
{
chunk->free_pages += pages_count;
zend_mm_bitset_reset_range(chunk->free_map, page_num, pages_count);
#define ZEND_MM_SMALL_SIZE_TO_BIN(size) zend_mm_small_size_to_bin(size)
-static zend_never_inline void *zend_mm_alloc_small_slow(zend_mm_heap *heap, int bin_num ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+static zend_never_inline void *zend_mm_alloc_small_slow(zend_mm_heap *heap, uint32_t bin_num ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
{
zend_mm_chunk *chunk;
int page_num;
page_num = ZEND_MM_ALIGNED_OFFSET(bin, ZEND_MM_CHUNK_SIZE) / ZEND_MM_PAGE_SIZE;
chunk->map[page_num] = ZEND_MM_SRUN(bin_num);
if (bin_pages[bin_num] > 1) {
- int i = 1;
+ uint32_t i = 1;
+
do {
chunk->map[page_num+i] = ZEND_MM_NRUN(bin_num, i);
i++;
size_t page_offset;
int page_num;
zend_mm_page_info info;
- int i, has_free_pages, free_counter;
+ uint32_t i, free_counter;
+ int has_free_pages;
size_t collected = 0;
#if ZEND_MM_CUSTOM
/* Leak detection */
/******************/
-static zend_long zend_mm_find_leaks_small(zend_mm_chunk *p, int i, int j, zend_leak_info *leak)
+static zend_long zend_mm_find_leaks_small(zend_mm_chunk *p, uint32_t i, uint32_t j, zend_leak_info *leak)
{
int empty = 1;
zend_long count = 0;
return count;
}
-static zend_long zend_mm_find_leaks(zend_mm_heap *heap, zend_mm_chunk *p, int i, zend_leak_info *leak)
+static zend_long zend_mm_find_leaks(zend_mm_heap *heap, zend_mm_chunk *p, uint32_t i, zend_leak_info *leak)
{
zend_long count = 0;
zend_leak_info leak;
zend_long repeated = 0;
uint32_t total = 0;
- int i, j;
+ uint32_t i, j;
/* find leaked huge blocks and free them */
list = heap->huge_list;
{
zend_live_range *range = op_array->live_range + offset;
- if (range->start == end && offset == op_array->last_live_range - 1) {
+ if (range->start == end && offset == (uint32_t)op_array->last_live_range - 1) {
op_array->last_live_range--;
} else {
range->end = end;
zend_op *get_next_op(zend_op_array *op_array);
void init_op(zend_op *op);
-int get_next_op_number(zend_op_array *op_array);
+uint32_t get_next_op_number(zend_op_array *op_array);
ZEND_API int pass_two(zend_op_array *op_array);
zend_brk_cont_element *get_next_brk_cont_element(void);
ZEND_API zend_bool zend_is_compiling(void);
#define ZEND_HASH_INDEX_FIND(_ht, _h, _ret, _not_found) do { \
if (EXPECTED((_ht)->u.flags & HASH_FLAG_PACKED)) { \
- if (EXPECTED((_h) < (_ht)->nNumUsed)) { \
+ if (EXPECTED((zend_ulong)(_h) < (zend_ulong)(_ht)->nNumUsed)) { \
_ret = &_ht->arData[_h].val; \
if (UNEXPECTED(Z_TYPE_P(_ret) == IS_UNDEF)) { \
goto _not_found; \
/* check if the NULL byte is after the __HALT_COMPILER(); */
pos2 = LANG_SCNG(script_org);
- while (pos1 - pos2 >= sizeof("__HALT_COMPILER();")-1) {
+ while ((size_t)(pos1 - pos2) >= sizeof("__HALT_COMPILER();")-1) {
pos2 = memchr(pos2, '_', pos1 - pos2);
if (!pos2) break;
pos2++;
/* The shebang line was read, get the current position to obtain the buffer start */
if (CG(start_lineno) == 2 && file_handle->type == ZEND_HANDLE_FP && file_handle->handle.fp) {
- if ((offset = ftell(file_handle->handle.fp)) == -1) {
+ if ((offset = ftell(file_handle->handle.fp)) == (size_t)-1) {
offset = 0;
}
}
SCNG(yy_in) = file_handle;
SCNG(yy_start) = NULL;
- if (size != -1) {
+ if (size != (size_t)-1) {
if (CG(multibyte)) {
SCNG(script_org) = (unsigned char*)buf;
SCNG(script_org_size) = size;
/* check if the NULL byte is after the __HALT_COMPILER(); */
pos2 = LANG_SCNG(script_org);
- while (pos1 - pos2 >= sizeof("__HALT_COMPILER();")-1) {
+ while ((size_t)(pos1 - pos2) >= sizeof("__HALT_COMPILER();")-1) {
pos2 = memchr(pos2, '_', pos1 - pos2);
if (!pos2) break;
pos2++;
/* The shebang line was read, get the current position to obtain the buffer start */
if (CG(start_lineno) == 2 && file_handle->type == ZEND_HANDLE_FP && file_handle->handle.fp) {
- if ((offset = ftell(file_handle->handle.fp)) == -1) {
+ if ((offset = ftell(file_handle->handle.fp)) == (size_t)-1) {
offset = 0;
}
}
SCNG(yy_in) = file_handle;
SCNG(yy_start) = NULL;
- if (size != -1) {
+ if (size != (size_t)-1) {
if (CG(multibyte)) {
SCNG(script_org) = (unsigned char*)buf;
SCNG(script_org_size) = size;
return next_op;
}
-int get_next_op_number(zend_op_array *op_array)
+uint32_t get_next_op_number(zend_op_array *op_array)
{
return op_array->last;
}
static void zend_signal_handler(int signo, siginfo_t *siginfo, void *context)
{
int errno_save = errno;
- struct sigaction sa = {{0}};
+ struct sigaction sa;
sigset_t sigset;
zend_signal_entry_t p_sig = SIGG(handlers)[signo-1];
+ memset(&sa, 0, sizeof(sa));
if (p_sig.handler == SIG_DFL) { /* raise default handler */
if (sigaction(signo, NULL, &sa) == 0) {
sa.sa_handler = SIG_DFL;
* Register a signal handler that will be deferred in critical sections */
ZEND_API int zend_sigaction(int signo, const struct sigaction *act, struct sigaction *oldact)
{
- struct sigaction sa = {{0}};
+ struct sigaction sa;
sigset_t sigset;
+ memset(&sa, 0, sizeof(sa));
if (oldact != NULL) {
oldact->sa_flags = SIGG(handlers)[signo-1].flags;
oldact->sa_handler = (void *) SIGG(handlers)[signo-1].handler;
* Register a signal handler that will be deferred in critical sections */
ZEND_API int zend_signal(int signo, void (*handler)(int))
{
- struct sigaction sa = {{0}};
+ struct sigaction sa;
+ memset(&sa, 0, sizeof(sa));
sa.sa_flags = 0;
sa.sa_handler = handler;
sa.sa_mask = global_sigmask;
*/
static int zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void*))
{
- struct sigaction sa = {{0}};
+ struct sigaction sa;
+ memset(&sa, 0, sizeof(sa));
if (sigaction(signo, NULL, &sa) == 0) {
if ((sa.sa_flags & SA_SIGINFO) && sa.sa_sigaction == handler) {
return FAILURE;
* Install our signal handlers, per request */
void zend_signal_activate(void)
{
- int x;
+ size_t x;
memcpy(&SIGG(handlers), &global_orig_handlers, sizeof(global_orig_handlers));
{
if (SIGG(check)) {
- int x;
- struct sigaction sa = {{0}};
+ size_t x;
+ struct sigaction sa;
+
+ memset(&sa, 0, sizeof(sa));
if (SIGG(depth) != 0) {
zend_error(E_CORE_WARNING, "zend_signal: shutdown with non-zero blocking depth (%d)", SIGG(depth));
}
void zend_signal_init(void) /* {{{ */
{
int signo;
- struct sigaction sa = {{0}};
+ struct sigaction sa;
+ memset(&sa, 0, sizeof(sa));
/* Save previously registered signal handlers into orig_handlers */
memset(&global_orig_handlers, 0, sizeof(global_orig_handlers));
for (signo = 1; signo < NSIG; ++signo) {
j = sizeof(ULong);
for(k = 0;
- sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i;
+ sizeof(Bigint) - sizeof(ULong) - sizeof(int) + (size_t)j <= (size_t)i;
j <<= 1)
k++;
r = (int*)Balloc(k);
ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
{
uint32_t throw_op_num = EG(opline_before_exception) - EX(func)->op_array.opcodes;
- uint32_t i, current_try_catch_offset = (uint32_t) -1;
+ int i, current_try_catch_offset = -1;
{
const zend_op *exc_opline = EG(opline_before_exception);
static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
uint32_t throw_op_num = EG(opline_before_exception) - EX(func)->op_array.opcodes;
- uint32_t i, current_try_catch_offset = (uint32_t) -1;
+ int i, current_try_catch_offset = -1;
{
const zend_op *exc_opline = EG(opline_before_exception);