Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for PowerPC: handle libffi's integer return type promotion #405

Merged
merged 3 commits into from
Jun 18, 2016
Merged

Fix for PowerPC: handle libffi's integer return type promotion #405

merged 3 commits into from
Jun 18, 2016

Conversation

yallop
Copy link
Owner

@yallop yallop commented Jun 18, 2016

When the return type of a function is an integer type narrower than the system register size, libffi promotes it to ffi_arg.

On big-endian systems, this causes problems with calls to functions that return small integers (char, short, etc.), since libffi writes the return value to an ffi_arg-sized slot, and ctypes attempts to read the value from the same address using a pointer to the return type rather than a pointer to ffi_arg.

This pull request adds a compensating offset to the return value address passed to ctypes on big-endian systems for both regular function calls (d00922e) and callbacks (d6c200a), and a new test for callbacks that return small integers (9f3cb97).

@yallop yallop merged commit 07f4f1d into yallop:master Jun 18, 2016
@yallop yallop deleted the return-type-promotion branch June 18, 2016 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant