-
Notifications
You must be signed in to change notification settings - Fork 16
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
Provide pure-OCaml fall-back implementation #6
Comments
Hi I agree, this and your idea of selectable behavior in #4 are nice suggestions. Currently I don't have the necessary time to work on stdint, but if you want to send a patch (or if @mwweissmann wants to do it) I'm all for it. |
Most of the <= int64 stuff is pure OCaml already; I'm not quite sure how to elegantly implement the int128 stuff that relies on special amd64 commands via gcc |
@mwweissmann what do you mean by "pure OCaml"? What I meant by it is "non-C". The interest in avoiding C is to be able to work with Js_of_ocaml. |
All integers <= 64 Bit are stored as "int" or "int64"; we should be able to rewrite all functions on them in "pure OCaml -- without C". The > 64 Bit integers (currently only 128 Bit) use some 64 Bit stuff we cannot tap into in pure OCaml. We would need a "pure OCaml" version of the 128 Bit integer which would also be nice for 32 Bit processors. |
For the record, the original implementation of Uint128 in the old ocaml-uint library was in pure OCaml. The code is still up in the old repository: https://github.com/andrenth/ocaml-uint/blob/master/lib/uint128.ml |
I have some interest in making this happen (this library is a dependency of something I want to run in the browser). From skimming the implementation, this seems pretty doable but I have some questions:
|
Maybe digestif could be a good example of that: https://github.com/mirage/digestif. It provides two implementations—one in C and one in OCaml. |
It would be nice if
stdint
had a fall-back on pure OCaml code for targets that don't support C bindings, e.g. Js_of_ocaml.I just open-sourced my pure OCaml integer implementation, which might be helpful for that:
https://github.com/keleshev/Integers.ml
The text was updated successfully, but these errors were encountered: