-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve handling of ocaml finalizers (#9)
* ensure entry arguments live long enough * ensure arguments to futhark functions live long enough * use Ctypes_ptr.Fat to manage pointer lifetimes * attach finalizers to C pointers, hold a context reference in array/opaque finalizers * test for opaque use after free * use get_ptr/get_opaque_ptr to access C pointers * bump version to 0.2.8 * set null pointer in free function
- Loading branch information
Showing
10 changed files
with
67 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "futhark-bindgen" | ||
version = "0.2.7" | ||
version = "0.2.8" | ||
edition = "2021" | ||
authors = ["Zach Shipko <[email protected]>"] | ||
license = "ISC" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
let v ctx {new_params} = | ||
check_use_after_free `context ctx.Context.context_free; | ||
let ptr = allocate (ptr void) null in | ||
let ptr = allocate ~finalise:(free' ctx) (ptr void) null in | ||
let rc = Bindings.{new_fn} ctx.Context.handle ptr {new_call_args} in | ||
Context.auto_sync ctx; | ||
if rc <> 0 then raise (Error (Code rc)); | ||
let opaque_ptr = !@ptr in | ||
let t = {{ opaque_ptr; opaque_ctx = ctx; opaque_free = false }} in | ||
Gc.finalise free t; t | ||
Context.auto_sync ctx; | ||
{{ opaque_ptr = ptr; opaque_ctx = ctx }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters