On 5/17/19 12:16 PM, Richard W.M. Jones wrote:
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 (); + CAMLreturnT (int, Int_val (rv));
The not very obvious implicit assumption here is that the order of the Cache* flags in the OCaml code is the same as the numbering of the NBDKIT_CACHE_* flags in the C code, which it is, so we should be good.
The fua code did similarly, so I wasn't too worried (copy and paste is nice...) -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org