search for: caml_callback_exn

Displaying 20 results from an estimated 41 matches for "caml_callback_exn".

Did you mean: caml_callbackn_exn
2017 Jan 27
2
Re: [nbdkit PATCH v3 1/4] plugins: Don't use bogus errno from non-C plugins
...ding > + * glue code, so this callback is implemented in C only, and not > + * exposed in OCaml. > + */ > +static int > +plugin_ocaml_errno_is_reliable (void *handle) > +{ > + return 0; > +} Actually OCaml is a real compiled language, and the call from C to OCaml code (via caml_callback_exn) is a short piece of asm which preserves errno. However you'll need to save errno around caml_enter_blocking_section since that unblocks and processes signals. IOW: static int pread_wrapper (void *h, void *buf, uint32_t count, uint64_t offset) { CAMLparam0 (); CAMLlocal3 (rv, s...
2019 May 17
1
Re: [nbdkit PATCH v2 08/24] ocaml: Implement .cache script callback
On Wed, May 15, 2019 at 10:57:58PM -0500, Eric Blake wrote: > +static int > +can_cache_wrapper (void *h) > +{ > + CAMLparam0 (); > + CAMLlocal1 (rv); > + > + caml_leave_blocking_section (); > + > + rv = caml_callback_exn (can_cache_fn, *(value *) h); > + if (Is_exception_result (rv)) { > + nbdkit_error ("%s", caml_format_exception (Extract_exception (rv))); > + caml_enter_blocking_section (); > + CAMLreturnT (int, -1); > + } > + > + caml_enter_blocking_section (); > +...
2020 Feb 10
1
[nbdkit PATCH] ocaml: Support .preconnect callback
...apper functions that translate calls from C (ie. nbdkit) to OCaml. */ @@ -726,6 +728,25 @@ can_fast_zero_wrapper (void *h) CAMLreturnT (int, Bool_val (rv)); } +static int +preconnect_wrapper (int readonly) +{ + CAMLparam0 (); + CAMLlocal1 (rv); + + caml_leave_blocking_section (); + + rv = caml_callback_exn (preconnect_fn, Val_bool (readonly)); + if (Is_exception_result (rv)) { + nbdkit_error ("%s", caml_format_exception (Extract_exception (rv))); + caml_enter_blocking_section (); + CAMLreturnT (int, -1); + } + + caml_enter_blocking_section (); + CAMLreturnT (int, 1); +} + /*--...
2019 Aug 15
2
[nbdkit PATCH] ocaml: Add support for dynamic .thread_model
...nslate calls from C (ie. nbdkit) to OCaml. */ @@ -683,18 +686,30 @@ cache_wrapper (void *h, uint32_t count, uint64_t offset, uint32_t flags) CAMLreturnT (int, 0); } +static int +thread_model_wrapper (void) +{ + CAMLparam0 (); + CAMLlocal1 (rv); + + caml_leave_blocking_section (); + + rv = caml_callback_exn (config_complete_fn, Val_unit); + if (Is_exception_result (rv)) { + nbdkit_error ("%s", caml_format_exception (Extract_exception (rv))); + caml_enter_blocking_section (); + CAMLreturnT (int, -1); + } + + caml_enter_blocking_section (); + CAMLreturnT (int, Int_val (rv)); +} +...
2016 Jul 11
0
Re: [PATCH v2] OCaml tools: add and use a Getopt module
...; diff --git a/mllib/getopt-c.c b/mllib/getopt-c.c > new file mode 100644 > index 0000000..e5e832c > --- /dev/null > +++ b/mllib/getopt-c.c > +static void > +do_call1 (value funv, value paramv) > +{ > + CAMLparam2 (funv, paramv); > + CAMLlocal1 (rv); > + > + rv = caml_callback_exn (funv, paramv); > + > + if (Is_exception_result (rv)) > + fprintf (stderr, > + "libguestfs: uncaught OCaml exception in getopt callback: %s", Does this need \n? > + case 0: > + if (STREQ (longopts[option_index].name, "help")) { > +...
2017 Jan 27
0
Re: [nbdkit PATCH v3 1/4] plugins: Don't use bogus errno from non-C plugins
On 01/27/2017 04:11 AM, Richard W.M. Jones wrote: > > Actually OCaml is a real compiled language, and the call from C to > OCaml code (via caml_callback_exn) is a short piece of asm which > preserves errno. Which shows my lack of familiarity with OCaml; but I'm guessing that also means that OCaml comes with easy ways to directly set errno so that it will be visible from C. > > However you'll need to save errno around caml_enter_bloc...
2019 May 16
0
[nbdkit PATCH v2 08/24] ocaml: Implement .cache script callback
...slate calls from C (ie. nbdkit) to OCaml. */ @@ -638,6 +641,48 @@ extents_wrapper (void *h, uint32_t count, uint64_t offset, uint32_t flags, CAMLreturnT (int, 0); } +static int +can_cache_wrapper (void *h) +{ + CAMLparam0 (); + CAMLlocal1 (rv); + + caml_leave_blocking_section (); + + rv = caml_callback_exn (can_cache_fn, *(value *) h); + if (Is_exception_result (rv)) { + nbdkit_error ("%s", caml_format_exception (Extract_exception (rv))); + caml_enter_blocking_section (); + CAMLreturnT (int, -1); + } + + caml_enter_blocking_section (); + CAMLreturnT (int, Int_val (rv)); +} + +s...
2017 Feb 10
0
[PATCH v3 06/10] mllib: ocaml wrapper for lib/osinfo
...unit); +} + +static int +read_osinfo_db_callback_wrapper (guestfs_h *g, const char *path, void *opaque) +{ + CAMLparam0 (); + CAMLlocal2 (pathv, v); + struct callback_wrapper_args *args = opaque; + + assert (path != NULL); + assert (args != NULL); + + pathv = caml_copy_string (path); + + v = caml_callback_exn (*args->fvp, pathv); + + if (Is_exception_result (v)) { + *args->exnp = Extract_exception (v); + CAMLreturnT (int, -1); + } + + /* No error, return normally. */ + CAMLreturnT (int, 0); +} diff --git a/mllib/osinfo.ml b/mllib/osinfo.ml new file mode 100644 index 000000000..f5afbd889...
2020 Sep 01
0
[nbdkit PATCH 2/2] ocaml: Implement .list_exports and friends
...char *, name); +} + static void * open_wrapper (int readonly) { @@ -358,6 +419,28 @@ close_wrapper (void *h) CAMLreturn0; } +static const char * +export_description_wrapper (void *h) +{ + const char *desc; + CAMLparam0 (); + CAMLlocal1 (rv); + + caml_leave_blocking_section (); + + rv = caml_callback_exn (export_description_fn, *(value *) h); + if (Is_exception_result (rv)) { + nbdkit_error ("%s", caml_format_exception (Extract_exception (rv))); + caml_enter_blocking_section (); + CAMLreturnT (const char *, NULL); + } + + desc = nbdkit_strdup_intern (String_val (rv)); + + cam...
2020 Sep 21
0
[nbdkit PATCH v3 14/14] ocaml: Implement .list_exports and friends
...char *, name); +} + static void * open_wrapper (int readonly) { @@ -358,6 +420,28 @@ close_wrapper (void *h) CAMLreturn0; } +static const char * +export_description_wrapper (void *h) +{ + const char *desc; + CAMLparam0 (); + CAMLlocal1 (rv); + + caml_leave_blocking_section (); + + rv = caml_callback_exn (export_description_fn, *(value *) h); + if (Is_exception_result (rv)) { + nbdkit_error ("%s", caml_format_exception (Extract_exception (rv))); + caml_enter_blocking_section (); + CAMLreturnT (const char *, NULL); + } + + desc = nbdkit_strdup_intern (String_val (rv)); + + cam...
2017 Mar 07
0
[PATCH v4 3/9] mllib: ocaml wrapper for lib/osinfo
...unit); +} + +static int +read_osinfo_db_callback_wrapper (guestfs_h *g, const char *path, void *opaque) +{ + CAMLparam0 (); + CAMLlocal2 (pathv, v); + struct callback_wrapper_args *args = opaque; + + assert (path != NULL); + assert (args != NULL); + + pathv = caml_copy_string (path); + + v = caml_callback_exn (*args->fvp, pathv); + + if (Is_exception_result (v)) { + *args->exnp = Extract_exception (v); + CAMLreturnT (int, -1); + } + + /* No error, return normally. */ + CAMLreturnT (int, 0); +} diff --git a/mllib/osinfo.ml b/mllib/osinfo.ml new file mode 100644 index 000000000..f5afbd889...
2017 Mar 23
0
[PATCH v5 03/10] mllib: ocaml wrapper for lib/osinfo
...unit); +} + +static int +read_osinfo_db_callback_wrapper (guestfs_h *g, const char *path, void *opaque) +{ + CAMLparam0 (); + CAMLlocal2 (pathv, v); + struct callback_wrapper_args *args = opaque; + + assert (path != NULL); + assert (args != NULL); + + pathv = caml_copy_string (path); + + v = caml_callback_exn (*args->fvp, pathv); + + if (Is_exception_result (v)) { + *args->exnp = Extract_exception (v); + CAMLreturnT (int, -1); + } + + /* No error, return normally. */ + CAMLreturnT (int, 0); +} diff --git a/mllib/osinfo.ml b/mllib/osinfo.ml new file mode 100644 index 000000000..f5afbd889...
2017 Apr 12
0
[PATCH v6 03/10] mllib: ocaml wrapper for lib/osinfo
...unit); +} + +static int +read_osinfo_db_callback_wrapper (guestfs_h *g, const char *path, void *opaque) +{ + CAMLparam0 (); + CAMLlocal2 (pathv, v); + struct callback_wrapper_args *args = opaque; + + assert (path != NULL); + assert (args != NULL); + + pathv = caml_copy_string (path); + + v = caml_callback_exn (*args->fvp, pathv); + + if (Is_exception_result (v)) { + *args->exnp = Extract_exception (v); + CAMLreturnT (int, -1); + } + + /* No error, return normally. */ + CAMLreturnT (int, 0); +} diff --git a/mllib/osinfo.ml b/mllib/osinfo.ml new file mode 100644 index 000000000..f5afbd889...
2016 Jul 11
2
[PATCH v2] OCaml tools: add and use a Getopt module
...v, j)); + + if (key[0] == '-' && key[1] == opt) { + ret = i; + goto done; + } + } + } + + ret = -1; + + done: + CAMLreturnT (int, ret); +} + +static void +do_call1 (value funv, value paramv) +{ + CAMLparam2 (funv, paramv); + CAMLlocal1 (rv); + + rv = caml_callback_exn (funv, paramv); + + if (Is_exception_result (rv)) + fprintf (stderr, + "libguestfs: uncaught OCaml exception in getopt callback: %s", + caml_format_exception (Extract_exception (rv))); + + CAMLreturn0; +} + +value +guestfs_int_mllib_getopt_parse (value argsv,...
2020 Sep 01
4
[nbdkit PATCH 0/2] More language bindings for .list_exports
This picks up python and ocaml. Some of our languages are lacking a number of bindings (for example, lua and perl lack .extents, so I didn't have anything to copy from), and I felt less comfortable with golang and rust. But for python and ocaml, I was able to test a working implementation. Eric Blake (2): python: Implement .list_exports and friends ocaml: Implement .list_exports and
2019 Aug 23
2
[nbdkit PATCH 3/3] plugins: Add .can_fast_zero hook
.../* Wrapper functions that translate calls from C (ie. nbdkit) to OCaml. */ @@ -705,6 +707,25 @@ thread_model_wrapper (void) CAMLreturnT (int, Int_val (rv)); } +static int +can_fast_zero_wrapper (void *h) +{ + CAMLparam0 (); + CAMLlocal1 (rv); + + caml_leave_blocking_section (); + + rv = caml_callback_exn (can_fast_zero_fn, *(value *) h); + if (Is_exception_result (rv)) { + nbdkit_error ("%s", caml_format_exception (Extract_exception (rv))); + caml_enter_blocking_section (); + CAMLreturnT (int, -1); + } + + caml_enter_blocking_section (); + CAMLreturnT (int, Bool_val (rv)); +}...
2020 Feb 25
6
[PATCH nbdkit 0/5] server: Add .get_ready callback.
I like this change. I think we were overloading the config_complete method before to do two different things (complete configuration; do any allocation/housekeeping necessary before we can start serving). The only questions in my mind are whether we want this before 1.18, and whether the name ("get_ready") is a good one. Rich.
2019 Jan 04
10
[PATCH nbdkit 0/7] server: Implement NBD_FLAG_CAN_MULTI_CONN.
First thing to say is that I need to do a *lot* more testing on this, so this is just an early peek. In particular, although it passed ‘make check && make check-valgrind’ I have *not* tested it against a multi-conn-aware client such as the Linux kernel >= 4.9. This implements NBD_FLAG_CAN_MULTI_CONN, described in the protocol doc as: "NBD_FLAG_CAN_MULTI_CONN: Indicates that
2019 Jan 05
15
[PATCH nbdkit v2 01/11] server: Implement NBD_FLAG_CAN_MULTI_CONN.
For existing commits, this is almost identical to v1, except that I updated some commit messages and reordered the commits in a somewhat more logical sequence. The main changes are the extra commits: [06/11] plugins: Return NBD_FLAG_CAN_MULTI_CONN from some readonly plugins. - Readonly plugins that can set the flag unconditionally. [09/11] partitioning: Return NBD_FLAG_CAN_MULTI_CONN. [10/11]
2020 Jun 22
4
[PATCH nbdkit 1/2] server: Add .after_fork callback, mainly for plugins to create threads.
...get_ready_fn; +static value after_fork_fn; static value preconnect_fn; static value open_fn; @@ -272,6 +273,25 @@ get_ready_wrapper (void) CAMLreturnT (int, 0); } +static int +after_fork_wrapper (void) +{ + CAMLparam0 (); + CAMLlocal1 (rv); + + caml_leave_blocking_section (); + + rv = caml_callback_exn (after_fork_fn, Val_unit); + if (Is_exception_result (rv)) { + nbdkit_error ("%s", caml_format_exception (Extract_exception (rv))); + caml_enter_blocking_section (); + CAMLreturnT (int, -1); + } + + caml_enter_blocking_section (); + CAMLreturnT (int, 0); +} + static int pre...