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

Windows Support #3

Closed
Xuanwo opened this issue Jul 13, 2024 · 4 comments
Closed

Windows Support #3

Xuanwo opened this issue Jul 13, 2024 · 4 comments

Comments

@Xuanwo
Copy link

Xuanwo commented Jul 13, 2024

Thank you so much for developing this library! It's fantastic, and opendal-go is now based on it.

I'm opening this issue to explore the possibility of adding Windows support to this library. From what I understand, both libffi and purego already support Windows.

Perhaps we could enable Windows support for this library as well? Are there any known blockers of this support?

@yuchanns and I are interested in helping to implement this support. Pleaes let us know if anything we can help.

@JupiterRider
Copy link
Owner

@Xuanwo It's a great honor that my library is used in a Apache project :D

I added the support for Windows in the dev.windows branch.
You could help by reviewing the code and running it on a actual Windows Computer.

Note that it requires you to have a libffi-8.dll next to the executable/root folder of your project or inside C:\Windows\System32. If you don't want to build libffi from source, you can find this dll for example inside the "Windows embeddable package" of Python: https://www.python.org/downloads/windows/

@Xuanwo
Copy link
Author

Xuanwo commented Jul 14, 2024

Perfect! We will evaluate windows support after our first release.

@JupiterRider
Copy link
Owner

@Xuanwo @yuchanns Please also note my latest commit f642a84.

libffi doesn't support integer return values, which are smaller than the word-size. This is what they C-documentation says about ffi_call:

rvalue is a pointer to a chunk of memory that will hold the result of the function call. This must be large enough to hold the result, no smaller than the system register size (generally 32 or 64 bits), and must be suitably aligned; it is the caller’s responsibility to ensure this. If cif declares that the function returns void (using ffi_type_void), then rvalue is ignored.

In most situations, ‘libffi’ will handle promotion according to the ABI. However, for historical reasons, there is a special case with return values that must be handled by your code. In particular, for integral (not struct) types that are narrower than the system register size, the return value will be widened by ‘libffi’. ‘libffi’ provides a type, ffi_arg, that can be used as the return type. For example, if the CIF was defined with a return type of char, ‘libffi’ will try to store a full ffi_arg into the return value.

@JupiterRider
Copy link
Owner

In the meanwhile I could successfully test the Windows implementation. It has now been released with v0.1.0-beta.10

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

No branches or pull requests

2 participants