Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src-ocaml/xor.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ module type BUFFER = sig
val sub : t -> int -> int -> t
val copy : t -> t
val benat_to_cpu : t -> int -> nativeint
val byte_to_cpu : t -> int -> int
val cpu_to_benat : t -> int -> nativeint -> unit
val cpu_to_byte : t -> int -> int -> unit
end

let imin (a : int) (b : int) = if a < b then a else b
Expand All @@ -33,10 +35,8 @@ module Make (B : BUFFER) = struct
i := !i + size_of_long
done ;
while !n > 0 do
B.cpu_to_benat dst (dst_off + !i)
Nat.(
B.benat_to_cpu src (src_off + !i)
lxor B.benat_to_cpu dst (dst_off + !i)) ;
B.cpu_to_byte dst (dst_off + !i)
(B.byte_to_cpu src (src_off + !i) lxor B.byte_to_cpu dst (dst_off + !i)) ;
incr i ;
decr n
done
Expand Down
2 changes: 2 additions & 0 deletions src/digestif_bi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ let blit_from_bytes src src_off dst dst_off len =
external swap32 : int32 -> int32 = "%bswap_int32"
external swap64 : int64 -> int64 = "%bswap_int64"
external swapnat : nativeint -> nativeint = "%bswap_native"
external byte_to_cpu : t -> int -> int = "%caml_ba_unsafe_ref_1"
external cpu_to_byte : t -> int -> int -> unit = "%caml_ba_unsafe_set_1"

let cpu_to_be32 s i v =
if Sys.big_endian then unsafe_set_32 s i v else unsafe_set_32 s i (swap32 v)
Expand Down
2 changes: 2 additions & 0 deletions src/digestif_by.ml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ let rpad a size x =
external swap32 : int32 -> int32 = "%bswap_int32"
external swap64 : int64 -> int64 = "%bswap_int64"
external swapnat : nativeint -> nativeint = "%bswap_native"
external cpu_to_byte : t -> int -> int -> unit = "%bytes_unsafe_set"
external byte_to_cpu : t -> int -> int = "%bytes_unsafe_get"

let cpu_to_be32 s i v =
if Sys.big_endian then unsafe_set_32 s i v else unsafe_set_32 s i (swap32 v)
Expand Down
Loading