This commit is contained in:
swrup 2025-11-11 02:07:51 +01:00
parent aa2ff7b2f0
commit 2f3113f55d
11742 changed files with 1223940 additions and 0 deletions

View file

@ -0,0 +1,15 @@
(* -*- tuareg -*- *)
let preprocess =
match Sys.getenv "BISECT_ENABLE" with
| "yes" -> "(preprocess (pps bisect_ppx))"
| _ -> ""
| exception Not_found -> ""
let () = Jbuild_plugin.V1.send @@ {|
(library
(public_name pgx_lwt_unix)
(libraries pgx pgx_lwt lwt.unix)
|} ^ preprocess ^ {|)
|}

View file

@ -0,0 +1,37 @@
open Lwt
module Thread : Pgx_lwt.Io_intf.S = struct
type sockaddr =
| Unix of string
| Inet of string * int
type in_channel = Lwt_io.input_channel
type out_channel = Lwt_io.output_channel
let output_char = Lwt_io.write_char
let output_string = Lwt_io.write
let flush = Lwt_io.flush
let input_char = Lwt_io.read_char
let really_input = Lwt_io.read_into_exactly
let close_in = Lwt_io.close
(* The unix getlogin syscall can fail *)
let getlogin () =
Unix.getuid () |> Lwt_unix.getpwuid >|= fun { Lwt_unix.pw_name; _ } -> pw_name
;;
let open_connection sockaddr =
(match sockaddr with
| Unix path -> return (Unix.ADDR_UNIX path)
| Inet (hostname, port) ->
Lwt_unix.gethostbyname hostname
>|= fun { Lwt_unix.h_addr_list; _ } ->
let len = Array.length h_addr_list in
let i = Random.int len in
let addr = h_addr_list.(i) in
Unix.ADDR_INET (addr, port))
>>= Lwt_io.open_connection
;;
end
include Pgx_lwt.Make (Thread)

View file

@ -0,0 +1 @@
include Pgx_lwt.S

View file

@ -0,0 +1,4 @@
(test
(name test_pgx_lwt)
(package pgx_lwt_unix)
(libraries alcotest alcotest-lwt pgx_test pgx_lwt_unix))

View file

@ -0,0 +1,10 @@
module Alcotest_io = struct
type 'a test_case = 'a Alcotest_lwt.test_case
let test_case name speed f = Alcotest_lwt.test_case name speed (fun _ -> f)
let run name tests = Alcotest_lwt.run name tests |> Lwt_main.run
end
include Pgx_test.Make_tests (Pgx_lwt_unix) (Alcotest_io)
let () = run_tests ~library_name:"pgx_lwt_unix"