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

24 bit types #50

Open
avsm opened this issue Feb 11, 2015 · 2 comments
Open

24 bit types #50

avsm opened this issue Feb 11, 2015 · 2 comments

Comments

@avsm
Copy link
Member

avsm commented Feb 11, 2015

I notice a comment in ocaml-tls that should be integrated into cstruct:

(* HACK: 24 bits type not in cstruct *)
let get_uint24_len buf =
  (Cstruct.BE.get_uint16 buf 0) * 0x100 + (Cstruct.get_uint8 buf 2)

let set_uint24_len buf num =
  Cstruct.BE.set_uint16 buf 0 (num / 0x100);
  Cstruct.set_uint8 buf 2 (num mod 0x100)

@jgjl
Copy link

jgjl commented Apr 2, 2016

Would it make sense to switch to Stdint (https://github.com/andrenth/ocaml-stdint) for value types to improve this issue? They have a uint24 type and others in one byte steps up to 128bits.

@hannesm
Copy link
Member

hannesm commented Nov 15, 2017

as a matter of fact, I discovered that 48bit fields are also in use -- Time Signed u_int48_t seconds since 1-Jan-70 UTC from https://tools.ietf.org/html/rfc2845 (if anyone is interested)... 48bit need to be converted to int64 if we want to stay 32bit compatible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants