package extunix

  1. Overview
  2. Docs

host endian functions

  • author Goswin von Brederlow
val unsafe_get_uint8 : 'a carray8 -> int -> int

unsafe_get_X buf off extract integer of type X from a buffer buf starting at offset off. Unsigned types are 0 extended and signed types are sign extended to fill the ocaml type. Bounds checking is not performed. Use with caution and only when the program logic guarantees that the access is within bounds.

Note: The 31bit functions extract a 32bit integer and return it as ocaml int. On 32bit platforms this can overflow as ocaml integers are 31bit signed there. No error is reported if this occurs. Use with care. Note: The same applies to 63bit functions.

val unsafe_get_int8 : 'a carray8 -> int -> int
val unsafe_get_uint16 : 'a carray8 -> int -> int
val unsafe_get_int16 : 'a carray8 -> int -> int
val unsafe_get_uint31 : 'a carray8 -> int -> int
val unsafe_get_int31 : 'a carray8 -> int -> int
val unsafe_get_int32 : 'a carray8 -> int -> int32
val unsafe_get_uint63 : 'a carray8 -> int -> int
val unsafe_get_int63 : 'a carray8 -> int -> int
val unsafe_get_int64 : 'a carray8 -> int -> int64

get_X buf off same as unsafe_get_X but with bounds checking.

val get_uint16 : ('a, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> int -> int
val get_uint31 : ('a, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> int -> int
val get_int32 : ('a, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> int -> int32
val get_uint63 : ('a, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> int -> int
val get_int64 : ('a, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> int -> int64
val unsafe_set_uint8 : 'a carray8 -> int -> int -> unit

unsafe_set_X buf off v stores the integer v as type X in a buffer buf starting at offset off. Bounds checking is not performed. Use with caution and only when the program logic guarantees that the access is within bounds.

Note: The 31bit functions store an ocaml int as 32bit integer. On 32bit platforms ocaml integers are 31bit signed and will be sign extended to 32bit first. Use with care. Note: The same applies to 63bit functions.

val unsafe_set_int8 : 'a carray8 -> int -> int -> unit
val unsafe_set_uint16 : 'a carray8 -> int -> int -> unit
val unsafe_set_int16 : 'a carray8 -> int -> int -> unit
val unsafe_set_uint31 : 'a carray8 -> int -> int -> unit
val unsafe_set_int31 : 'a carray8 -> int -> int -> unit
val unsafe_set_int32 : 'a carray8 -> int -> int32 -> unit
val unsafe_set_uint63 : 'a carray8 -> int -> int -> unit
val unsafe_set_int63 : 'a carray8 -> int -> int -> unit
val unsafe_set_int64 : 'a carray8 -> int -> int64 -> unit
val set_uint8 : ('a, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> int -> int -> unit

set_X buf off v same as unsafe_set_X but with bounds checking.

val set_int8 : ('a, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> int -> int -> unit
val set_uint16 : ('a, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> int -> int -> unit
val set_int16 : ('a, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> int -> int -> unit
val set_uint31 : ('a, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> int -> int -> unit
val set_int31 : ('a, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> int -> int -> unit
val set_int32 : ('a, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> int -> int32 -> unit
val set_uint63 : ('a, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> int -> int -> unit
val set_int63 : ('a, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> int -> int -> unit
val set_int64 : ('a, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> int -> int64 -> unit
OCaml

Innovation. Community. Security.