-
Notifications
You must be signed in to change notification settings - Fork 49
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
Wasm: remove libc dependency #26
Comments
Hi. There are The relevant subdirectory is this: https://github.com/Frommi/miniz_oxide/tree/master/miniz_oxide. |
libc has been used for C interoperability and memory allocation. Doing the same for flate2 may be a bit more involved, currently it interfaces miniz_oxide with a C api which mimics the ones for miniz and zlib, so avoiding that would require some larger changes to flate2 internals. I do think it would be a good idea though to avoid unsafetyness that comes with C code. Maybe it would even make sense to split the C api and the flate2 brigding code. |
@oyvindln Thanks for this detailed explanation. I will try to help the best I could :) |
Just doing pub type PutBufFuncPtrNotNull = unsafe extern "C" fn(*const (), i32, *mut ()) -> bool; does compile just fine with wasm32-unknown-unknown. Not sure how good this is for the C side though... |
libc defines c_int as i32 and *c_void as a pointer to a u8 on all platforms outside of wasm, so that may be safe. Just in case though I think it's probably safest to redefine it only on wasm conditionally for now. A proper fix later should be to alter the rust API to use a safe rust callback. |
I changed the function signature on wasm32 (similar to how libc defines nothing on the target) in the latest commit, and changed MZFlush and TDEFFLush new functions to take an |
In this commit I replaced callback function pointer by closure and removed There are breaking changes, so before version bump there is an opportunity to introduce other breaking changes, so there will be some time before this hits a crate release. |
No, it is a mistake. Thanks for pointing out. I intended to rewrite only last commit. I made it from other computer and wanted to set author to this acount. Any idea how to revert? |
I think I restored old history. Thanks again. |
Look good to me! |
By the way, with only a modest amount of hacking, I was able to use this latest code (via the zip-rs crate) to decode zip files using the wasm32-unknown-unknown target in a browser. Pretty cool! |
@eminence Can you share your hacks on this? Maybe a github repo? |
Hi,
Currently,
miniz_oxide
is not buildable withwasm32-unknown-unknown
as target.I would like to help to remove
libc
to be able to useflate2
inside a browser.Unfortunately I have no knowledge in miniz/zlib api.
Do you think it's doable? Can you give me guidance to do it?
From what I understand it's highly related to #3 .
Thanks.
The text was updated successfully, but these errors were encountered: