Skip to content

Commit

Permalink
Changes for OCaml 4.02 compatibility:
Browse files Browse the repository at this point in the history
  * use 'fun (type a) (type b) ...' instead of 'fun (type a b)'
  * use Gc.finalise instead of Gc.finalise_last
  • Loading branch information
yallop committed Dec 4, 2019
1 parent 7373ea1 commit a928781
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/ctypes-foreign-base/ctypes_foreign_basis.ml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ struct
val with_fun : fn -> (t -> 'c) -> 'c
end

let dynamic_funptr (type a b) ?(abi=Libffi_abi.default_abi) ?(runtime_lock=false) ?(thread_registration=false) fn : (module Funptr with type fn = a -> b) =
let dynamic_funptr (type a) (type b) ?(abi=Libffi_abi.default_abi)
?(runtime_lock=false) ?(thread_registration=false) fn
: (module Funptr with type fn = a -> b) =
(module struct
type fn = a -> b
type t = fn Ffi.funptr
Expand All @@ -70,7 +72,8 @@ struct

let t_opt = Ctypes_std_views.nullable_funptr_view t fn
let free = Ffi.free_funptr
let of_fun = Ffi.funptr_of_fun ~abi ~acquire_runtime_lock:runtime_lock ~thread_registration fn
let of_fun = Ffi.funptr_of_fun ~abi ~acquire_runtime_lock:runtime_lock
~thread_registration fn

let with_fun f do_it =
let f = of_fun f in
Expand Down
2 changes: 1 addition & 1 deletion tests/test-funptrs/test_funptrs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct
let make_f () : (int -> int) * ([`Live|`Released] -> unit) =
let closure_status = ref `Live in
let f = (+) 1 in
Gc.finalise_last (fun () -> closure_status := `Released) f;
Gc.finalise (fun _ -> closure_status := `Released) f;
f, (fun status ->
Gc.full_major ();
Gc.full_major ();
Expand Down

0 comments on commit a928781

Please sign in to comment.