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

purego: add float32 and float64 support to callbacks #120

Merged
merged 8 commits into from
Apr 3, 2023

Conversation

TotallyGamerJet
Copy link
Collaborator

This commit adds support for float32 and float64 arguments in C callbacks. It also adds a test to check the maximum number of arguments a callback can have and that it is callback properly by purego. There is also some formatting done to the assembly.

This fixes a bug in RegisterFunc which was converting float32 into float64 when the C function expected a float32 argument. This gave unpredictable results. It also makes the behavior of SyscallN more inline with what is expected when calling it with float arguments. It no longer expects them to be float64 and it is up to the caller to convert either float32 or float64 into uintptr. SyscallN will then properly move it into the correct register
Copy link
Member

@hajimehoshi hajimehoshi left a comment

Choose a reason for hiding this comment

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

Thanks!

By the way, Does a calback work even if this mixes float32 and float64 as this arguments?

@hajimehoshi
Copy link
Member

I'm gonna sleep soon so I'll take a look tomorrow. Good night...

@TotallyGamerJet
Copy link
Collaborator Author

By the way, Does a callback work even if this mixes float32 and float64 as this arguments?

Yes! I added a test for that case (TestNewCallbackFloat32AndFloat64)

Copy link
Member

@hajimehoshi hajimehoshi left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@TotallyGamerJet TotallyGamerJet merged commit dd97be5 into ebitengine:main Apr 3, 2023
@TotallyGamerJet TotallyGamerJet deleted the float branch April 3, 2023 14:41
TotallyGamerJet added a commit to TotallyGamerJet/purego that referenced this pull request Jan 7, 2024
TotallyGamerJet added a commit that referenced this pull request Jan 7, 2024
floats and doubles were already implemented in #67 #69 #120 #171 #177
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.

2 participants