diff options
| author | Marcos Magueta <maguetamarcos@gmail.com> | 2026-04-04 17:10:32 -0300 |
|---|---|---|
| committer | Marcos Magueta <maguetamarcos@gmail.com> | 2026-04-04 17:10:32 -0300 |
| commit | d3708bb28adcd0220142f1890ab96bfd2df637d3 (patch) | |
| tree | 29da1e5e79c0481cb364bdc9d1da0147da0200fd /lib | |
| parent | 63ae3c930de89af6f85229a467caa3f53cb844a2 (diff) | |
| download | Sakura-d3708bb28adcd0220142f1890ab96bfd2df637d3.tar.gz Sakura-d3708bb28adcd0220142f1890ab96bfd2df637d3.zip | |
remove interop with c
Diffstat (limited to '')
| -rw-r--r-- | lib/conventions.ml | 6 | ||||
| -rw-r--r-- | lib/core_functions.ml | 23 | ||||
| -rw-r--r-- | lib/core_types.ml | 3 | ||||
| -rw-r--r-- | lib/dune | 30 | ||||
| -rw-r--r-- | lib/interop.ml | 11 |
5 files changed, 5 insertions, 68 deletions
diff --git a/lib/conventions.ml b/lib/conventions.ml index b6f82a5..de04712 100644 --- a/lib/conventions.ml +++ b/lib/conventions.ml @@ -1,7 +1,7 @@ module Hash = struct - type t = Interop.Sha256.t + type t = string - let hash_text text = Interop.Sha256.compute_hash (Bytes.of_string text) + let hash_text text = Sha256.to_hex (Sha256.string text) let compare = String.compare let sexp_of_t = Sexplib.Std.sexp_of_string end @@ -25,7 +25,7 @@ end module AbstractValue = struct type t = Obj.t - let hash (elem : t) = Interop.Sha256.compute_hash @@ Marshal.to_bytes elem [] + let hash (elem : t) = Sha256.to_hex (Sha256.string (Bytes.to_string (Marshal.to_bytes elem []))) let sexp_of_t (v : t) = let open Sexplib.Sexp in diff --git a/lib/core_functions.ml b/lib/core_functions.ml deleted file mode 100644 index 9cb6213..0000000 --- a/lib/core_functions.ml +++ /dev/null @@ -1,23 +0,0 @@ -module Types = Types_generated - -module Functions (F : Ctypes.FOREIGN) = struct - open Ctypes_static - - let os_extension = - if Sys.os_type = "Unix" then - let ic = Unix.open_process_in "uname" in - let uname = input_line ic in - let () = close_in ic in - if uname = "Darwin" then "dylib" else "so" - else "dll" - - let libmerklecpp = - Dl.dlopen ~flags:[ RTLD_GLOBAL; RTLD_NOW ] - ~filename: - (Sys.getenv "LIBRELATIONAL_ENGINE_LIB_PATH" - ^ "/librelational_engine." ^ os_extension) - - let compute_hash = - Foreign.foreign ~from:libmerklecpp "compute_hash" - (ptr char @-> Ctypes.string @-> returning void) -end diff --git a/lib/core_types.ml b/lib/core_types.ml deleted file mode 100644 index 45f5720..0000000 --- a/lib/core_types.ml +++ /dev/null @@ -1,3 +0,0 @@ -module Types (F : Ctypes.TYPE) = struct - let hash_size = F.constant "HASH_SIZE" F.int -end @@ -3,8 +3,7 @@ (library (name relational_engine) (libraries - ctypes - ctypes-foreign + sha data-encoding lwt lwt.unix @@ -13,29 +12,4 @@ ppx_protocol_conv_xml_light sexplib) (preprocess - (pps ppx_deriving.show ppx_sexp_conv ppx_protocol_conv)) - ;; (c_library_flags -lssl -lcrypto -L %{env:LIBRESSL_LIB_PATH=}) - ;; (foreign_stubs - ;; (language cxx) - ;; (names merklecpp_stubs) - ;; (flags - ;; (:standard -lssl -lcrypto) - ;; (-L %{env:LIBRESSL_LIB_PATH=}) - ;; (-I %{env:LIBRESSL_INCLUDE_PATH=}) - ;; (-I %{env:MERKLECPP_INCLUDE_PATH=}))) - (ctypes - (external_library_name relational_engine) - (headers - (include %{env:LIBRELATIONAL_ENGINE_INCLUDE_PATH=}/library.h)) - (build_flags_resolver - (vendored - (c_flags -L %{env:LIBRELATIONAL_ENGINE_LIB_PATH=}))) - (type_description - (instance Types) - (functor core_types)) - (function_description - (concurrency unlocked) - (instance Functions) - (functor core_functions)) - (generated_types Types_generated) - (generated_entry_point C))) + (pps ppx_deriving.show ppx_sexp_conv ppx_protocol_conv))) diff --git a/lib/interop.ml b/lib/interop.ml deleted file mode 100644 index 8cbc05c..0000000 --- a/lib/interop.ml +++ /dev/null @@ -1,11 +0,0 @@ -open Ctypes - -module Sha256 = struct - type t = string - - let compute_hash content : t = - let size_with_null_terminator = C.Types.hash_size + 1 in - let buf = Ctypes.allocate_n char ~count:size_with_null_terminator in - let () = C.Functions.compute_hash buf (Bytes.to_string content) in - Ctypes.coerce (ptr char) Ctypes.string buf -end |
