search for: generate_include_libnbd_h

Displaying 20 results from an estimated 35 matches for "generate_include_libnbd_h".

2019 Jun 03
1
[libnbd PATCH] generator: Add #define witnesses for all API
...et print_extern name args ret = print_call name args ret; pr ";\n" +let print_extern_and_define name args ret = + let name_upper = String.uppercase_ascii name in + print_extern name args ret; + pr "#define LIBNBD_HAVE_NBD_%s 1\n" name_upper; + pr "\n" + let generate_include_libnbd_h () = generate_header CStyle; @@ -2729,14 +2735,23 @@ let generate_include_libnbd_h () = List.iter (fun (n, i) -> pr "#define LIBNBD_%-30s %d\n" n i) constants; pr "\n"; pr "extern struct nbd_handle *nbd_create (void);\n"; + pr "#define LIBNBD_HAVE...
2019 Aug 11
3
[PATCH libnbd proposal] api: Add semi-private function for freeing persistent data.
...ajor minor; pr " global:\n"; if (major, minor) = (1, 0) then ( + pr " nbd_add_free_callback;\n"; pr " nbd_create;\n"; pr " nbd_close;\n"; pr " nbd_get_errno;\n"; @@ -3581,6 +3582,12 @@ let generate_include_libnbd_h () = pr "extern int nbd_get_errno (void);\n"; pr "#define LIBNBD_HAVE_NBD_GET_ERRNO 1\n"; pr "\n"; + pr "typedef void (*nbd_free_callback) (void *ptr);\n"; + pr "extern int nbd_add_free_callback (struct nbd_handle *h,\n"; + pr "...
2019 Aug 10
0
[PATCH libnbd 8/9] generator: Enhance Flags/OFlags with optional "all flags" mask.
...ues in C *) } and permitted_state = @@ -930,6 +931,7 @@ let all_enums = [ tls_enum ] (* Flags. *) let cmd_flags = { flag_prefix = "CMD_FLAG"; + all_flags_bitmask = false; flags = [ "FUA", 1 lsl 0; "NO_HOLE", 1 lsl 1; @@ -3547,13 +3549,18 @@ let generate_include_libnbd_h () = pr "\n" ) all_enums; List.iter ( - fun { flag_prefix; flags } -> + fun { flag_prefix; all_flags_bitmask; flags } -> List.iter ( fun (flag, i) -> let flag = sprintf "LIBNBD_%s_%s" flag_prefix flag in pr "...
2019 Aug 12
0
Re: [PATCH libnbd proposal] api: Add semi-private function for freeing persistent data.
...global:\n"; > if (major, minor) = (1, 0) then ( > + pr " nbd_add_free_callback;\n"; > pr " nbd_create;\n"; > pr " nbd_close;\n"; > pr " nbd_get_errno;\n"; > @@ -3581,6 +3582,12 @@ let generate_include_libnbd_h () = > pr "extern int nbd_get_errno (void);\n"; > pr "#define LIBNBD_HAVE_NBD_GET_ERRNO 1\n"; > pr "\n"; > + pr "typedef void (*nbd_free_callback) (void *ptr);\n"; > + pr "extern int nbd_add_free_callback (struct nbd_handle *h,\...
2019 Jun 27
3
[libnbd PATCH] generator: Add support for namespace constants
..." ns; + pr "#define LIBNBD_NAMESPACE_%s \"%s\"\n" ns_upper ns; + pr "\n"; + pr "/* \"%s\" namespace contexts */\n" ns; + List.iter ( + fun (ctxt, consts) -> print_ns_ctxt ns ns_upper ctxt consts + ) ctxts; + pr "\n" + let generate_include_libnbd_h () = generate_header CStyle; @@ -2944,6 +2970,10 @@ let generate_include_libnbd_h () = fun (name, { args; ret }) -> print_extern_and_define name args ret ) handle_calls; pr "\n"; + List.iter ( + fun (ns, ctxts) -> print_ns ns ctxts + ) metadata_namespaces; + pr...
2019 Jul 16
2
[PATCH libnbd] generator: Swap parameters of nbd_add_close_callback.
...passed first). --- generator/generator | 10 +++++----- lib/handle.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/generator/generator b/generator/generator index 951349d..ed05ea9 100755 --- a/generator/generator +++ b/generator/generator @@ -3305,8 +3305,8 @@ let generate_include_libnbd_h () = pr "#define LIBNBD_HAVE_NBD_GET_ERRNO 1\n"; pr "\n"; pr "extern int nbd_add_close_callback (struct nbd_handle *h,\n"; - pr " nbd_close_callback cb,\n"; - pr " void *user_...
2019 Jul 25
0
[PATCH libnbd v3 2/2] lib: Remove nbd_add_close_callback.
...@ -3055,7 +3055,6 @@ let generate_lib_libnbd_syms () = pr "{\n"; pr " global:\n"; - pr " nbd_add_close_callback;\n"; pr " nbd_create;\n"; pr " nbd_close;\n"; pr " nbd_get_errno;\n"; @@ -3255,11 +3254,6 @@ let generate_include_libnbd_h () = pr "extern int nbd_get_errno (void);\n"; pr "#define LIBNBD_HAVE_NBD_GET_ERRNO 1\n"; pr "\n"; - pr "extern int nbd_add_close_callback (struct nbd_handle *h,\n"; - pr " nbd_close_callback cb,\n"; - p...
2019 Jun 18
0
[libnbd RFC PATCH 9/8] wip: generator: Add ReadStatus enum type
...r "int64_t %s" n | Opaque n -> pr "void *%s" n + | ReadStatus n -> pr "enum nbd_read_status %s" n | Path n | String n -> pr "const char *%s" n | StringList n -> pr "char **%s" n @@ -2896,6 +2902,13 @@ let generate_include_libnbd_h () = pr "\n"; List.iter (fun (n, i) -> pr "#define LIBNBD_%-30s %d\n" n i) constants; pr "\n"; + List.iter ( + fun (name, list) -> + pr "enum %s {\n" name; + List.iter (fun (n, i) -> pr " LIBNBD_%-30s = %d,\n" n i) l...
2019 Aug 12
0
[PATCH libnbd 1/7] api: Add semi-private function for freeing persistent data.
...ajor minor; pr " global:\n"; if (major, minor) = (1, 0) then ( + pr " nbd_add_free_callback;\n"; pr " nbd_create;\n"; pr " nbd_close;\n"; pr " nbd_get_errno;\n"; @@ -3581,6 +3582,13 @@ let generate_include_libnbd_h () = pr "extern int nbd_get_errno (void);\n"; pr "#define LIBNBD_HAVE_NBD_GET_ERRNO 1\n"; pr "\n"; + pr "typedef void (*nbd_free_callback) (void *ptr, void *user_data);\n"; + pr "extern int nbd_add_free_callback (struct nbd_handle *h,\n";...
2019 Jul 16
2
[PATCH libnbd] generator: Define new Closure type
** INCOMPLETE ** This is the generator change as discussed on the list already. The Python and OCaml bindings are not yet done. It passes all [C only] tests and valgrind. Note that nbd_add_close_callback is inconsistent with other closure types because it passes the user_data parameter after the function. (This is not caused by the current patch, it was already inconsistent). We decided that
2019 Aug 10
0
[PATCH libnbd 3/9] generator: Add Enum type for enumerated types / unions.
...s then pr "void *"; pr "%s_user_data" cbname + | Enum (n, _) -> + if types then pr "int "; + pr "%s" n | Int n -> if types then pr "int "; pr "%s" n @@ -3512,6 +3532,15 @@ let generate_include_libnbd_h () = pr "\n"; pr "struct nbd_handle;\n"; pr "\n"; + List.iter ( + fun { enum_prefix; enums } -> + List.iter ( + fun (enum, i) -> + let enum = sprintf "LIBNBD_%s_%s" enum_prefix enum in + pr "#define %-40s...
2019 Jun 20
1
Re: [libnbd RFC PATCH 9/8] wip: generator: Add ReadStatus enum type
...; | Opaque n -> pr "void *%s" n > + | ReadStatus n -> pr "enum nbd_read_status %s" n > | Path n > | String n -> pr "const char *%s" n > | StringList n -> pr "char **%s" n > @@ -2896,6 +2902,13 @@ let generate_include_libnbd_h () = > pr "\n"; > List.iter (fun (n, i) -> pr "#define LIBNBD_%-30s %d\n" n i) constants; > pr "\n"; > + List.iter ( > + fun (name, list) -> > + pr "enum %s {\n" name; > + List.iter (fun (n, i) -> pr "...
2020 Sep 11
0
[libnbd PATCH v2 1/5] api: Add xxx_MASK constant for each Flags type
...flags."; see_also = [Link "close"; Link "aio_disconnect"]; example = Some "examples/reads-and-writes.c"; }; diff --git a/generator/C.ml b/generator/C.ml index c9f0ff4..4d4958d 100644 --- a/generator/C.ml +++ b/generator/C.ml @@ -349,11 +349,15 @@ let generate_include_libnbd_h () = ) all_enums; List.iter ( fun { flag_prefix; flags } -> + let mask = ref 0 in List.iter ( fun (flag, i) -> let flag = sprintf "LIBNBD_%s_%s" flag_prefix flag in - pr "#define %-40s %d\n" flag i + pr "#de...
2019 Jul 16
1
[libnbd PATCH] generator: Prefer closure opaque after function pointer in C
..._c_arg_list ~user_data:true cbargs; + pr ", " + ) cls; + pr "void *user_data" | Flags n -> pr "uint32_t %s" n | Int n -> pr "int %s" n | Int64 n -> pr "int64_t %s" n @@ -3305,8 +3306,8 @@ let generate_include_libnbd_h () = pr "#define LIBNBD_HAVE_NBD_GET_ERRNO 1\n"; pr "\n"; pr "extern int nbd_add_close_callback (struct nbd_handle *h,\n"; - pr " void *user_data,\n"; - pr " nbd_close_callbac...
2019 Aug 10
17
[PATCH libnbd 0/9] Add Enum and Flags types.
This largish series adds several new features to the generator. Enum maps to enumerated types (like enum in C). The only current use for this is replacing the nbd_set_tls (nbd, 0/1/2) parameter with LIBNBD_TLS_DISABLE, LIBNBD_TLS_ALLOW, LIBNBD_TLS_REQUIRE (and natural equivalents in other programming languages). Flags maps to any uint32_t bitmask. It is basically a non-optional, generalized
2019 Aug 10
0
[PATCH libnbd 2/9] generator: Generalize OFlags.
...false) ?(types = true) args optargs = if !comma then pr ", "; comma := true; match optarg with - | OFlags n -> + | OFlags (n, _) -> if types then pr "uint32_t "; pr "%s" n ) optargs; @@ -3501,7 +3512,20 @@ let generate_include_libnbd_h () = pr "\n"; pr "struct nbd_handle;\n"; pr "\n"; - List.iter (fun (n, i) -> pr "#define LIBNBD_%-30s %d\n" n i) constants; + List.iter ( + fun { flag_prefix; flags } -> + List.iter ( + fun (flag, i) -> + let flag =...
2019 Jul 16
0
[PATCH libnbd v2] generator: Define new Closure type instead of callbacks.
...| Mutable (Int n) -> pr "int *%s" n | Mutable arg -> assert false - | Opaque n -> pr "void *%s" n | Path n | String n -> pr "const char *%s" n | StringList n -> pr "char **%s" n @@ -3258,7 +3274,7 @@ let generate_include_libnbd_h () = pr "\n"; pr "struct nbd_handle;\n"; pr "\n"; - pr "typedef void (*nbd_close_callback) (void *data);\n"; + pr "typedef void (*nbd_close_callback) (void *user_data);\n"; pr "\n"; List.iter (fun (n, i) -> pr "#de...
2019 Aug 03
1
[PATCH libnbd] generator: Generate typedefs automatically for Closure arguments.
...) " cbname; + print_arg_list ~valid_flag:true ~user_data:true cbargs; + pr ";\n"; + ) unique_cls; + pr "\n" + let print_extern_and_define name args ret = let name_upper = String.uppercase_ascii name in print_extern name args ret; @@ -3355,6 +3413,7 @@ let generate_include_libnbd_h () = pr "extern int nbd_get_errno (void);\n"; pr "#define LIBNBD_HAVE_NBD_GET_ERRNO 1\n"; pr "\n"; + print_closure_typedefs (); List.iter ( fun (name, { args; ret }) -> print_extern_and_define name args ret ) handle_calls; @@ -4845,7 +4904,7 @@...
2019 Jul 25
4
[PATCH libnbd v3 0/2] lib: Implement closure lifetimes.
I think I've addressed everything that was raised in review. Some of the highlights: - Callbacks should be freed reliably along all exit paths. - There's a simple test of closure lifetimes. - I've tried to use VALID|FREE in all the places where I'm confident that it's safe and correct to do. There may be more places. Note this is an optimization and shouldn't
2019 Jul 16
2
[PATCH libnbd v2] generator: Define new Closure type
As before, but this one has working Python bindings. OCaml still TBD. Rich.