Displaying 20 results from an estimated 54 matches for "s_wrapper".
2019 Aug 13
0
[PATCH libnbd 2/6] generator: Create only one Python wrapper per closure.
...ith a Closure parameter are special because we
+ * have to generate wrapper functions which translate the
+ * callbacks back to Python.
+ *)
+let print_python_closure_wrapper { cbname; cbargs } =
+  pr "/* Wrapper for %s callback. */\n" cbname;
+  pr "static int\n";
+  pr "%s_wrapper " cbname;
+  C.print_cbarg_list cbargs;
+  pr "\n";
+  pr "{\n";
+  pr "  int ret = 0;\n";
+  pr "\n";
+  pr "  if (valid_flag & LIBNBD_CALLBACK_VALID) {\n";
+  pr "    PyGILState_STATE py_save = PyGILState_UNLOCKED;\n";
+  pr &qu...
2019 Aug 14
4
[PATCH libnbd 0/2] Use free callback to dereference NBD.Buffer.
In this patch series we use the newly introduced free callback
on the completion function to dererence the OCaml NBD.Buffer.
I will make the same kind of change for Python later in a
separate series.
The completion function is always called at the C level, even
if the OCaml program didn't use the optional argument.  That's
because the free callback doesn't run otherwise.
There is a
2019 Jul 24
0
[PATCH libnbd 1/3] generator: Change Closure so it describes single callbacks.
...pr "  free (user_data);\n";
+         pr "  Py_DECREF (user_data);\n";
          pr "}\n";
          pr "\n";
        );
 
+       pr "/* Wrapper for %s callback of %s. */\n" cbname name;
+       pr "static int\n";
+       pr "%s_%s_wrapper " name cbname;
+       C.print_arg_list ~user_data:true cbargs;
+       pr "\n";
+       pr "{\n";
+       pr "  int ret;\n";
+       pr "  PyGILState_STATE py_save = PyGILState_UNLOCKED;\n";
+       pr "  PyObject *py_args, *py_ret;\n";...
2019 Aug 12
0
[PATCH libnbd 5/7] ocaml: Use free callback to free closure root, instead of valid_flag == FREE.
...et }) =
        pr "  if (%s_user_data == NULL) caml_raise_out_of_memory ();\n" cbname;
        pr "  *%s_user_data = %sv;\n" cbname cbname;
        pr "  caml_register_generational_global_root (%s_user_data);\n" cbname;
-       pr "  const void *%s_callback = %s_%s_wrapper;\n" cbname name cbname
+       pr "  const void *%s_callback = %s_%s_wrapper;\n" cbname name cbname;
+       pr "  if (nbd_add_free_callback (h, %s_user_data,\n" cbname;
+       pr "                             free_root, %s_user_data) == -1)\n"
+         cbname;...
2019 Aug 13
12
[PATCH 0/6] Implement OClosure.
Patches 1-4 are basically uncontroversial, straightforward refactoring
and IMHO we should just push them.  Possibly 1-3 should be squashed
together, but I posted them separately so they are easier to review.
Patches 5 and 6 together implement OClosure.  Patch 5 adds the feature
and is simple to understand.
Patch 6 changes the Closure completion callbacks into OClosure, but
because it doesn't
2019 Aug 13
1
Re: [PATCH libnbd v2 1/3] generator: Implement OClosure.
...) -> pr "  %s_u32 = %s;\n" n n
>    ) optargs;
>  
> @@ -4423,6 +4438,9 @@ let print_python_binding name { args; optargs; ret; may_set_error } =
>    ) args;
>    List.iter (
>      function
> +    | OClosure { cbname } ->
> +       pr ", %s_user_data ? %s_wrapper : NULL" cbname cbname;
Still looks wrong. %s_user_data is non-NULL; the check here should be
%s_user_data != Py_None.
-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
2019 Aug 14
0
[PATCH libnbd 2/2] ocaml: Remove NBD.Buffer.free function, use the completion callback instead.
...struct user_data *user_data = alloc_user_data ();\n";
-       pr "\n";
-       pr "    user_data->fnv = Field (%sv, 0);\n" cbname;
-       pr "    caml_register_generational_global_root (&user_data->fnv);\n";
-       pr "    %s_callback.callback = %s_wrapper;\n" cbname cbname;
-       pr "    %s_callback.user_data = user_data;\n" cbname;
-       pr "    %s_callback.free = free_user_data;\n" cbname;
+       pr "    %s_user_data->fnv = Field (%sv, 0);\n" cbname cbname;
+       pr "    caml_register_generational_...
2019 Aug 14
5
[PATCH libnbd 0/3] Use free callback to hold ref to AIO buffer.
Basically the same as this patch series, but for Python:
https://www.redhat.com/archives/libguestfs/2019-August/msg00235.html
plus adding the 590 asynch test at the end.
Rich.
2019 Aug 13
0
[PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
...+4156,8 @@ let print_python_binding name { args; optargs; ret; may_set_error } =
           n;
        pr "  struct py_aio_buffer *%s_buf;\n" n
     | Closure { cbname } ->
-       pr "  PyObject *%s_user_data;\n" cbname
+       pr "  nbd_%s_callback %s = { .callback = %s_wrapper };\n"
+         cbname cbname cbname
     | Enum (n, _) -> pr "  int %s;\n" n
     | Flags (n, _) ->
        pr "  uint32_t %s_u32;\n" n;
@@ -4188,7 +4189,8 @@ let print_python_binding name { args; optargs; ret; may_set_error } =
   List.iter (
     function
     | OC...
2019 Aug 13
0
[PATCH libnbd 5/6] generator: Implement OClosure.
...pr "  }\n"
     | OFlags (n, _) -> pr "  %s_u32 = %s;\n" n n
   ) optargs;
 
@@ -4412,6 +4426,9 @@ let print_python_binding name { args; optargs; ret; may_set_error } =
   ) args;
   List.iter (
     function
+    | OClosure { cbname } ->
+       pr ", %s_user_data ? %s_wrapper : NULL" cbname cbname;
+       pr ", %s_user_data" cbname
     | OFlags (n, _) -> pr ", %s_u32" n
   ) optargs;
   pr ");\n";
@@ -4668,6 +4685,7 @@ class NBD (object):
       let optargs =
         List.map (
           function
+          | OClosure { cbname }...
2019 Aug 15
13
[PATCH libnbd v2 00/10] Callbacks and OCaml and Python persistent buffers.
This is a combination of these two earlier series:
https://www.redhat.com/archives/libguestfs/2019-August/msg00235.html
https://www.redhat.com/archives/libguestfs/2019-August/msg00240.html
plus changes to allow .callback = NULL / .free != NULL, and to reduce
the complexity of freeing callbacks.
Although it's rather long there's nothing complex here.  We might
consider squashing some
2019 Aug 13
0
[PATCH libnbd v2 1/3] generator: Implement OClosure.
...pr "  }\n"
     | OFlags (n, _) -> pr "  %s_u32 = %s;\n" n n
   ) optargs;
 
@@ -4423,6 +4438,9 @@ let print_python_binding name { args; optargs; ret; may_set_error } =
   ) args;
   List.iter (
     function
+    | OClosure { cbname } ->
+       pr ", %s_user_data ? %s_wrapper : NULL" cbname cbname;
+       pr ", %s_user_data" cbname
     | OFlags (n, _) -> pr ", %s_u32" n
   ) optargs;
   pr ");\n";
@@ -4679,6 +4697,7 @@ class NBD (object):
       let optargs =
         List.map (
           function
+          | OClosure { cbname }...
2019 Aug 10
0
[PATCH libnbd 6/9] generator: Add non-optional Flags type.
...| Enum _ -> ()
+    | Flags (n, _) -> pr "  %s_u32 = %s;\n" n n
     | Int _ -> ()
     | Int64 n -> pr "  %s_i64 = %s;\n" n n
     | Path n ->
@@ -4391,6 +4404,7 @@ let print_python_binding name { args; optargs; ret; may_set_error } =
        pr ", %s_%s_wrapper" name cbname;
        pr ", %s_user_data" cbname
     | Enum (n, _) -> pr ", %s" n
+    | Flags (n, _) -> pr ", %s_u32" n
     | Int n -> pr ", %s" n
     | Int64 n -> pr ", %s_i64" n
     | Path n -> pr ", %s" n
@@ -44...
2019 Aug 13
0
[PATCH libnbd 2/4] api: Add free function and remove valid_flag parameter.
...;\n"
 
 (* Generate the Python binding. *)
@@ -4156,8 +4150,8 @@ let print_python_binding name { args; optargs; ret; may_set_error } =
           n;
        pr "  struct py_aio_buffer *%s_buf;\n" n
     | Closure { cbname } ->
-       pr "  nbd_%s_callback %s = { .callback = %s_wrapper };\n"
-         cbname cbname cbname
+       pr "  nbd_%s_callback %s = { .callback = %s_wrapper, .free = %s_free };\n"
+         cbname cbname cbname cbname
     | Enum (n, _) -> pr "  int %s;\n" n
     | Flags (n, _) ->
        pr "  uint32_t %s_u32;\n" n;...
2019 Jul 24
6
[PATCH libnbd 0/3] Implement closure lifetimes.
This implements most of what I wrote here:
https://www.redhat.com/archives/libguestfs/2019-July/msg00213.html
2019 Jul 24
8
[PATCH libnbd v2 0/5] lib: Implement closure lifetimes.
v1 was here:
https://www.redhat.com/archives/libguestfs/2019-July/thread.html#00231
The changes address everything that Eric picked up in his review of
the first two patches.  I have also added two more patches (4 and 5)
which respectively fix docs and change int status -> unsigned status,
as discussed.
Passes make, check, check-valgrind.
Rich.
2019 Jul 24
0
[PATCH libnbd 2/3] lib: Implement closure lifetimes.
...;
-         pr "  Py_DECREF (user_data);\n";
-         pr "}\n";
-         pr "\n";
-       );
-
+    | Closure { cbname; cbargs } ->
        pr "/* Wrapper for %s callback of %s. */\n" cbname name;
        pr "static int\n";
        pr "%s_%s_wrapper " name cbname;
-       C.print_arg_list ~user_data:true cbargs;
+       C.print_arg_list ~valid_flag:true ~user_data:true cbargs;
        pr "\n";
        pr "{\n";
+       pr "  if (valid_flag & LIBNBD_CALLBACK_VALID) {\n";
        pr "  int ret;\n"...
2019 Jul 16
0
[libnbd PATCH 2/2] RFC: generator: Handle shared callbacks in Python
...hf "%s: couldn't find callback associated with Opaque %s"
-                  name opaque_id in
-    match cb with
-    | Callback (name, _) | CallbackPersist (name, _) -> name
-    | _ -> assert false
+  let print_callback cb =
+    pr "static int\n";
+    pr "%s_%s_wrapper " name cb.name;
+    print_c_arg_list ~handle:(Some "void *_data") cb.cbargs;
+    pr "\n";
+    pr "{\n";
+    pr "  int ret;\n";
+    pr "  PyGILState_STATE py_save = PyGILState_UNLOCKED;\n";
+    pr "  PyObject *py_args, *py_ret;\n"...
2019 Aug 13
8
[PATCH libnbd 0/4] Add free function to callbacks.
Patches 1 & 2 are rather complex, but the end result is that we pass
closures + user_data + free function in single struct parameters as I
described previously in this email:
https://www.redhat.com/archives/libguestfs/2019-August/msg00210.html
Patch 3 adds a convenient FREE_CALLBACK macro which seems a worthwhile
simplification if you buy into 1 & 2.
Patch 4 adds another macro which is
2019 Jul 24
0
[PATCH libnbd v2 2/5] lib: Implement closure lifetimes.
...;
-         pr "  Py_DECREF (user_data);\n";
-         pr "}\n";
-         pr "\n";
-       );
-
+    | Closure { cbname; cbargs } ->
        pr "/* Wrapper for %s callback of %s. */\n" cbname name;
        pr "static int\n";
        pr "%s_%s_wrapper " name cbname;
-       C.print_arg_list ~user_data:true cbargs;
+       C.print_arg_list ~valid_flag:true ~user_data:true cbargs;
        pr "\n";
        pr "{\n";
-       pr "  int ret;\n";
-       pr "  PyGILState_STATE py_save = PyGILState_UNLOCKED;\n&quo...