[Libguestfs] [nbdkit PATCH v2 08/24] ocaml: Implement .cache script callback

Eric Blake eblake at redhat.com
Fri May 17 21:10:04 UTC 2019


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20190517/1b90eb78/attachment.sig>


More information about the Libguestfs mailing list