2024-12-06 14:38:24 +00:00
|
|
|
external unsafe_get_char : Miou_solo5.bigstring -> int -> char
|
|
|
|
= "%caml_ba_ref_1"
|
2024-12-06 13:45:17 +00:00
|
|
|
|
|
|
|
let bigstring_to_string v =
|
|
|
|
let len = Bigarray.Array1.dim v in
|
|
|
|
let res = Bytes.create len in
|
|
|
|
for i = 0 to len - 1 do
|
|
|
|
Bytes.set res i (unsafe_get_char v i)
|
|
|
|
done;
|
|
|
|
Bytes.unsafe_to_string res
|
|
|
|
|
2024-12-06 14:38:24 +00:00
|
|
|
let () =
|
|
|
|
Miou_solo5.(run [ block "simple" ]) @@ fun blk () ->
|
2024-12-06 13:45:17 +00:00
|
|
|
let pagesize = Miou_solo5.Block.pagesize blk in
|
|
|
|
let bstr = Bigarray.(Array1.create char c_layout pagesize) in
|
2024-12-06 14:38:24 +00:00
|
|
|
let prm =
|
|
|
|
Miou.async @@ fun () ->
|
2024-12-06 13:45:17 +00:00
|
|
|
Miou_solo5.Block.atomic_read blk ~off:0 bstr;
|
|
|
|
let str = bigstring_to_string bstr in
|
|
|
|
let hash = Digest.string str in
|
|
|
|
Fmt.pr "%08x: %s\n%!" 0 (Digest.to_hex hash)
|
|
|
|
in
|
2024-12-06 13:48:23 +00:00
|
|
|
Miou_solo5.Block.read blk ~off:pagesize bstr;
|
2024-12-06 13:45:17 +00:00
|
|
|
let str = bigstring_to_string bstr in
|
|
|
|
let hash = Digest.string str in
|
|
|
|
Fmt.pr "%08x: %s\n%!" pagesize (Digest.to_hex hash);
|
|
|
|
Miou.await_exn prm
|