My working unpac space for OCaml projects in development
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge opam/patches/zstd

+242
+3
vendor/opam/zstd/.gitignore
··· 1 + _build/ 2 + *.merlin 3 + *.install
+34
vendor/opam/zstd/Makefile
··· 1 + build: 2 + dune build 3 + 4 + doc: 5 + dune build @doc 6 + 7 + test: 8 + dune runtest 9 + 10 + all: build doc test 11 + 12 + install: 13 + dune install 14 + 15 + uninstall: 16 + dune uninstall 17 + 18 + 19 + clean: 20 + dune clean 21 + 22 + .PHONY: build doc test all install uninstall clean 23 + 24 + VERSION=0.4 25 + NAME=zstd-$(VERSION) 26 + 27 + .PHONY: release 28 + release: 29 + dune-release tag v$(VERSION) 30 + dune-release distrib 31 + gpg -a -b _build/$(NAME).tbz -o $(NAME).tbz.asc 32 + dune-release publish -m "" 33 + dune-release opam pkg 34 + dune-release opam submit -m ""
+5
vendor/opam/zstd/dune-project
··· 1 + (lang dune 3.7) 2 + (using ctypes 0.3) 3 + 4 + (name zstd) 5 + (implicit_transitive_deps false)
+4
vendor/opam/zstd/src/dune
··· 1 + (library 2 + (public_name zstd) 3 + (modules zstd) 4 + (libraries ctypes.stubs integers zstd.stubs))
+62
vendor/opam/zstd/src/zstd.ml
··· 1 + open Zstd_stubs 2 + 3 + module Size_t = Unsigned.Size_t 4 + module F = C.Functions 5 + module T = C.Types 6 + 7 + exception Error of string 8 + 9 + let version () = 10 + let n = F.version_number () in 11 + (n / 10_000, (n / 100) mod 100, n mod 100) 12 + 13 + let bracket res destroy k = 14 + let r = try k res with exn -> let () = destroy res in raise exn in 15 + let () = destroy res in 16 + r 17 + 18 + let check r = if F.is_error r then raise (Error (F.get_error_name r)) 19 + 20 + let free_cctx x = check (F.free_cctx x) 21 + let free_dctx x = check (F.free_dctx x) 22 + 23 + let compress ~level ?dict s = 24 + let open Ctypes in 25 + let len = Size_t.of_int (String.length s) in 26 + let dst_size = F.compress_bound len in 27 + let dst = allocate_n char ~count:(Size_t.to_int dst_size) in 28 + let r = 29 + match dict with 30 + | None -> F.compress (to_voidp dst) dst_size s len level 31 + | Some dict -> 32 + let dlen = Size_t.of_int (String.length dict) in 33 + bracket (F.create_cctx ()) free_cctx begin fun cctx -> 34 + F.compress_using_dict cctx (to_voidp dst) dst_size s len dict dlen level 35 + end 36 + in 37 + check r; 38 + string_from_ptr dst ~length:(Size_t.to_int r) 39 + 40 + let decompress orig ?dict s = 41 + let open Ctypes in 42 + let dst = allocate_n char ~count:orig in 43 + let r = 44 + match dict with 45 + | None -> F.decompress (to_voidp dst) (Size_t.of_int orig) s (Size_t.of_int (String.length s)) 46 + | Some dict -> 47 + let dlen = Size_t.of_int (String.length dict) in 48 + bracket (F.create_dctx ()) free_dctx begin fun dctx -> 49 + F.decompress_using_dict dctx (to_voidp dst) (Size_t.of_int orig) s (Size_t.of_int (String.length s)) dict dlen 50 + end 51 + in 52 + check r; 53 + string_from_ptr dst ~length:(Size_t.to_int r) 54 + 55 + let get_decompressed_size s = 56 + let r = F.get_frame_content_size s (Size_t.of_int (String.length s)) in 57 + if r = T.content_size_error then 58 + raise (Error "content size error") 59 + else if r = T.content_size_unknown then 60 + raise (Error "content size unknown") 61 + else 62 + Unsigned.ULLong.to_int r
+18
vendor/opam/zstd/src/zstd.mli
··· 1 + (** Zstandard - fast lossless compression algorithm *) 2 + 3 + exception Error of string 4 + 5 + val version : unit -> (int * int * int) 6 + 7 + (** [dict] optional pre-defined dictionary content (see dictBuilder) *) 8 + val compress : level:int -> ?dict:string -> string -> string 9 + 10 + (** 11 + [decompress orig_size ?dict s] 12 + 13 + [orig_size] specifies size of buffer for decompression (not less than original size of uncompressed [s]) 14 + [dict] must be identical to the one used during compression, otherwise uncompressed data will be corrupted. 15 + *) 16 + val decompress : int -> ?dict:string -> string -> string 17 + 18 + val get_decompressed_size : string -> int
+16
vendor/opam/zstd/stubs/dune
··· 1 + (library 2 + (name zstd_stubs) 3 + (public_name zstd.stubs) 4 + (libraries ctypes.stubs integers) 5 + (ctypes 6 + (external_library_name libzstd) 7 + (headers (include "zstd.h")) 8 + (type_description 9 + (instance Types) 10 + (functor Type_description)) 11 + (function_description 12 + (concurrency unlocked) 13 + (instance Functions) 14 + (functor Function_description)) 15 + (generated_types Types_generated) 16 + (generated_entry_point C)))
+35
vendor/opam/zstd/stubs/function_description.ml
··· 1 + open Ctypes 2 + 3 + module Types = Types_generated 4 + 5 + module Functions (F : Cstubs.FOREIGN) = struct 6 + open F 7 + 8 + let version_number = foreign "ZSTD_versionNumber" (void @-> returning int) 9 + let compress_bound = foreign "ZSTD_compressBound" (size_t @-> returning size_t) 10 + let get_error_name = foreign "ZSTD_getErrorName" (size_t @-> returning string) 11 + let is_error = foreign "ZSTD_isError" (size_t @-> returning bool) 12 + 13 + let get_frame_content_size = foreign "ZSTD_getFrameContentSize" (string @-> size_t @-> returning ullong) 14 + 15 + let compress = foreign "ZSTD_compress" (ptr void @-> size_t @-> string @-> size_t @-> int @-> returning size_t) 16 + let decompress = foreign "ZSTD_decompress" (ptr void @-> size_t @-> string @-> size_t @-> returning size_t) 17 + 18 + let cctx : [`CCtx] structure typ = structure "ZSTD_CCtx_s" 19 + let create_cctx = foreign "ZSTD_createCCtx" (void @-> returning (ptr cctx)) 20 + let free_cctx = foreign "ZSTD_freeCCtx" (ptr cctx @-> returning size_t) 21 + 22 + let compress_cctx = foreign "ZSTD_compressCCtx" (ptr cctx @-> ptr void @-> size_t @-> string @-> size_t @-> int @-> returning size_t) 23 + 24 + let dctx : [`DCtx] structure typ = structure "ZSTD_DCtx_s" 25 + let create_dctx = foreign "ZSTD_createDCtx" (void @-> returning (ptr dctx)) 26 + let free_dctx = foreign "ZSTD_freeDCtx" (ptr dctx @-> returning size_t) 27 + 28 + let decompress_dctx = foreign "ZSTD_decompressDCtx" (ptr dctx @-> ptr void @-> size_t @-> string @-> size_t @-> returning size_t) 29 + 30 + let compress_using_dict = foreign "ZSTD_compress_usingDict" (ptr cctx @-> ptr void @-> size_t @-> string @-> size_t @-> 31 + string @-> size_t @-> int @-> returning size_t) 32 + 33 + let decompress_using_dict = foreign "ZSTD_decompress_usingDict" (ptr dctx @-> ptr void @-> size_t @-> string @-> size_t @-> 34 + string @-> size_t @-> returning size_t) 35 + end
+6
vendor/opam/zstd/stubs/type_description.ml
··· 1 + module Types (F : Ctypes.TYPE) = struct 2 + open F 3 + 4 + let content_size_unknown = constant "ZSTD_CONTENTSIZE_UNKNOWN" ullong 5 + let content_size_error = constant "ZSTD_CONTENTSIZE_ERROR" ullong 6 + end
+3
vendor/opam/zstd/test/dune
··· 1 + (test 2 + (name test) 3 + (libraries extlib unix zstd))
+26
vendor/opam/zstd/test/test.ml
··· 1 + open ExtLib 2 + open Printf 3 + 4 + let test (name,src) = 5 + let orig = String.length src in 6 + let a = Array.init 20 (fun level -> Zstd.compress ~level src) in 7 + a |> Array.iteri begin fun i s -> 8 + assert (Zstd.get_decompressed_size s = orig); 9 + let s = Zstd.decompress orig s in 10 + if s <> src then failwith @@ sprintf "%s : level %d failed" name i; 11 + end; 12 + let best = Array.fold_left (fun m s -> min m (String.length s)) (String.length a.(0)) a in 13 + let best_level = Array.findi (fun s -> String.length s = best) a in 14 + printf "%50s : best compression %02.1fx at level %d : %d -> %d\n" name (float orig /. float best) best_level orig best 15 + 16 + let () = 17 + let file f = try Some (f, Std.input_file f) with _ -> None in 18 + let inputs = [ 19 + file "/bin/bash"; 20 + file Sys.executable_name; 21 + file "/etc/ld.so.cache"; 22 + file "/etc/mailcap"; 23 + Some ("environment", String.concat " " @@ Array.to_list @@ Unix.environment ()); 24 + ] |> List.filter_map (fun x -> x) 25 + in 26 + List.iter test inputs
+30
vendor/opam/zstd/zstd.opam
··· 1 + opam-version: "2.0" 2 + maintainer: "ygrek@autistici.org" 3 + homepage: "https://github.com/ygrek/ocaml-zstd" 4 + license: "BSD-3-Clause" 5 + authors: [ "ygrek" ] 6 + tags: [ "org:ygrek" "clib:zstd" ] 7 + doc: [ "https://ygrek.org/p/ocaml-zstd/api/index.html" ] 8 + dev-repo: "git+https://github.com/ygrek/ocaml-zstd.git" 9 + bug-reports: "https://github.com/ygrek/ocaml-zstd/issues" 10 + build: [ 11 + ["dune" "subst"] {dev} 12 + ["dune" "build" "-p" name "-j" jobs 13 + "@install" 14 + "@doc" {with-doc} 15 + "@runtest" {with-test}] 16 + ] 17 + depends: [ 18 + "ocaml" 19 + "dune" {>= "3.7"} 20 + "ctypes" {>= "0.13.0"} 21 + "integers" 22 + ("extlib" {with-test} | "extlib-compat" {with-test}) 23 + "base-unix" {with-test} 24 + "conf-zstd" 25 + ] 26 + synopsis: "Bindings to zstd compression library" 27 + description: """ 28 + Zstd, short for Zstandard, is a fast lossless compression algorithm, 29 + targeting real-time compression scenarios at zlib-level compression ratio. 30 + See http://zstd.net/ for more info."""