diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c index 3fc97577abdea..621e60c6f19a3 100644 --- a/ext/ffi/ffi.c +++ b/ext/ffi/ffi.c @@ -220,14 +220,14 @@ static zend_internal_function zend_ffi_type_fn; /* forward declarations */ static void _zend_ffi_type_dtor(zend_ffi_type *type); static void zend_ffi_finalize_type(zend_ffi_dcl *dcl); -static bool zend_ffi_is_same_type(zend_ffi_type *type1, zend_ffi_type *type2); +static bool zend_ffi_is_same_type(const zend_ffi_type *type1, const zend_ffi_type *type2); static zend_ffi_type *zend_ffi_remember_type(zend_ffi_type *type); static char *zend_ffi_parse_directives(const char *filename, char *code_pos, char **scope_name, char **lib, bool preload); static ZEND_FUNCTION(ffi_trampoline); static ZEND_COLD void zend_ffi_return_unsupported(zend_ffi_type *type); static ZEND_COLD void zend_ffi_pass_unsupported(zend_ffi_type *type); -static ZEND_COLD void zend_ffi_assign_incompatible(zval *arg, zend_ffi_type *type); -static bool zend_ffi_is_compatible_type(zend_ffi_type *dst_type, zend_ffi_type *src_type); +static ZEND_COLD void zend_ffi_assign_incompatible(const zval *arg, const zend_ffi_type *type); +static bool zend_ffi_is_compatible_type(const zend_ffi_type *dst_type, const zend_ffi_type *src_type); #if FFI_CLOSURES static void *zend_ffi_create_callback(zend_ffi_type *type, zval *value); @@ -270,7 +270,7 @@ static zend_object *zend_ffi_cdata_new(zend_class_entry *class_type) /* {{{ */ } /* }}} */ -static bool zend_ffi_func_ptr_are_compatible(zend_ffi_type *dst_type, zend_ffi_type *src_type) /* {{{ */ +static bool zend_ffi_func_ptr_are_compatible(const zend_ffi_type *dst_type, const zend_ffi_type *src_type) /* {{{ */ { uint32_t dst_argc, src_argc, i; zend_ffi_type *dst_arg, *src_arg; @@ -313,7 +313,7 @@ static bool zend_ffi_func_ptr_are_compatible(zend_ffi_type *dst_type, zend_ffi_t } /* }}} */ -static bool zend_ffi_is_compatible_type(zend_ffi_type *dst_type, zend_ffi_type *src_type) /* {{{ */ +static bool zend_ffi_is_compatible_type(const zend_ffi_type *dst_type, const zend_ffi_type *src_type) /* {{{ */ { while (1) { if (dst_type == src_type) { @@ -354,7 +354,7 @@ static bool zend_ffi_is_compatible_type(zend_ffi_type *dst_type, zend_ffi_type * } /* }}} */ -static ffi_type* zend_ffi_face_struct_add_fields(ffi_type* t, zend_ffi_type *type, int *i, size_t size) +static ffi_type* zend_ffi_face_struct_add_fields(ffi_type* t, const zend_ffi_type *type, int *i, size_t size) { zend_ffi_field *field; @@ -418,7 +418,7 @@ static ffi_type* zend_ffi_face_struct_add_fields(ffi_type* t, zend_ffi_type *typ return t; } -static ffi_type *zend_ffi_make_fake_struct_type(zend_ffi_type *type) /* {{{ */ +static ffi_type *zend_ffi_make_fake_struct_type(const zend_ffi_type *type) /* {{{ */ { /* for unions we use only the first field */ uint32_t num_fields = !(type->attr & ZEND_FFI_ATTR_UNION) ? @@ -438,7 +438,7 @@ static ffi_type *zend_ffi_make_fake_struct_type(zend_ffi_type *type) /* {{{ */ } /* }}} */ -static ffi_type *zend_ffi_get_type(zend_ffi_type *type) /* {{{ */ +static ffi_type *zend_ffi_get_type(const zend_ffi_type *type) /* {{{ */ { zend_ffi_type_kind kind = type->kind; @@ -633,7 +633,7 @@ static zend_always_inline void zend_ffi_cdata_to_zval(zend_ffi_cdata *cdata, voi } /* }}} */ -static uint64_t zend_ffi_bit_field_read(void *ptr, zend_ffi_field *field) /* {{{ */ +static uint64_t zend_ffi_bit_field_read(void *ptr, const zend_ffi_field *field) /* {{{ */ { size_t bit = field->first_bit; size_t last_bit = bit + field->bits - 1; @@ -675,7 +675,7 @@ static uint64_t zend_ffi_bit_field_read(void *ptr, zend_ffi_field *field) /* {{{ } /* }}} */ -static void zend_ffi_bit_field_to_zval(void *ptr, zend_ffi_field *field, zval *rv) /* {{{ */ +static void zend_ffi_bit_field_to_zval(void *ptr, const zend_ffi_field *field, zval *rv) /* {{{ */ { uint64_t val = zend_ffi_bit_field_read(ptr, field); if (ZEND_FFI_TYPE(field->type)->kind == ZEND_FFI_TYPE_CHAR @@ -693,7 +693,7 @@ static void zend_ffi_bit_field_to_zval(void *ptr, zend_ffi_field *field, zval *r } /* }}} */ -static void zend_ffi_zval_to_bit_field(void *ptr, zend_ffi_field *field, zval *value) /* {{{ */ +static void zend_ffi_zval_to_bit_field(void *ptr, const zend_ffi_field *field, const zval *value) /* {{{ */ { uint64_t val = zval_get_long(value); size_t bit = field->first_bit; @@ -744,7 +744,7 @@ static zend_always_inline zend_result zend_ffi_zval_to_cdata(void *ptr, zend_ffi /* Pointer type has special handling of CData */ if (kind != ZEND_FFI_TYPE_POINTER && Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == zend_ffi_cdata_ce) { - zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ_P(value); + const zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ_P(value); if (zend_ffi_is_compatible_type(type, ZEND_FFI_TYPE(cdata->type)) && type->size == ZEND_FFI_TYPE(cdata->type)->size) { memcpy(ptr, cdata->ptr, type->size); @@ -822,7 +822,7 @@ static zend_always_inline zend_result zend_ffi_zval_to_cdata(void *ptr, zend_ffi *(void**)ptr = NULL; break; } else if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == zend_ffi_cdata_ce) { - zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ_P(value); + const zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ_P(value); if (zend_ffi_is_compatible_type(type, ZEND_FFI_TYPE(cdata->type))) { if (ZEND_FFI_TYPE(cdata->type)->kind == ZEND_FFI_TYPE_POINTER) { @@ -929,7 +929,7 @@ static void zend_ffi_callback_hash_dtor(zval *zv) /* {{{ */ if (callback_data->fcc.function_handler->common.fn_flags & ZEND_ACC_CLOSURE) { OBJ_RELEASE(ZEND_CLOSURE_OBJECT(callback_data->fcc.function_handler)); } - for (int i = 0; i < callback_data->arg_count; ++i) { + for (uint32_t i = 0; i < callback_data->arg_count; ++i) { if (callback_data->arg_types[i]->type == FFI_TYPE_STRUCT) { efree(callback_data->arg_types[i]); } @@ -974,9 +974,7 @@ static void zend_ffi_callback_trampoline(ffi_cif* cif, void* ret, void** args, v } if (callback_data->arg_count) { - int n = 0; - - for (n = 0; n < callback_data->arg_count; n++) { + for (uint32_t n = 0; n < callback_data->arg_count; n++) { zval_ptr_dtor(&fci.params[n]); } } @@ -1172,8 +1170,8 @@ static zval *zend_ffi_cdata_set(zend_object *obj, zend_string *member, zval *val static zend_result zend_ffi_cdata_cast_object(zend_object *readobj, zval *writeobj, int type) /* {{{ */ { if (type == IS_STRING) { - zend_ffi_cdata *cdata = (zend_ffi_cdata*)readobj; - zend_ffi_type *ctype = ZEND_FFI_TYPE(cdata->type); + const zend_ffi_cdata *cdata = (zend_ffi_cdata*)readobj; + const zend_ffi_type *ctype = ZEND_FFI_TYPE(cdata->type); void *ptr = cdata->ptr; zend_ffi_type_kind kind = ctype->kind; @@ -1700,7 +1698,7 @@ static ZEND_COLD void zend_ffi_pass_unsupported(zend_ffi_type *type) /* {{{ */ } /* }}} */ -static ZEND_COLD void zend_ffi_pass_incompatible(zval *arg, zend_ffi_type *type, uint32_t n, zend_execute_data *execute_data) /* {{{ */ +static ZEND_COLD void zend_ffi_pass_incompatible(const zval *arg, const zend_ffi_type *type, uint32_t n, const zend_execute_data *execute_data) /* {{{ */ { zend_ffi_ctype_name_buf buf1, buf2; @@ -1710,7 +1708,7 @@ static ZEND_COLD void zend_ffi_pass_incompatible(zval *arg, zend_ffi_type *type, } else { *buf1.end = 0; if (Z_TYPE_P(arg) == IS_OBJECT && Z_OBJCE_P(arg) == zend_ffi_cdata_ce) { - zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ_P(arg); + const zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ_P(arg); type = ZEND_FFI_TYPE(cdata->type); buf2.start = buf2.end = buf2.buf + ((MAX_TYPE_NAME_LEN * 3) / 4); @@ -1727,7 +1725,7 @@ static ZEND_COLD void zend_ffi_pass_incompatible(zval *arg, zend_ffi_type *type, } /* }}} */ -static ZEND_COLD void zend_ffi_assign_incompatible(zval *arg, zend_ffi_type *type) /* {{{ */ +static ZEND_COLD void zend_ffi_assign_incompatible(const zval *arg, const zend_ffi_type *type) /* {{{ */ { zend_ffi_ctype_name_buf buf1, buf2; @@ -1737,7 +1735,7 @@ static ZEND_COLD void zend_ffi_assign_incompatible(zval *arg, zend_ffi_type *typ } else { *buf1.end = 0; if (Z_TYPE_P(arg) == IS_OBJECT && Z_OBJCE_P(arg) == zend_ffi_cdata_ce) { - zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ_P(arg); + const zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ_P(arg); type = ZEND_FFI_TYPE(cdata->type); buf2.start = buf2.end = buf2.buf + ((MAX_TYPE_NAME_LEN * 3) / 4); @@ -1770,7 +1768,7 @@ static zend_string *zend_ffi_get_class_name(zend_string *prefix, const zend_ffi_ static zend_string *zend_ffi_cdata_get_class_name(const zend_object *zobj) /* {{{ */ { - zend_ffi_cdata *cdata = (zend_ffi_cdata*)zobj; + const zend_ffi_cdata *cdata = (zend_ffi_cdata*)zobj; return zend_ffi_get_class_name(zobj->ce->name, ZEND_FFI_TYPE(cdata->type)); } @@ -1780,10 +1778,10 @@ static int zend_ffi_cdata_compare_objects(zval *o1, zval *o2) /* {{{ */ { if (Z_TYPE_P(o1) == IS_OBJECT && Z_OBJCE_P(o1) == zend_ffi_cdata_ce && Z_TYPE_P(o2) == IS_OBJECT && Z_OBJCE_P(o2) == zend_ffi_cdata_ce) { - zend_ffi_cdata *cdata1 = (zend_ffi_cdata*)Z_OBJ_P(o1); - zend_ffi_cdata *cdata2 = (zend_ffi_cdata*)Z_OBJ_P(o2); - zend_ffi_type *type1 = ZEND_FFI_TYPE(cdata1->type); - zend_ffi_type *type2 = ZEND_FFI_TYPE(cdata2->type); + const zend_ffi_cdata *cdata1 = (zend_ffi_cdata*)Z_OBJ_P(o1); + const zend_ffi_cdata *cdata2 = (zend_ffi_cdata*)Z_OBJ_P(o2); + const zend_ffi_type *type1 = ZEND_FFI_TYPE(cdata1->type); + const zend_ffi_type *type2 = ZEND_FFI_TYPE(cdata2->type); if (type1->kind == ZEND_FFI_TYPE_POINTER && type2->kind == ZEND_FFI_TYPE_POINTER) { void *ptr1 = *(void**)cdata1->ptr; @@ -1803,8 +1801,8 @@ static int zend_ffi_cdata_compare_objects(zval *o1, zval *o2) /* {{{ */ static zend_result zend_ffi_cdata_count_elements(zend_object *obj, zend_long *count) /* {{{ */ { - zend_ffi_cdata *cdata = (zend_ffi_cdata*)obj; - zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); + const zend_ffi_cdata *cdata = (zend_ffi_cdata*)obj; + const zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); if (type->kind != ZEND_FFI_TYPE_ARRAY) { zend_throw_error(zend_ffi_exception_ce, "Attempt to count() on non C array"); @@ -1892,8 +1890,8 @@ static zend_result zend_ffi_cdata_do_operation(uint8_t opcode, zval *result, zva return SUCCESS; } else if (opcode == ZEND_SUB) { if (Z_TYPE_P(op2) == IS_OBJECT && Z_OBJCE_P(op2) == zend_ffi_cdata_ce) { - zend_ffi_cdata *cdata2 = (zend_ffi_cdata*)Z_OBJ_P(op2); - zend_ffi_type *type2 = ZEND_FFI_TYPE(cdata2->type); + const zend_ffi_cdata *cdata2 = (zend_ffi_cdata*)Z_OBJ_P(op2); + const zend_ffi_type *type2 = ZEND_FFI_TYPE(cdata2->type); if (type2->kind == ZEND_FFI_TYPE_POINTER || type2->kind == ZEND_FFI_TYPE_ARRAY) { zend_ffi_type *t1, *t2; @@ -1961,9 +1959,9 @@ static void zend_ffi_cdata_it_dtor(zend_object_iterator *iter) /* {{{ */ static zend_result zend_ffi_cdata_it_valid(zend_object_iterator *it) /* {{{ */ { - zend_ffi_cdata_iterator *iter = (zend_ffi_cdata_iterator*)it; - zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ(iter->it.data); - zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); + const zend_ffi_cdata_iterator *iter = (zend_ffi_cdata_iterator*)it; + const zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ(iter->it.data); + const zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); return (iter->key >= 0 && iter->key < type->array.length) ? SUCCESS : FAILURE; } @@ -1999,7 +1997,7 @@ static zval *zend_ffi_cdata_it_get_current_data(zend_object_iterator *it) /* {{{ static void zend_ffi_cdata_it_get_current_key(zend_object_iterator *it, zval *key) /* {{{ */ { - zend_ffi_cdata_iterator *iter = (zend_ffi_cdata_iterator*)it; + const zend_ffi_cdata_iterator *iter = (zend_ffi_cdata_iterator*)it; ZVAL_LONG(key, iter->key); } /* }}} */ @@ -2240,7 +2238,7 @@ static void zend_ffi_ctype_free_obj(zend_object *object) /* {{{ */ } /* }}} */ -static bool zend_ffi_is_same_type(zend_ffi_type *type1, zend_ffi_type *type2) /* {{{ */ +static bool zend_ffi_is_same_type(const zend_ffi_type *type1, const zend_ffi_type *type2) /* {{{ */ { while (1) { if (type1 == type2) { @@ -2282,10 +2280,10 @@ static int zend_ffi_ctype_compare_objects(zval *o1, zval *o2) /* {{{ */ { if (Z_TYPE_P(o1) == IS_OBJECT && Z_OBJCE_P(o1) == zend_ffi_ctype_ce && Z_TYPE_P(o2) == IS_OBJECT && Z_OBJCE_P(o2) == zend_ffi_ctype_ce) { - zend_ffi_ctype *ctype1 = (zend_ffi_ctype*)Z_OBJ_P(o1); - zend_ffi_ctype *ctype2 = (zend_ffi_ctype*)Z_OBJ_P(o2); - zend_ffi_type *type1 = ZEND_FFI_TYPE(ctype1->type); - zend_ffi_type *type2 = ZEND_FFI_TYPE(ctype2->type); + const zend_ffi_ctype *ctype1 = (zend_ffi_ctype*)Z_OBJ_P(o1); + const zend_ffi_ctype *ctype2 = (zend_ffi_ctype*)Z_OBJ_P(o2); + const zend_ffi_type *type1 = ZEND_FFI_TYPE(ctype1->type); + const zend_ffi_type *type2 = ZEND_FFI_TYPE(ctype2->type); if (zend_ffi_is_same_type(type1, type2)) { return 0; @@ -2569,7 +2567,7 @@ static zval *zend_ffi_write_var(zend_object *obj, zend_string *var_name, zval *v } /* }}} */ -static zend_result zend_ffi_pass_arg(zval *arg, zend_ffi_type *type, ffi_type **pass_type, void **arg_values, uint32_t n, zend_execute_data *execute_data) /* {{{ */ +static zend_result zend_ffi_pass_arg(zval *arg, zend_ffi_type *type, ffi_type **pass_type, void **arg_values, uint32_t n, const zend_execute_data *execute_data) /* {{{ */ { zend_long lval; double dval; @@ -2712,7 +2710,7 @@ static zend_result zend_ffi_pass_arg(zval *arg, zend_ffi_type *type, ffi_type ** } /* }}} */ -static zend_result zend_ffi_pass_var_arg(zval *arg, ffi_type **pass_type, void **arg_values, uint32_t n, zend_execute_data *execute_data) /* {{{ */ +static zend_result zend_ffi_pass_var_arg(zval *arg, ffi_type **pass_type, void **arg_values, uint32_t n, const zend_execute_data *execute_data) /* {{{ */ { ZVAL_DEREF(arg); switch (Z_TYPE_P(arg)) { @@ -2919,6 +2917,7 @@ static ZEND_FUNCTION(ffi_trampoline) /* {{{ */ } /* }}} */ +/* This function was manually optimized to reduce the overhead of calling native functions */ static zend_function *zend_ffi_get_func(zend_object **obj, zend_string *name, const zval *key) /* {{{ */ { zend_ffi *ffi = (zend_ffi*)*obj; @@ -3000,7 +2999,7 @@ static zend_never_inline int zend_ffi_disabled(void) /* {{{ */ } /* }}} */ -static zend_always_inline bool zend_ffi_validate_api_restriction(zend_execute_data *execute_data) /* {{{ */ +static zend_always_inline bool zend_ffi_validate_api_restriction(const zend_execute_data *execute_data) /* {{{ */ { if (EXPECTED(FFI_G(restriction) > ZEND_FFI_ENABLED)) { ZEND_ASSERT(FFI_G(restriction) == ZEND_FFI_PRELOAD); @@ -3064,8 +3063,6 @@ ZEND_METHOD(FFI, cdef) /* {{{ */ zend_string *lib = NULL; zend_ffi *ffi = NULL; DL_HANDLE handle = NULL; - char *err; - void *addr; ZEND_FFI_VALIDATE_API_RESTRICTION(); ZEND_PARSE_PARAMETERS_START(0, 2) @@ -3077,7 +3074,7 @@ ZEND_METHOD(FFI, cdef) /* {{{ */ if (lib) { handle = DL_LOAD(ZSTR_VAL(lib)); if (!handle) { - err = GET_DL_ERROR(); + char *err = GET_DL_ERROR(); #ifdef PHP_WIN32 if (err && err[0]) { zend_throw_error(zend_ffi_exception_ce, "Failed loading '%s' (%s)", ZSTR_VAL(lib), err); @@ -3125,6 +3122,7 @@ ZEND_METHOD(FFI, cdef) /* {{{ */ zend_ffi_symbol *sym; ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(FFI_G(symbols), name, sym) { + void *addr; if (sym->kind == ZEND_FFI_SYM_VAR) { addr = DL_FETCH_SYMBOL(handle, ZSTR_VAL(name)); if (!addr) { @@ -3159,7 +3157,7 @@ ZEND_METHOD(FFI, cdef) /* {{{ */ } /* }}} */ -static bool zend_ffi_same_types(zend_ffi_type *old, zend_ffi_type *type) /* {{{ */ +static bool zend_ffi_same_types(const zend_ffi_type *old, const zend_ffi_type *type) /* {{{ */ { if (old == type) { return 1; @@ -3186,7 +3184,7 @@ static bool zend_ffi_same_types(zend_ffi_type *old, zend_ffi_type *type) /* {{{ } else { zend_ffi_field *old_field, *field; zend_string *key; - Bucket *b = type->record.fields.arData; + const Bucket *b = type->record.fields.arData; ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(&old->record.fields, key, old_field) { while (Z_TYPE(b->val) == IS_UNDEF) { @@ -3220,7 +3218,7 @@ static bool zend_ffi_same_types(zend_ffi_type *old, zend_ffi_type *type) /* {{{ return 0; } else if (old->func.args) { zend_ffi_type *arg_type; - zval *zv = type->func.args->arPacked; + const zval *zv = type->func.args->arPacked; ZEND_HASH_PACKED_FOREACH_PTR(old->func.args, arg_type) { while (Z_TYPE_P(zv) == IS_UNDEF) { @@ -3241,7 +3239,7 @@ static bool zend_ffi_same_types(zend_ffi_type *old, zend_ffi_type *type) /* {{{ } /* }}} */ -static bool zend_ffi_same_symbols(zend_ffi_symbol *old, zend_ffi_symbol *sym) /* {{{ */ +static bool zend_ffi_same_symbols(const zend_ffi_symbol *old, const zend_ffi_symbol *sym) /* {{{ */ { if (old->kind != sym->kind || old->is_const != sym->is_const) { return 0; @@ -3257,7 +3255,7 @@ static bool zend_ffi_same_symbols(zend_ffi_symbol *old, zend_ffi_symbol *sym) /* } /* }}} */ -static bool zend_ffi_same_tags(zend_ffi_tag *old, zend_ffi_tag *tag) /* {{{ */ +static bool zend_ffi_same_tags(const zend_ffi_tag *old, const zend_ffi_tag *tag) /* {{{ */ { if (old->kind != tag->kind) { return 0; @@ -3344,7 +3342,7 @@ static zend_ffi *zend_ffi_load(const char *filename, bool preload) /* {{{ */ { struct stat buf; int fd; - char *code, *code_pos, *scope_name, *lib, *err; + char *code, *code_pos, *scope_name, *lib; size_t code_size, scope_name_len; zend_ffi *ffi; DL_HANDLE handle = NULL; @@ -3352,7 +3350,6 @@ static zend_ffi *zend_ffi_load(const char *filename, bool preload) /* {{{ */ zend_string *name; zend_ffi_symbol *sym; zend_ffi_tag *tag; - void *addr; if (stat(filename, &buf) != 0) { if (preload) { @@ -3425,7 +3422,7 @@ static zend_ffi *zend_ffi_load(const char *filename, bool preload) /* {{{ */ if (preload) { zend_error(E_WARNING, "FFI: Failed pre-loading '%s'", lib); } else { - err = GET_DL_ERROR(); + char *err = GET_DL_ERROR(); #ifdef PHP_WIN32 if (err && err[0]) { zend_throw_error(zend_ffi_exception_ce, "Failed loading '%s' (%s)", lib, err); @@ -3459,6 +3456,7 @@ static zend_ffi *zend_ffi_load(const char *filename, bool preload) /* {{{ */ if (FFI_G(symbols)) { ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(FFI_G(symbols), name, sym) { + void *addr; if (sym->kind == ZEND_FFI_SYM_VAR) { addr = DL_FETCH_SYMBOL(handle, ZSTR_VAL(name)); if (!addr) { @@ -3702,7 +3700,7 @@ static void zend_ffi_throw_parser_error(const char *format, ...) /* {{{ */ } /* }}} */ -static zend_result zend_ffi_validate_vla(zend_ffi_type *type) /* {{{ */ +static zend_result zend_ffi_validate_vla(const zend_ffi_type *type) /* {{{ */ { if (!FFI_G(allow_vla) && (type->attr & ZEND_FFI_ATTR_VLA)) { zend_ffi_throw_parser_error("\"[*]\" is not allowed in other than function prototype scope at line %d", FFI_G(line)); @@ -3712,7 +3710,7 @@ static zend_result zend_ffi_validate_vla(zend_ffi_type *type) /* {{{ */ } /* }}} */ -static zend_result zend_ffi_validate_incomplete_type(zend_ffi_type *type, bool allow_incomplete_tag, bool allow_incomplete_array) /* {{{ */ +static zend_result zend_ffi_validate_incomplete_type(const zend_ffi_type *type, bool allow_incomplete_tag, bool allow_incomplete_array) /* {{{ */ { if (!allow_incomplete_tag && (type->attr & ZEND_FFI_ATTR_INCOMPLETE_TAG)) { if (FFI_G(tags)) { @@ -3756,7 +3754,7 @@ static zend_result zend_ffi_validate_incomplete_type(zend_ffi_type *type, bool a } /* }}} */ -static zend_result zend_ffi_validate_type(zend_ffi_type *type, bool allow_incomplete_tag, bool allow_incomplete_array) /* {{{ */ +static zend_result zend_ffi_validate_type(const zend_ffi_type *type, bool allow_incomplete_tag, bool allow_incomplete_array) /* {{{ */ { if (type->kind == ZEND_FFI_TYPE_VOID) { zend_ffi_throw_parser_error("void type is not allowed at line %d", FFI_G(line)); @@ -3766,7 +3764,7 @@ static zend_result zend_ffi_validate_type(zend_ffi_type *type, bool allow_incomp } /* }}} */ -static zend_result zend_ffi_validate_var_type(zend_ffi_type *type, bool allow_incomplete_array) /* {{{ */ +static zend_result zend_ffi_validate_var_type(const zend_ffi_type *type, bool allow_incomplete_array) /* {{{ */ { if (type->kind == ZEND_FFI_TYPE_FUNC) { zend_ffi_throw_parser_error("function type is not allowed at line %d", FFI_G(line)); @@ -4150,7 +4148,7 @@ ZEND_METHOD(FFI, cast) /* {{{ */ cdata->ptr = *(void**)ptr; } else if (old_type->kind == ZEND_FFI_TYPE_ARRAY && type->kind == ZEND_FFI_TYPE_POINTER - && zend_ffi_is_compatible_type(ZEND_FFI_TYPE(old_type->array.type), ZEND_FFI_TYPE(type->pointer.type))) { cdata->ptr = &cdata->ptr_holder; + && zend_ffi_is_compatible_type(ZEND_FFI_TYPE(old_type->array.type), ZEND_FFI_TYPE(type->pointer.type))) { cdata->ptr = &cdata->ptr_holder; cdata->ptr_holder = old_cdata->ptr; } else if (old_type->kind == ZEND_FFI_TYPE_POINTER @@ -4735,8 +4733,8 @@ ZEND_METHOD(FFI_CType, getName) /* {{{ */ ZEND_METHOD(FFI_CType, getKind) /* {{{ */ { - zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); - zend_ffi_type *type; + const zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); + const zend_ffi_type *type; if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); @@ -4749,8 +4747,8 @@ ZEND_METHOD(FFI_CType, getKind) /* {{{ */ ZEND_METHOD(FFI_CType, getSize) /* {{{ */ { - zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); - zend_ffi_type *type; + const zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); + const zend_ffi_type *type; if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); @@ -4763,8 +4761,8 @@ ZEND_METHOD(FFI_CType, getSize) /* {{{ */ ZEND_METHOD(FFI_CType, getAlignment) /* {{{ */ { - zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); - zend_ffi_type *type; + const zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); + const zend_ffi_type *type; if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); @@ -4777,8 +4775,8 @@ ZEND_METHOD(FFI_CType, getAlignment) /* {{{ */ ZEND_METHOD(FFI_CType, getAttributes) /* {{{ */ { - zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); - zend_ffi_type *type; + const zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); + const zend_ffi_type *type; if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); @@ -4791,8 +4789,8 @@ ZEND_METHOD(FFI_CType, getAttributes) /* {{{ */ ZEND_METHOD(FFI_CType, getEnumKind) /* {{{ */ { - zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); - zend_ffi_type *type; + const zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); + const zend_ffi_type *type; if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); @@ -4831,8 +4829,8 @@ ZEND_METHOD(FFI_CType, getArrayElementType) /* {{{ */ ZEND_METHOD(FFI_CType, getArrayLength) /* {{{ */ { - zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); - zend_ffi_type *type; + const zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); + const zend_ffi_type *type; if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); @@ -4871,8 +4869,8 @@ ZEND_METHOD(FFI_CType, getPointerType) /* {{{ */ ZEND_METHOD(FFI_CType, getStructFieldNames) /* {{{ */ { - zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); - zend_ffi_type *type; + const zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); + const zend_ffi_type *type; HashTable *ht; zend_string* name; zval zv; @@ -4898,10 +4896,10 @@ ZEND_METHOD(FFI_CType, getStructFieldNames) /* {{{ */ ZEND_METHOD(FFI_CType, getStructFieldOffset) /* {{{ */ { - zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); - zend_ffi_type *type; + const zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); + const zend_ffi_type *type; zend_string *name; - zend_ffi_field *ptr; + const zend_ffi_field *ptr; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STR(name) @@ -4954,8 +4952,8 @@ ZEND_METHOD(FFI_CType, getStructFieldType) /* {{{ */ ZEND_METHOD(FFI_CType, getFuncABI) /* {{{ */ { - zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); - zend_ffi_type *type; + const zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); + const zend_ffi_type *type; if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); @@ -4994,8 +4992,8 @@ ZEND_METHOD(FFI_CType, getFuncReturnType) /* {{{ */ ZEND_METHOD(FFI_CType, getFuncParameterCount) /* {{{ */ { - zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); - zend_ffi_type *type; + const zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); + const zend_ffi_type *type; if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); @@ -5909,8 +5907,8 @@ static void zend_ffi_finalize_type(zend_ffi_dcl *dcl) /* {{{ */ bool zend_ffi_is_typedef_name(const char *name, size_t name_len) /* {{{ */ { - zend_ffi_symbol *sym; - zend_ffi_type *type; + const zend_ffi_symbol *sym; + const zend_ffi_type *type; if (FFI_G(symbols)) { sym = zend_hash_str_find_ptr(FFI_G(symbols), name, name_len); @@ -5952,15 +5950,13 @@ void zend_ffi_resolve_typedef(const char *name, size_t name_len, zend_ffi_dcl *d void zend_ffi_resolve_const(const char *name, size_t name_len, zend_ffi_val *val) /* {{{ */ { - zend_ffi_symbol *sym; - if (UNEXPECTED(FFI_G(attribute_parsing))) { val->kind = ZEND_FFI_VAL_NAME; val->str = name; val->len = name_len; return; } else if (FFI_G(symbols)) { - sym = zend_hash_str_find_ptr(FFI_G(symbols), name, name_len); + const zend_ffi_symbol *sym = zend_hash_str_find_ptr(FFI_G(symbols), name, name_len); if (sym && sym->kind == ZEND_FFI_SYM_CONST) { val->i64 = sym->value; switch (sym->type->kind) { @@ -6010,7 +6006,7 @@ void zend_ffi_make_enum_type(zend_ffi_dcl *dcl) /* {{{ */ } /* }}} */ -void zend_ffi_add_enum_val(zend_ffi_dcl *enum_dcl, const char *name, size_t name_len, zend_ffi_val *val, int64_t *min, int64_t *max, int64_t *last) /* {{{ */ +void zend_ffi_add_enum_val(zend_ffi_dcl *enum_dcl, const char *name, size_t name_len, const zend_ffi_val *val, int64_t *min, int64_t *max, int64_t *last) /* {{{ */ { zend_ffi_symbol *sym; const zend_ffi_type *sym_type; @@ -6141,7 +6137,7 @@ void zend_ffi_make_struct_type(zend_ffi_dcl *dcl) /* {{{ */ static zend_result zend_ffi_validate_prev_field_type(zend_ffi_type *struct_type) /* {{{ */ { if (zend_hash_num_elements(&struct_type->record.fields) > 0) { - zend_ffi_field *field = NULL; + const zend_ffi_field *field = NULL; ZEND_HASH_MAP_REVERSE_FOREACH_PTR(&struct_type->record.fields, field) { break; @@ -6155,7 +6151,7 @@ static zend_result zend_ffi_validate_prev_field_type(zend_ffi_type *struct_type) } /* }}} */ -static zend_result zend_ffi_validate_field_type(zend_ffi_type *type, zend_ffi_type *struct_type) /* {{{ */ +static zend_result zend_ffi_validate_field_type(const zend_ffi_type *type, zend_ffi_type *struct_type) /* {{{ */ { if (type == struct_type) { zend_ffi_throw_parser_error("Struct/union can't contain an instance of itself at line %d", FFI_G(line)); @@ -6284,7 +6280,7 @@ void zend_ffi_add_anonymous_field(zend_ffi_dcl *struct_dcl, zend_ffi_dcl *field_ } /* }}} */ -void zend_ffi_add_bit_field(zend_ffi_dcl *struct_dcl, const char *name, size_t name_len, zend_ffi_dcl *field_dcl, zend_ffi_val *bits) /* {{{ */ +void zend_ffi_add_bit_field(zend_ffi_dcl *struct_dcl, const char *name, size_t name_len, zend_ffi_dcl *field_dcl, const zend_ffi_val *bits) /* {{{ */ { zend_ffi_type *struct_type = ZEND_FFI_TYPE(struct_dcl->type); zend_ffi_type *field_type; @@ -6347,7 +6343,7 @@ void zend_ffi_add_bit_field(zend_ffi_dcl *struct_dcl, const char *name, size_t n struct_type->size = MAX(struct_type->size, ((bits->u64 + 31) / 32) * 4); } } else { - zend_ffi_field *prev_field = NULL; + const zend_ffi_field *prev_field = NULL; if (zend_hash_num_elements(&struct_type->record.fields) > 0) { ZEND_HASH_MAP_REVERSE_FOREACH_PTR(&struct_type->record.fields, prev_field) { @@ -6421,7 +6417,7 @@ void zend_ffi_make_pointer_type(zend_ffi_dcl *dcl) /* {{{ */ } /* }}} */ -static zend_result zend_ffi_validate_array_element_type(zend_ffi_type *type) /* {{{ */ +static zend_result zend_ffi_validate_array_element_type(const zend_ffi_type *type) /* {{{ */ { if (type->kind == ZEND_FFI_TYPE_FUNC) { zend_ffi_throw_parser_error("Array of functions is not allowed at line %d", FFI_G(line)); @@ -6434,10 +6430,10 @@ static zend_result zend_ffi_validate_array_element_type(zend_ffi_type *type) /* } /* }}} */ -void zend_ffi_make_array_type(zend_ffi_dcl *dcl, zend_ffi_val *len) /* {{{ */ +void zend_ffi_make_array_type(zend_ffi_dcl *dcl, const zend_ffi_val *len) /* {{{ */ { - int length = 0; - zend_ffi_type *element_type; + int64_t length = 0; + const zend_ffi_type *element_type; zend_ffi_type *type; zend_ffi_finalize_type(dcl); @@ -6481,7 +6477,7 @@ void zend_ffi_make_array_type(zend_ffi_dcl *dcl, zend_ffi_val *len) /* {{{ */ } /* }}} */ -static zend_result zend_ffi_validate_func_ret_type(zend_ffi_type *type) /* {{{ */ +static zend_result zend_ffi_validate_func_ret_type(const zend_ffi_type *type) /* {{{ */ { if (type->kind == ZEND_FFI_TYPE_FUNC) { zend_ffi_throw_parser_error("Function returning function is not allowed at line %d", FFI_G(line)); @@ -6695,7 +6691,7 @@ void zend_ffi_declare(const char *name, size_t name_len, zend_ffi_dcl *dcl) /* { return; } else if ((dcl->flags & ZEND_FFI_DCL_STORAGE_CLASS) == 0 || (dcl->flags & ZEND_FFI_DCL_STORAGE_CLASS) == ZEND_FFI_DCL_EXTERN) { - zend_ffi_type *type = ZEND_FFI_TYPE(dcl->type); + const zend_ffi_type *type = ZEND_FFI_TYPE(dcl->type); if (type->kind == ZEND_FFI_TYPE_FUNC) { if (sym->kind == ZEND_FFI_SYM_FUNC @@ -6767,7 +6763,6 @@ void zend_ffi_declare(const char *name, size_t name_len, zend_ffi_dcl *dcl) /* { void zend_ffi_declare_tag(const char *name, size_t name_len, zend_ffi_dcl *dcl, bool incomplete) /* {{{ */ { zend_ffi_tag *tag; - zend_ffi_type *type; if (!FFI_G(tags)) { FFI_G(tags) = pemalloc(sizeof(HashTable), FFI_G(persistent)); @@ -6810,8 +6805,10 @@ void zend_ffi_declare_tag(const char *name, size_t name_len, zend_ffi_dcl *dcl, type->attr &= ~ZEND_FFI_ATTR_INCOMPLETE_TAG; } } else { - zend_ffi_tag *tag = pemalloc(sizeof(zend_ffi_tag), FFI_G(persistent)); zend_string *tag_name = zend_string_init(name, name_len, FFI_G(persistent)); + zend_ffi_type *type; + + tag = pemalloc(sizeof(zend_ffi_tag), FFI_G(persistent)); if (dcl->flags & ZEND_FFI_DCL_STRUCT) { tag->kind = ZEND_FFI_TAG_STRUCT; @@ -6959,7 +6956,7 @@ void zend_ffi_add_attribute(zend_ffi_dcl *dcl, const char *name, size_t name_len _(format) \ _(deprecated) -void zend_ffi_add_attribute_value(zend_ffi_dcl *dcl, const char *name, size_t name_len, int n, zend_ffi_val *val) /* {{{ */ +void zend_ffi_add_attribute_value(zend_ffi_dcl *dcl, const char *name, size_t name_len, int n, const zend_ffi_val *val) /* {{{ */ { enum { VALUE_ATTRIBUTES(ATTR_ID) @@ -7074,7 +7071,7 @@ void zend_ffi_add_attribute_value(zend_ffi_dcl *dcl, const char *name, size_t na } /* }}} */ -void zend_ffi_add_msvc_attribute_value(zend_ffi_dcl *dcl, const char *name, size_t name_len, zend_ffi_val *val) /* {{{ */ +void zend_ffi_add_msvc_attribute_value(zend_ffi_dcl *dcl, const char *name, size_t name_len, const zend_ffi_val *val) /* {{{ */ { if (name_len == sizeof("align")-1 && memcmp(name, "align", sizeof("align")-1) == 0) { if ((val->kind == ZEND_FFI_VAL_INT32 || val->kind == ZEND_FFI_VAL_UINT32 || val->kind == ZEND_FFI_VAL_INT64 || val->kind == ZEND_FFI_VAL_UINT64) @@ -7156,7 +7153,7 @@ void zend_ffi_align_as_type(zend_ffi_dcl *dcl, zend_ffi_dcl *align_dcl) /* {{{ * } /* }}} */ -void zend_ffi_align_as_val(zend_ffi_dcl *dcl, zend_ffi_val *align_val) /* {{{ */ +void zend_ffi_align_as_val(zend_ffi_dcl *dcl, const zend_ffi_val *align_val) /* {{{ */ { switch (align_val->kind) { case ZEND_FFI_VAL_INT32: @@ -7400,7 +7397,7 @@ void zend_ffi_align_as_val(zend_ffi_dcl *dcl, zend_ffi_val *align_val) /* {{{ */ } \ } while (0) -void zend_ffi_expr_conditional(zend_ffi_val *val, zend_ffi_val *op2, zend_ffi_val *op3) /* {{{ */ +void zend_ffi_expr_conditional(zend_ffi_val *val, const zend_ffi_val *op2, const zend_ffi_val *op3) /* {{{ */ { zend_ffi_expr_bool(val); if (val->kind == ZEND_FFI_VAL_INT32) { @@ -7437,97 +7434,97 @@ void zend_ffi_expr_bool_and(zend_ffi_val *val, zend_ffi_val *op2) /* {{{ */ } /* }}} */ -void zend_ffi_expr_bw_or(zend_ffi_val *val, zend_ffi_val *op2) /* {{{ */ +void zend_ffi_expr_bw_or(zend_ffi_val *val, const zend_ffi_val *op2) /* {{{ */ { zend_ffi_expr_int_math(val, op2, |); } /* }}} */ -void zend_ffi_expr_bw_xor(zend_ffi_val *val, zend_ffi_val *op2) /* {{{ */ +void zend_ffi_expr_bw_xor(zend_ffi_val *val, const zend_ffi_val *op2) /* {{{ */ { zend_ffi_expr_int_math(val, op2, ^); } /* }}} */ -void zend_ffi_expr_bw_and(zend_ffi_val *val, zend_ffi_val *op2) /* {{{ */ +void zend_ffi_expr_bw_and(zend_ffi_val *val, const zend_ffi_val *op2) /* {{{ */ { zend_ffi_expr_int_math(val, op2, &); } /* }}} */ -void zend_ffi_expr_is_equal(zend_ffi_val *val, zend_ffi_val *op2) /* {{{ */ +void zend_ffi_expr_is_equal(zend_ffi_val *val, const zend_ffi_val *op2) /* {{{ */ { zend_ffi_expr_cmp(val, op2, ==); } /* }}} */ -void zend_ffi_expr_is_not_equal(zend_ffi_val *val, zend_ffi_val *op2) /* {{{ */ +void zend_ffi_expr_is_not_equal(zend_ffi_val *val, const zend_ffi_val *op2) /* {{{ */ { zend_ffi_expr_cmp(val, op2, !=); } /* }}} */ -void zend_ffi_expr_is_less(zend_ffi_val *val, zend_ffi_val *op2) /* {{{ */ +void zend_ffi_expr_is_less(zend_ffi_val *val, const zend_ffi_val *op2) /* {{{ */ { zend_ffi_expr_cmp(val, op2, <); } /* }}} */ -void zend_ffi_expr_is_greater(zend_ffi_val *val, zend_ffi_val *op2) /* {{{ */ +void zend_ffi_expr_is_greater(zend_ffi_val *val, const zend_ffi_val *op2) /* {{{ */ { zend_ffi_expr_cmp(val, op2, >); } /* }}} */ -void zend_ffi_expr_is_less_or_equal(zend_ffi_val *val, zend_ffi_val *op2) /* {{{ */ +void zend_ffi_expr_is_less_or_equal(zend_ffi_val *val, const zend_ffi_val *op2) /* {{{ */ { zend_ffi_expr_cmp(val, op2, <=); } /* }}} */ -void zend_ffi_expr_is_greater_or_equal(zend_ffi_val *val, zend_ffi_val *op2) /* {{{ */ +void zend_ffi_expr_is_greater_or_equal(zend_ffi_val *val, const zend_ffi_val *op2) /* {{{ */ { zend_ffi_expr_cmp(val, op2, >=); } /* }}} */ -void zend_ffi_expr_shift_left(zend_ffi_val *val, zend_ffi_val *op2) /* {{{ */ +void zend_ffi_expr_shift_left(zend_ffi_val *val, const zend_ffi_val *op2) /* {{{ */ { zend_ffi_expr_int_math(val, op2, <<); } /* }}} */ -void zend_ffi_expr_shift_right(zend_ffi_val *val, zend_ffi_val *op2) /* {{{ */ +void zend_ffi_expr_shift_right(zend_ffi_val *val, const zend_ffi_val *op2) /* {{{ */ { zend_ffi_expr_int_math(val, op2, >>); } /* }}} */ -void zend_ffi_expr_add(zend_ffi_val *val, zend_ffi_val *op2) /* {{{ */ +void zend_ffi_expr_add(zend_ffi_val *val, const zend_ffi_val *op2) /* {{{ */ { zend_ffi_expr_math(val, op2, +); } /* }}} */ -void zend_ffi_expr_sub(zend_ffi_val *val, zend_ffi_val *op2) /* {{{ */ +void zend_ffi_expr_sub(zend_ffi_val *val, const zend_ffi_val *op2) /* {{{ */ { zend_ffi_expr_math(val, op2, -); } /* }}} */ -void zend_ffi_expr_mul(zend_ffi_val *val, zend_ffi_val *op2) /* {{{ */ +void zend_ffi_expr_mul(zend_ffi_val *val, const zend_ffi_val *op2) /* {{{ */ { zend_ffi_expr_math(val, op2, *); } /* }}} */ -void zend_ffi_expr_div(zend_ffi_val *val, zend_ffi_val *op2) /* {{{ */ +void zend_ffi_expr_div(zend_ffi_val *val, const zend_ffi_val *op2) /* {{{ */ { zend_ffi_expr_math(val, op2, /); } /* }}} */ -void zend_ffi_expr_mod(zend_ffi_val *val, zend_ffi_val *op2) /* {{{ */ +void zend_ffi_expr_mod(zend_ffi_val *val, const zend_ffi_val *op2) /* {{{ */ { zend_ffi_expr_int_math(val, op2, %); // ??? } @@ -7758,7 +7755,7 @@ void zend_ffi_expr_sizeof_val(zend_ffi_val *val) /* {{{ */ void zend_ffi_expr_sizeof_type(zend_ffi_val *val, zend_ffi_dcl *dcl) /* {{{ */ { - zend_ffi_type *type; + const zend_ffi_type *type; zend_ffi_finalize_type(dcl); type = ZEND_FFI_TYPE(dcl->type); diff --git a/ext/ffi/php_ffi.h b/ext/ffi/php_ffi.h index 430b8a2e568f8..ba92947e62bf4 100644 --- a/ext/ffi/php_ffi.h +++ b/ext/ffi/php_ffi.h @@ -217,45 +217,45 @@ void zend_ffi_resolve_typedef(const char *name, size_t name_len, zend_ffi_dcl *d void zend_ffi_resolve_const(const char *name, size_t name_len, zend_ffi_val *val); void zend_ffi_declare_tag(const char *name, size_t name_len, zend_ffi_dcl *dcl, bool incomplete); void zend_ffi_make_enum_type(zend_ffi_dcl *dcl); -void zend_ffi_add_enum_val(zend_ffi_dcl *enum_dcl, const char *name, size_t name_len, zend_ffi_val *val, int64_t *min, int64_t *max, int64_t *last); +void zend_ffi_add_enum_val(zend_ffi_dcl *enum_dcl, const char *name, size_t name_len, const zend_ffi_val *val, int64_t *min, int64_t *max, int64_t *last); void zend_ffi_make_struct_type(zend_ffi_dcl *dcl); void zend_ffi_add_field(zend_ffi_dcl *struct_dcl, const char *name, size_t name_len, zend_ffi_dcl *field_dcl); void zend_ffi_add_anonymous_field(zend_ffi_dcl *struct_dcl, zend_ffi_dcl *field_dcl); -void zend_ffi_add_bit_field(zend_ffi_dcl *struct_dcl, const char *name, size_t name_len, zend_ffi_dcl *field_dcl, zend_ffi_val *bits); +void zend_ffi_add_bit_field(zend_ffi_dcl *struct_dcl, const char *name, size_t name_len, zend_ffi_dcl *field_dcl, const zend_ffi_val *bits); void zend_ffi_adjust_struct_size(zend_ffi_dcl *dcl); void zend_ffi_make_pointer_type(zend_ffi_dcl *dcl); -void zend_ffi_make_array_type(zend_ffi_dcl *dcl, zend_ffi_val *len); +void zend_ffi_make_array_type(zend_ffi_dcl *dcl, const zend_ffi_val *len); void zend_ffi_make_func_type(zend_ffi_dcl *dcl, HashTable *args, zend_ffi_dcl *nested_dcl); void zend_ffi_add_arg(HashTable **args, const char *name, size_t name_len, zend_ffi_dcl *arg_dcl); void zend_ffi_declare(const char *name, size_t name_len, zend_ffi_dcl *dcl); void zend_ffi_add_attribute(zend_ffi_dcl *dcl, const char *name, size_t name_len); -void zend_ffi_add_attribute_value(zend_ffi_dcl *dcl, const char *name, size_t name_len, int n, zend_ffi_val *val); -void zend_ffi_add_msvc_attribute_value(zend_ffi_dcl *dcl, const char *name, size_t name_len, zend_ffi_val *val); +void zend_ffi_add_attribute_value(zend_ffi_dcl *dcl, const char *name, size_t name_len, int n, const zend_ffi_val *val); +void zend_ffi_add_msvc_attribute_value(zend_ffi_dcl *dcl, const char *name, size_t name_len, const zend_ffi_val *val); void zend_ffi_set_abi(zend_ffi_dcl *dcl, uint16_t abi); void zend_ffi_nested_declaration(zend_ffi_dcl *dcl, zend_ffi_dcl *nested_dcl); void zend_ffi_align_as_type(zend_ffi_dcl *dcl, zend_ffi_dcl *align_dcl); -void zend_ffi_align_as_val(zend_ffi_dcl *dcl, zend_ffi_val *align_val); +void zend_ffi_align_as_val(zend_ffi_dcl *dcl, const zend_ffi_val *align_val); void zend_ffi_validate_type_name(zend_ffi_dcl *dcl); -void zend_ffi_expr_conditional(zend_ffi_val *val, zend_ffi_val *op2, zend_ffi_val *op3); +void zend_ffi_expr_conditional(zend_ffi_val *val, const zend_ffi_val *op2, const zend_ffi_val *op3); void zend_ffi_expr_bool_or(zend_ffi_val *val, zend_ffi_val *op2); void zend_ffi_expr_bool_and(zend_ffi_val *val, zend_ffi_val *op2); -void zend_ffi_expr_bw_or(zend_ffi_val *val, zend_ffi_val *op2); -void zend_ffi_expr_bw_xor(zend_ffi_val *val, zend_ffi_val *op2); -void zend_ffi_expr_bw_and(zend_ffi_val *val, zend_ffi_val *op2); -void zend_ffi_expr_is_equal(zend_ffi_val *val, zend_ffi_val *op2); -void zend_ffi_expr_is_not_equal(zend_ffi_val *val, zend_ffi_val *op2); -void zend_ffi_expr_is_less(zend_ffi_val *val, zend_ffi_val *op2); -void zend_ffi_expr_is_greater(zend_ffi_val *val, zend_ffi_val *op2); -void zend_ffi_expr_is_less_or_equal(zend_ffi_val *val, zend_ffi_val *op2); -void zend_ffi_expr_is_greater_or_equal(zend_ffi_val *val, zend_ffi_val *op2); -void zend_ffi_expr_shift_left(zend_ffi_val *val, zend_ffi_val *op2); -void zend_ffi_expr_shift_right(zend_ffi_val *val, zend_ffi_val *op2); -void zend_ffi_expr_add(zend_ffi_val *val, zend_ffi_val *op2); -void zend_ffi_expr_sub(zend_ffi_val *val, zend_ffi_val *op2); -void zend_ffi_expr_mul(zend_ffi_val *val, zend_ffi_val *op2); -void zend_ffi_expr_div(zend_ffi_val *val, zend_ffi_val *op2); -void zend_ffi_expr_mod(zend_ffi_val *val, zend_ffi_val *op2); +void zend_ffi_expr_bw_or(zend_ffi_val *val, const zend_ffi_val *op2); +void zend_ffi_expr_bw_xor(zend_ffi_val *val, const zend_ffi_val *op2); +void zend_ffi_expr_bw_and(zend_ffi_val *val, const zend_ffi_val *op2); +void zend_ffi_expr_is_equal(zend_ffi_val *val, const zend_ffi_val *op2); +void zend_ffi_expr_is_not_equal(zend_ffi_val *val, const zend_ffi_val *op2); +void zend_ffi_expr_is_less(zend_ffi_val *val, const zend_ffi_val *op2); +void zend_ffi_expr_is_greater(zend_ffi_val *val, const zend_ffi_val *op2); +void zend_ffi_expr_is_less_or_equal(zend_ffi_val *val, const zend_ffi_val *op2); +void zend_ffi_expr_is_greater_or_equal(zend_ffi_val *val, const zend_ffi_val *op2); +void zend_ffi_expr_shift_left(zend_ffi_val *val, const zend_ffi_val *op2); +void zend_ffi_expr_shift_right(zend_ffi_val *val, const zend_ffi_val *op2); +void zend_ffi_expr_add(zend_ffi_val *val, const zend_ffi_val *op2); +void zend_ffi_expr_sub(zend_ffi_val *val, const zend_ffi_val *op2); +void zend_ffi_expr_mul(zend_ffi_val *val, const zend_ffi_val *op2); +void zend_ffi_expr_div(zend_ffi_val *val, const zend_ffi_val *op2); +void zend_ffi_expr_mod(zend_ffi_val *val, const zend_ffi_val *op2); void zend_ffi_expr_cast(zend_ffi_val *val, zend_ffi_dcl *dcl); void zend_ffi_expr_plus(zend_ffi_val *val); void zend_ffi_expr_neg(zend_ffi_val *val);