Skip to content
Open
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
2 changes: 1 addition & 1 deletion cstruct-async.opam
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ build: [
]
depends: [
"ocaml" {>= "4.08.0"}
"dune" {>= "2.0.0"}
"dune" {>= "3.17"}
"async" {>= "v0.9.0" & < "v0.17.0"}
"async_unix" {>= "v0.9.0" & < "v0.17.0"}
"core" {>= "v0.9.0" & < "v0.17.0"}
Expand Down
2 changes: 1 addition & 1 deletion cstruct-lwt.opam
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ build: [
depends: [
"ocaml" {>= "4.08.0"}
"base-unix"
"dune" {>= "2.0.0"}
"dune" {>= "3.17"}
"lwt"
"cstruct" {=version}
]
Expand Down
2 changes: 1 addition & 1 deletion cstruct-sexp.opam
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ build: [
]
depends: [
"ocaml" {>= "4.08.0"}
"dune" {>= "2.0.0"}
"dune" {>= "3.17"}
"sexplib"
"cstruct" {=version}
"alcotest" {with-test}
Expand Down
2 changes: 1 addition & 1 deletion cstruct-unix.opam
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ build: [
]
depends: [
"ocaml" {>= "4.06.0"}
"dune" {>= "2.0.0"}
"dune" {>= "3.17"}
"base-unix"
"cstruct" {=version}
]
Expand Down
2 changes: 1 addition & 1 deletion cstruct.opam
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ build: [
]
depends: [
"ocaml" {>= "4.08.0"}
"dune" {>= "2.0.0"}
"dune" {>= "3.17"}
"alcotest" {with-test}
"fmt" {>= "0.8.9"}
"crowbar" {with-test & >= "0.2"}
Expand Down
4 changes: 1 addition & 3 deletions dune-project
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
(lang dune 2.0)

(allow_approximate_merlin)
(lang dune 3.17)

(name cstruct)
2 changes: 0 additions & 2 deletions fuzz/fuzz.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ let bytes = map [bytes] Bytes.unsafe_of_string

let buffer = map [uint8] Bigarray.(Array1.create Char c_layout)

let pp_cstruct f c = Format.pp_print_string f (Cstruct.debug c)

let check_within ~base x =
check Cstruct.(base.off <= x.off);
check Cstruct.(base.off + base.len >= x.off + x.len);
Expand Down
39 changes: 39 additions & 0 deletions lib/cstruct.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
;; The Wasm runtime for cstruct's bigstring primitives -- the analog of
;; cstruct.js for wasm_of_ocaml. wasm_of_ocaml's runtime already provides these
;; operations under its own bigarray names, so each cstruct primitive simply
;; re-exports the matching runtime function; only caml_check_alignment_bigstring
;; is cstruct-specific.
(module
(import "env" "caml_bigstring_blit_ba_to_ba"
(func $caml_blit_bigstring_to_bigstring
(param (ref eq)) (param (ref eq)) (param (ref eq)) (param (ref eq))
(param (ref eq)) (result (ref eq))))
(import "env" "caml_bigstring_blit_ba_to_bytes"
(func $caml_blit_bigstring_to_string
(param (ref eq)) (param (ref eq)) (param (ref eq)) (param (ref eq))
(param (ref eq)) (result (ref eq))))
(import "env" "caml_bigstring_blit_string_to_ba"
(func $caml_blit_string_to_bigstring
(param (ref eq)) (param (ref eq)) (param (ref eq)) (param (ref eq))
(param (ref eq)) (result (ref eq))))
(import "env" "caml_bigstring_memset"
(func $caml_fill_bigstring
(param (ref eq)) (param (ref eq)) (param (ref eq)) (param (ref eq))
(result (ref eq))))
(import "env" "caml_bigstring_memcmp"
(func $caml_compare_bigstring
(param (ref eq)) (param (ref eq)) (param (ref eq)) (param (ref eq))
(param (ref eq)) (result (ref eq))))

(export "caml_blit_bigstring_to_bigstring"
(func $caml_blit_bigstring_to_bigstring))
(export "caml_blit_bigstring_to_string" (func $caml_blit_bigstring_to_string))
(export "caml_blit_string_to_bigstring" (func $caml_blit_string_to_bigstring))
(export "caml_fill_bigstring" (func $caml_fill_bigstring))
(export "caml_compare_bigstring" (func $caml_compare_bigstring))

;; No fixed buffer address on Wasm, as in cstruct.js: always aligned.
(func (export "caml_check_alignment_bigstring")
(param (ref eq)) (param (ref eq)) (param (ref eq)) (result (ref eq))
(ref.i31 (i32.const 1)))
)
2 changes: 2 additions & 0 deletions lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
(wrapped false)
(js_of_ocaml
(javascript_files cstruct.js))
(wasm_of_ocaml
(wasm_files cstruct.wat))
(modules cstruct cstruct_cap))

(library
Expand Down
2 changes: 1 addition & 1 deletion ppx_cstruct.opam
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ build: [
]
depends: [
"ocaml" {>= "4.08.0"}
"dune" {>= "2.0.0"}
"dune" {>= "3.17"}
"cstruct" {=version}
"ounit" {with-test}
"ppxlib" {>= "0.16.0"}
Expand Down
2 changes: 2 additions & 0 deletions ppx_test/with-lwt/ppx_cstruct_and_lwt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ type foo64 =
let foo =
let%lwt foo = Lwt.return () in
Lwt.return foo

let () = ignore foo
Loading