X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=libvirt%2Flibvirt_c_prologue.c;h=c41e48d12c12ea71bf73e4464a965f907f3b71ef;hb=a1775ba94cbf77e60e97f5fe00ed3e524ca531a5;hp=bf972e9e0e4f771549872398e535fbb0bd5a0d93;hpb=68fae1ec3de46fd9eec88fb7c1894ea7ed85ccc9;p=ocaml-libvirt.git diff --git a/libvirt/libvirt_c_prologue.c b/libvirt/libvirt_c_prologue.c index bf972e9..c41e48d 100644 --- a/libvirt/libvirt_c_prologue.c +++ b/libvirt/libvirt_c_prologue.c @@ -23,10 +23,13 @@ static char *Optstring_val (value strv); typedef value (*Val_ptr_t) (void *); static value Val_opt (void *ptr, Val_ptr_t Val_ptr); +typedef value (*Val_const_ptr_t) (const void *); +static value Val_opt_const (const void *ptr, Val_const_ptr_t Val_ptr); /*static value option_default (value option, value deflt);*/ static void _raise_virterror (const char *fn) Noreturn; -static void not_supported (const char *fn) Noreturn; static value Val_virterror (virErrorPtr err); +static int _list_length (value listv); +static value Val_virconnectcredential (const virConnectCredentialPtr cred); /* Use this around synchronous libvirt API calls to release the OCaml * lock, allowing other threads to run simultaneously. 'code' must not @@ -40,11 +43,18 @@ static value Val_virterror (virErrorPtr err); caml_leave_blocking_section (); \ } while (0) +/* Empty macro to use as empty parameter for other macros, since + * a null token as parameter when calling a macro is not allowed + * before C99. + */ +#define EMPTY /* Check error condition from a libvirt function, and automatically raise * an exception if one is found. */ +#define CHECK_ERROR_CLEANUP(cond, cleanup, fn) \ + do { if (cond) { cleanup; _raise_virterror (fn); } } while (0) #define CHECK_ERROR(cond, fn) \ - do { if (cond) _raise_virterror (fn); } while (0) + CHECK_ERROR_CLEANUP(cond, EMPTY, fn) /*----------------------------------------------------------------------*/