-
Notifications
You must be signed in to change notification settings - Fork 97
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
Use unboxed types for uint8_t and uint16_t #413
Conversation
Thank you. I think this is a worthwhile change. The tests are failing on OCaml 4.01.0 because of the |
[@@inline] is not supported by OCaml 4.01, so remove it.
@yallop I removed the |
let to_int64 : t -> int64 = fun x -> to_int x |> Int64.of_int [@@inline] | ||
external of_string : string -> t = "ctypes_uint8_of_string" [@@inline] | ||
let to_string : t -> string = string_of_int [@@inline] | ||
let of_int64 : int64 -> t = fun x -> of_int (Int64.to_int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Int64.to_int)
~> (Int64.to_int x)
This caused compilation to fail with a typing error.
The patch changes the behaviour around unrepresentable values in a couple of ways:
Could you please switch the patch over to the existing behaviour? |
I had previously (and incompatibly) changed the overflow behavior of uint8 and uint16 such that they failed to check for overflow during arithmatic, and raised Invalid_argument when an overflow occurred durint their creation (in of_int). This patch fixes both of those.
@yallop done. I just noticed that there are no tests for this behavior – should I add some? |
Thanks. Yes, some tests would be very welcome. |
Add tests for coercions of unsigned integers
Tests added. |
Thanks for the tests. Could you please address the following minor cosmetic issues? Once they're fixed I'm happy to merge this PR.
|
Deletes commented-out code, fixes naming of ctypes_copy_uint16 and ctypes_copy_uint8, and adds unit tests.
I replaced the commented-out |
Thank you! |
This PR changes the representation of
uint8_t
anduint16_t
to be unboxed values. This should be a performance win.