-
Notifications
You must be signed in to change notification settings - Fork 4
noalloc #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
noalloc #12
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,14 +40,19 @@ end | |
|
||
type t = Unix.file_descr (* epoll fd *) | ||
|
||
external caml_polly_add : t -> Unix.file_descr -> Events.t -> unit | ||
external caml_raise_unix_error : string -> 'a = "caml_raise_unix_error" | ||
|
||
external caml_polly_add : t -> Unix.file_descr -> Events.t -> int | ||
= "caml_polly_add" | ||
[@@noalloc] | ||
|
||
external caml_polly_del : t -> Unix.file_descr -> Events.t -> unit | ||
external caml_polly_del : t -> Unix.file_descr -> Events.t -> int | ||
= "caml_polly_del" | ||
[@@noalloc] | ||
|
||
external caml_polly_mod : t -> Unix.file_descr -> Events.t -> unit | ||
external caml_polly_mod : t -> Unix.file_descr -> Events.t -> int | ||
= "caml_polly_mod" | ||
[@@noalloc] | ||
|
||
external caml_polly_create1 : unit -> t = "caml_polly_create1" | ||
|
||
|
@@ -70,11 +75,17 @@ let create = caml_polly_create1 | |
|
||
let close t = Unix.close t | ||
|
||
let add = caml_polly_add | ||
let add t fd e = | ||
let r = caml_polly_add t fd e in | ||
if r < 0 then caml_raise_unix_error "Polly.add" | ||
|
||
let del t fd = caml_polly_del t fd Events.empty | ||
let del t fd = | ||
let r = caml_polly_del t fd Events.empty in | ||
if r < 0 then caml_raise_unix_error "Polly.del" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we need to preserve There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code may work correctly as it is currently written, but it relies on some fragile properties.
|
||
|
||
let upd = caml_polly_mod | ||
let upd t fd e = | ||
let r = caml_polly_mod t fd e in | ||
if r < 0 then caml_raise_unix_error "Polly.mod" | ||
|
||
let wait = caml_polly_wait | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why we need this. We can raise an exception simply from OCaml without calling into C first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because C will get the errno last set by the unix call and position it in the exception.
We probably should use that for eventfd though.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, why to you define
__FUNCTION__
in eventfd.read and write ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__FUNCTION__
is not defined in OCaml 4.08, unfortunately. I could have used__LOC__
instead.