From 2eab114a120c7818861c0640ecdc300cf7366e53 Mon Sep 17 00:00:00 2001 From: Marcos Magueta Date: Sat, 26 Oct 2024 14:26:10 -0300 Subject: Basic storage with C interop (#1) * writer command design * dune build with shared core lib * port c lib project inside ocaml * os specific dynamic link * fix project name on flake * fix: cmake cxx version breaking merklecpp * finish write to disk and update maps func * add non atomic commit to transaction graph * merkle tree binding for generating root hash * disk module refactor --------- Co-authored-by: Renan Lopes --- lib/core_functions.ml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/core_functions.ml (limited to 'lib/core_functions.ml') diff --git a/lib/core_functions.ml b/lib/core_functions.ml new file mode 100644 index 0000000..1e1af37 --- /dev/null +++ b/lib/core_functions.ml @@ -0,0 +1,21 @@ +(* open Ctypes *) + +module Types = Types_generated + +module Functions (F : Ctypes.FOREIGN) = struct + (* open F *) + 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) + let merkle_generate_root = Foreign.foreign ~from:libmerklecpp "merkle_generate_root" (ptr Ctypes.string @-> int @-> ptr char @-> returning void) + +end -- cgit v1.2.3