Skip to content

Fix GH-9090: Support assigning function pointers in FFI - #9107

Closed
adsr wants to merge 1 commit into
php:masterfrom
adsr:gh9090_ffi_func_ptr
Closed

adsr wants to merge 1 commit into
php:masterfrom
adsr:gh9090_ffi_func_ptr

Conversation

@adsr

@adsr adsr commented Jul 22, 2022

Copy link
Copy Markdown
Contributor

No description provided.

@devnexen

Copy link
Copy Markdown
Member

Looks fine by me but cc @dstogov

@cmb69

cmb69 commented Jul 23, 2022

Copy link
Copy Markdown
Member

Thank you! On a quick glimpse, this looks good to me as well, but we should also check the calling convention compatibility (zend_ffi_type.func.abi), and maybe some other "details".

Comment thread ext/ffi/ffi.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need a check for C varags? Either way, a test for that would be nice.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, added a variadic to the test.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should check

(src_type->attr & ZEND_FFI_ATTR_VARIADIC) == (dst_type->attr & ZEND_FFI_ATTR_VARIADIC)

Also it's make sense to add check for calling convention

src_type->func.abi == dst_type->func.abi

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added those checks. Thank you.

@adsr
adsr force-pushed the gh9090_ffi_func_ptr branch from 105ce4b to 44c3558 Compare July 25, 2022 22:56

@dstogov dstogov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything else except abi and variadic looks fine.

Comment thread ext/ffi/ffi.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should check

(src_type->attr & ZEND_FFI_ATTR_VARIADIC) == (dst_type->attr & ZEND_FFI_ATTR_VARIADIC)

Also it's make sense to add check for calling convention

src_type->func.abi == dst_type->func.abi

@adsr
adsr force-pushed the gh9090_ffi_func_ptr branch from 44c3558 to 3f70649 Compare July 27, 2022 00:33
@cmb69 cmb69 closed this in 8cf9c2f Jul 27, 2022
@cmb69

cmb69 commented Jul 27, 2022

Copy link
Copy Markdown
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants