<commit_before>open Unsigned
open Ctypes

exception Error of int

module Make (C : Cstubs.Types.TYPE) = struct
  open C

  type mdb_error = unit
  let mdb_error : mdb_error typ =
    let read i =
      if i = 0 then ()
      else raise (Error i)
    in
    view ~read ~write:(fun () -> 0) int

  let uint_as_int = view ~read:UInt.to_int ~write:UInt.of_int uint
  let size_t_as_int = view ~read:Size_t.to_int ~write:Size_t.of_int size_t

  type mdb_env = unit ptr
  let mdb_env : mdb_env typ = ptr (typedef void "MDB_env")

  type mdb_mode_t = PosixTypes.mode_t
  let mdb_mode_t = PosixTypes.mode_t

  let mdb_filehandle_t : Unix.file_descr typ =
    Unix_representations.
      (view int ~read:file_descr_of_int ~write:int_of_file_descr)

  (* typedef struct MDB_txn MDB_txn; *)
  type mdb_txn = unit ptr
  let mdb_txn : mdb_txn typ = ptr (typedef void "MDB_txn")
  let mdb_txn_opt : mdb_txn option typ = ptr_opt (typedef void "MDB_txn")

  (* typedef unsigned int MDB_dbi; *)
  type mdb_dbi = Unsigned.uint
  let mdb_dbi : mdb_dbi typ = uint


  type mdb_val
  let mdb_val : mdb_val structure typ = structure "MDB_val"
  let mv_size = field mdb_val "mv_size" size_t
  let mv_data = field mdb_val "mv_data" (ptr void)
  let () = seal mdb_val<commit_msg>Use Not_found for ENOTFOUND.<commit_after>open Unsigned
open Ctypes

exception Error of int

module Make (C : Cstubs.Types.TYPE) = struct
  open C

  type mdb_error = unit
  let mdb_error : mdb_error typ =
    let read = function
      | 0 -> ()
      | -30798 -> raise Not_found
      | i -> raise (Error i)
    in
    view ~read ~write:(fun () -> 0) int

  let uint_as_int = view ~read:UInt.to_int ~write:UInt.of_int uint
  let size_t_as_int = view ~read:Size_t.to_int ~write:Size_t.of_int size_t

  type mdb_env = unit ptr
  let mdb_env : mdb_env typ = ptr (typedef void "MDB_env")

  type mdb_mode_t = PosixTypes.mode_t
  let mdb_mode_t = PosixTypes.mode_t

  let mdb_filehandle_t : Unix.file_descr typ =
    Unix_representations.
      (view int ~read:file_descr_of_int ~write:int_of_file_descr)

  (* typedef struct MDB_txn MDB_txn; *)
  type mdb_txn = unit ptr
  let mdb_txn : mdb_txn typ = ptr (typedef void "MDB_txn")
  let mdb_txn_opt : mdb_txn option typ = ptr_opt (typedef void "MDB_txn")

  (* typedef unsigned int MDB_dbi; *)
  type mdb_dbi = Unsigned.uint
  let mdb_dbi : mdb_dbi typ = uint


  type mdb_val
  let mdb_val : mdb_val structure typ = structure "MDB_val"
  let mv_size = field mdb_val "mv_size" size_t
  let mv_data = field mdb_val "mv_data" (ptr void)
  let () = seal mdb_val
{'fraction_non_alphanumeric': 0.0852561595619867, 'fraction_numerical': 0.0035197497066875244, 'mean_word_length': 3.456445993031359, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6493390', 'n_tokens_mistral': 1065, 'n_tokens_neox': 1021, 'n_words': 282}