]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.4'
authorDmitry Stogov <dmitry@zend.com>
Thu, 12 Mar 2020 08:41:12 +0000 (11:41 +0300)
committerDmitry Stogov <dmitry@zend.com>
Thu, 12 Mar 2020 08:41:12 +0000 (11:41 +0300)
* PHP-7.4:
  Allow to fetch function address

1  2 
ext/ffi/ffi.c

diff --cc ext/ffi/ffi.c
index 6014a4660c3a049775296ed5a391f27e2c106a11,ec9cdb17cae23f49cb77f4577b46f36a00e584ac..9b2640648676d04e418c41629a56568dffb6b44c
@@@ -2344,8 -2364,29 +2344,26 @@@ static zval *zend_ffi_read_var(zend_obj
                return &EG(uninitialized_zval);
        }
  
 -      zend_tmp_string_release(tmp_var_name);
 -
        if (sym->kind == ZEND_FFI_SYM_VAR) {
                zend_ffi_cdata_to_zval(NULL, sym->addr, ZEND_FFI_TYPE(sym->type), read_type, rv, (zend_ffi_flags)sym->is_const, 0);
+       } else if (sym->kind == ZEND_FFI_SYM_FUNC) {
+               zend_ffi_cdata *cdata;
+               zend_ffi_type *new_type = emalloc(sizeof(zend_ffi_type));
+               new_type->kind = ZEND_FFI_TYPE_POINTER;
+               new_type->attr = 0;
+               new_type->size = sizeof(void*);
+               new_type->align = _Alignof(void*);
+               new_type->pointer.type = ZEND_FFI_TYPE(sym->type);
+               cdata = emalloc(sizeof(zend_ffi_cdata));
+               zend_ffi_object_init(&cdata->std, zend_ffi_cdata_ce);
+               cdata->std.handlers = &zend_ffi_cdata_handlers;
+               cdata->type = ZEND_FFI_TYPE_MAKE_OWNED(new_type);
+               cdata->flags = ZEND_FFI_FLAG_CONST;
+               cdata->ptr_holder = sym->addr;
+               cdata->ptr = &cdata->ptr_holder;
+               ZVAL_OBJ(rv, &cdata->std);
        } else {
                ZVAL_LONG(rv, sym->value);
        }