Displaying 20 results from an estimated 69 matches for "generate_lib_api_c".
2019 Jun 04
2
[PATCH libnbd] generator: Fix race condition when validating h->state.
...Blake for identifying the race condition above.
---
generator/generator | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/generator/generator b/generator/generator
index ea6f739..8068762 100755
--- a/generator/generator
+++ b/generator/generator
@@ -2820,10 +2820,9 @@ let generate_lib_api_c () =
pr " nbd_internal_reset_error (\"nbd_%s\");\n" name;
pr "\n"
);
+ if is_locked then
+ pr " pthread_mutex_lock (&h->lock);\n";
if permitted_states <> [] then (
- pr " /* We can check the state outs...
2019 Aug 10
0
[PATCH libnbd 7/9] generator: On entry to API functions, check Flags and OFlags parameters.
...) flags are
passed to Flags or OFlags parameters.
---
generator/generator | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/generator/generator b/generator/generator
index 96d1148..a6aea26 100755
--- a/generator/generator
+++ b/generator/generator
@@ -3689,6 +3689,19 @@ let generate_lib_api_c () =
);
(* Check parameters are valid. *)
+ let print_flags_check n { flag_prefix; flags } =
+ let value = match errcode with
+ | Some value -> value
+ | None -> assert false in
+ let mask = List.fold_left (lor) 0 (List.map snd flags) in
+ pr "...
2019 Nov 02
1
[PATCH libnbd] lib: Use GCC hints to move debug and error handling code out of hot paths.
...or | 6 +++---
lib/crypto.c | 2 +-
lib/internal.h | 14 +++++++++++++-
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/generator/generator b/generator/generator
index c2ff0db..eb3408d 100755
--- a/generator/generator
+++ b/generator/generator
@@ -4512,7 +4512,7 @@ let generate_lib_api_c () =
let value = match errcode with
| Some value -> value
| None -> assert false in
- pr " if (!%s_in_permitted_state (h)) {\n" name;
+ pr " if (unlikely (!%s_in_permitted_state (h))) {\n" name;
pr " ret = %s;\n" val...
2019 May 30
3
[PATCH libnbd 0/2] Avoid lock and error overhead on some calls.
This works. I'm in the middle of testing whether there is any
noticable benefit.
Rich.
2019 Aug 13
0
[PATCH libnbd 5/6] generator: Implement OClosure.
...pr "%s_callback" cbname;
+ pr ", ";
+ if types then pr "void *";
+ pr "%s_user_data" cbname
| OFlags (n, _) ->
if types then pr "uint32_t ";
pr "%s" n
@@ -3707,6 +3704,7 @@ let generate_lib_api_c () =
) args;
List.iter (
function
+ | OClosure _ -> ()
| OFlags (n, flags) ->
print_flags_check n flags
) optargs;
@@ -3756,6 +3754,7 @@ let generate_lib_api_c () =
) args;
List.iter (
function
+ | OClosure { cbname } -> pr...
2019 Aug 09
0
[PATCH libnbd 2/2] generator: Change handling of Flags to be a true optional argument.
...+ optargs = [ OFlags "flags" ];
ret = RInt64;
permitted_states = [ Connected ];
shortdesc = "send block status command to the NBD server, with callback on completion";
@@ -3149,7 +3160,8 @@ module C : sig
val generate_lib_unlocked_h : unit -> unit
val generate_lib_api_c : unit -> unit
val generate_docs_libnbd_api_pod : unit -> unit
- val print_arg_list : ?handle:bool -> ?types:bool -> arg list -> unit
+ val print_arg_list : ?handle:bool -> ?types:bool ->
+ arg list -> optarg list -> unit
val print_cbarg_list...
2019 Aug 13
0
[PATCH libnbd v2 1/3] generator: Implement OClosure.
...pr "%s_callback" cbname;
+ pr ", ";
+ if types then pr "void *";
+ pr "%s_user_data" cbname
| OFlags (n, _) ->
if types then pr "uint32_t ";
pr "%s" n
@@ -3718,6 +3716,7 @@ let generate_lib_api_c () =
) args;
List.iter (
function
+ | OClosure _ -> ()
| OFlags (n, flags) ->
print_flags_check n flags
) optargs;
@@ -3767,6 +3766,7 @@ let generate_lib_api_c () =
) args;
List.iter (
function
+ | OClosure { cbname } -> pr...
2020 Sep 29
2
[PATCH libnbd] generator: Add SizeT type, maps to C size_t.
...t;
if types then pr "int64_t ";
pr "%s" n
+ | SizeT n ->
+ if types then pr "size_t ";
+ pr "%s" n
| Path n
| String n ->
if types then pr "const char *";
@@ -621,7 +625,8 @@ let generate_lib_api_c () =
pr " nbd_internal_printable_string_list (%s);\n" n
| BytesOut _ | BytesPersistOut _
| Bool _ | Closure _ | Enum _ | Flags _ | Fd _ | Int _
- | Int64 _ | SockAddrAndLen _ | UInt _ | UInt32 _ | UInt64 _ -> ()
+ | Int64 _ | SizeT _
+ | So...
2019 Aug 09
4
[PATCH libnbd 0/2] generator: Preparatory changes to the generator.
These are some simplifications to the generator. They don't probably
make much sense on their own, but they are preparatory to better
handling of enums, and or'd lists of flags.
Rich.
2019 Jun 04
0
Re: [PATCH libnbd] generator: Fix race condition when validating h->state.
...ve.
> ---
> generator/generator | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/generator/generator b/generator/generator
> index ea6f739..8068762 100755
> --- a/generator/generator
> +++ b/generator/generator
> @@ -2820,10 +2820,9 @@ let generate_lib_api_c () =
> pr " nbd_internal_reset_error (\"nbd_%s\");\n" name;
> pr "\n"
> );
> + if is_locked then
> + pr " pthread_mutex_lock (&h->lock);\n";
> if permitted_states <> [] then (
> - pr &qu...
2019 Aug 13
2
Re: [PATCH libnbd 5/6] generator: Implement OClosure.
On 8/13/19 5:06 AM, Richard W.M. Jones wrote:
> An optional Closure parameter, but otherwise works the same way as
> Closure.
> @@ -3778,6 +3777,7 @@ let generate_lib_api_c () =
> ) args;
> List.iter (
> function
> + | OClosure { cbname } -> pr ", %s_callback ? \"<fun>\" : \"NULL\"" cbname
Well, it also permits a NULL fn pointer.
> @@ -4383,6 +4387,16 @@ let print_python_binding name { args;...
2020 Sep 11
0
[libnbd PATCH v2 2/5] generator: Refactor filtering of accepted OFlags
...-> "&"
| Pointer -> "*" in
pr "%s%s_callback" mark cbname
- | OFlags (n, _) ->
+ | OFlags (n, _, _) ->
if types then pr "uint32_t ";
pr "%s" n
) optargs
@@ -494,11 +494,21 @@ let generate_lib_api_c () =
);
(* Check parameters are valid. *)
- let print_flags_check n { flag_prefix } =
+ let print_flags_check n { flag_prefix; flags } subset =
let value = match errcode with
| Some value -> value
| None -> assert false in
- pr " if (unlike...
2019 Jul 25
2
[libnbd PATCH] generator: Let nbd_aio_get_direction return unsigned
...name args ret =
| RConstString -> pr "const char *"
| RInt64 -> pr "int64_t "
| RString -> pr "char *"
+ | RUInt -> pr "unsigned "
);
pr "nbd_%s " name;
print_arg_list ~handle:true args
@@ -3329,10 +3333,11 @@ let generate_lib_api_c () =
| RBool
| RErr
| RFd
- | RInt -> "int", "-1"
- | RConstString -> "const char *", "NULL"
- | RInt64 -> "int64_t", "-1"
- | RString -> "char *", "NULL" in
+ |...
2020 Jul 31
1
[libnbd PATCH] generator: Trace return even when in wrong state
...o use in the wrong
state, the debug output was useless in telling me why.
generator/C.ml | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/generator/C.ml b/generator/C.ml
index 4a0b45d..2c62d4e 100644
--- a/generator/C.ml
+++ b/generator/C.ml
@@ -542,13 +542,13 @@ let generate_lib_api_c () =
pr " ret = nbd_unlocked_%s " name;
print_arg_list ~wrap:true ~types:false ~handle:true args optargs;
pr ";\n";
- if may_set_error then (
- pr "\n";
- print_trace_leave ret;
- pr "\n"
- );
+ pr "\n";...
2019 Aug 10
0
[PATCH libnbd 6/9] generator: Add non-optional Flags type.
...if types then pr "int ";
pr "%s" n
+ | Flags (n, _) ->
+ if types then pr "uint32_t ";
+ pr "%s" n
| Int n ->
if types then pr "int ";
pr "%s" n
@@ -3748,6 +3753,7 @@ let generate_lib_api_c () =
| BytesPersistOut (n, count) -> pr " %s=<buf> %s=%%zu" n count
| Closure { cbname } -> pr " %s=<fun>" cbname
| Enum (n, _) -> pr " %s=%%d" n
+ | Flags (n, _) -> pr " %s=0x%%x" n
| Int n -> pr &q...
[PATCH libnbd v2 02/10] lib: Add macros to check if a callback is "null" or not, and set it to null.
2019 Aug 15
0
[PATCH libnbd v2 02/10] lib: Add macros to check if a callback is "null" or not, and set it to null.
...| 2 +-
lib/internal.h | 9 +++++++--
7 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/generator/generator b/generator/generator
index ca97910..98c99e0 100755
--- a/generator/generator
+++ b/generator/generator
@@ -3576,7 +3576,7 @@ let generate_lib_api_c () =
let value = match errcode with
| Some value -> value
| None -> assert false in
- pr " if (%s_callback.callback == NULL) {\n" cbname;
+ pr " if (CALLBACK_IS_NULL (%s_callback)) {\n" cbname;
pr " set_...
2019 Jun 05
2
Re: [PATCH libnbd 4/4] lib: Atomically update h->state when leaving the locked region.
...d for doing those additional handshake
steps. It's easier to think about adding a mandatory nbd_aio_go() called
in between nbd_aio_connect*() and the first nbd_aio_pread now, before we
have to start worrying about back-compat issues to all existing AIO clients.
> @@ -2866,8 +2866,11 @@ let generate_lib_api_c () =
As said above, I think you're still missing a change at the beginning of
the wrapper that grabs the lock to do the state check after the lock.
> let argnames = List.flatten (List.map name_of_arg args) in
> List.iter (pr ", %s") argnames;
> pr ");\n&...
2019 Aug 10
2
Re: [PATCH libnbd 7/9] generator: On entry to API functions, check Flags and OFlags parameters.
...ver do add such a mode, it shouldn't be hard
to make this sanity checking conditional on that mode.
>
> diff --git a/generator/generator b/generator/generator
> index 96d1148..a6aea26 100755
> --- a/generator/generator
> +++ b/generator/generator
> @@ -3689,6 +3689,19 @@ let generate_lib_api_c () =
> );
>
> (* Check parameters are valid. *)
> + let print_flags_check n { flag_prefix; flags } =
> + let value = match errcode with
> + | Some value -> value
> + | None -> assert false in
> + let mask = List.fold_left (lor) 0...
2019 Aug 09
1
Re: [PATCH libnbd 2/2] generator: Change handling of Flags to be a true optional argument.
...function
> + | _, { optargs = [] } | _, { optargs = [OFlags _] } -> ()
> + | (name, _) ->
> + failwithf "%s: optargs can only be empty list of [OFlags]" name
s/of/or/
> @@ -3554,7 +3569,7 @@ let permitted_state_text permitted_states =
> *)
> let generate_lib_api_c () =
> (* Print the wrapper added around all API calls. *)
> - let rec print_wrapper (name, {args; ret; permitted_states;
> + let rec print_wrapper (name, {args; optargs; ret; permitted_states;
> is_locked; may_set_error}) =
Indentation looks odd to me...
2019 Jun 05
1
[PATCH libnbd v2] lib: Atomically update h->state when leaving the locked region.
...nection_state (struct nbd_handle *h)\n";
pr "{\n";
- pr " switch (get_state (h))\n";
+ pr " switch (get_next_state (h))\n";
pr " {\n";
List.iter (
fun ({ comment; parsed = { display_name; state_enum } }) ->
@@ -2844,7 +2844,7 @@ let generate_lib_api_c () =
pr " /* We can check the state outside the handle lock because the\n";
pr " * the state is atomic.\n";
pr " */\n";
- pr " enum state state = get_state (h);\n";
+ pr " enum state state = get_public_state (h);\n&q...