Displaying 20 results from an estimated 52 matches for "flag_prefix".
2019 Aug 10
0
[PATCH libnbd 8/9] generator: Enhance Flags/OFlags with optional "all flags" mask.
...---
generator/generator | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/generator/generator b/generator/generator
index a6aea26..fe24738 100755
--- a/generator/generator
+++ b/generator/generator
@@ -898,6 +898,7 @@ and enum = {
}
and flags = {
flag_prefix : string; (* prefix of each flag name *)
+ all_flags_bitmask : bool; (* if true, generate a bitmask of all flags *)
flags : (string * int) list (* flag names and their values in C *)
}
and permitted_state =
@@ -930,6 +931,7 @@ let all_enums = [ tls_enum ]
(* Flags. *)
let cmd_flags = {...
2020 Sep 07
0
[libnbd PATCH v2 3/3] ocaml: Typesafe returns for REnum/RFlags
...ator/OCaml.ml
@@ -66,8 +66,8 @@ and ocaml_ret_to_string = function
| RCookie -> "cookie"
| RString -> "string"
| RUInt -> "int"
- | REnum _ -> "int" (* XXX return enum_prefix.t instead *)
- | RFlags _ -> "int" (* XXX return flag_prefix.t list instead *)
+ | REnum { enum_prefix } -> enum_prefix ^ ".t"
+ | RFlags { flag_prefix } -> flag_prefix ^ ".t list"
and ocaml_optarg_to_string = function
| OClosure { cbname; cbargs } ->
@@ -344,7 +344,34 @@ let print_ocaml_enum_val { enum_prefix; enums } =...
2020 Sep 06
0
[libnbd PATCH 3/3] ocaml: Typesafe returns for REnum/RFlags
.../OCaml.ml
@@ -66,8 +66,8 @@ and ocaml_ret_to_string = function
| RCookie -> "cookie"
| RString -> "string"
| RUInt -> "int"
- | REnum (_) -> "int" (* XXX return enum_prefix.t instead *)
- | RFlags (_) -> "int" (* XXX return flag_prefix.t list instead *)
+ | REnum ({ enum_prefix }) -> enum_prefix ^ ".t"
+ | RFlags ({ flag_prefix }) -> flag_prefix ^ ".t list"
and ocaml_optarg_to_string = function
| OClosure { cbname; cbargs } ->
@@ -332,10 +332,33 @@ let print_ocaml_enum_val { enum_prefix; enums...
2020 Sep 11
0
[libnbd PATCH v2 1/5] api: Add xxx_MASK constant for each Flags type
...sconnect"];
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 "#define %-40s 0x%02x\n" flag i;
+ mask := !mask...
2019 Aug 10
0
[PATCH libnbd 2/9] generator: Generalize OFlags.
...(* return a boolean, or error *)
| RStaticString (* return a static string (must be located in
@@ -890,6 +890,10 @@ and cbarg =
| CBString of string (* like String *)
| CBUInt of string (* like UInt *)
| CBUInt64 of string (* like UInt64 *)
+and flags = {
+ flag_prefix : string; (* prefix of each flag name *)
+ flags : (string * int) list (* flag names and their values in C *)
+}
and permitted_state =
| Created (* can be called in the START state *)
| Connecting (* can be called when connecting/handshaking *)
@@ -906,6 +910,1...
2020 Sep 17
2
Re: [libnbd PATCH v2 4/5] api: Add STRICT_FLAGS to set_strict_mode
...; change: I probably would have put that change in a
separate commit. Also you could consider having a default_flags
parameter to avoid having to set guard = None everywhere, although you
would still have to make a one-off change to every *_flags. It would
look like this:
let default_flags = { flag_prefix = ""; guard = None; flags = [] }
...
let handshake_flags = {
default_flags with
flag_prefix = "HANDSHAKE_FLAG";
flags = [ ... ]
}
(We already do this with "default_call"). Neither of these is a big deal
though.
Rich.
> generator/API.ml |...
2020 Sep 11
10
[libnbd PATCH v2 0/5] Add knobs for client- vs. server-side validation
In v2:
- now based on my proposal to add LIBNBD_SHUTDOWN_IMMEDIATE
- four flags instead of two: STRICT_FLAGS is new (patch 4),
and STRICT_BOUNDS is separate from STRICT_ZERO_SIZE (patch 5)
- various refactorings for more shared code and less duplication
Eric Blake (5):
api: Add xxx_MASK constant for each Flags type
generator: Refactor filtering of accepted OFlags
api: Add
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
2020 Sep 11
0
[libnbd PATCH v2 4/5] api: Add STRICT_FLAGS to set_strict_mode
...c | 6 +++---
tests/errors.c | 22 ++++++++++++++++++++--
6 files changed, 68 insertions(+), 16 deletions(-)
diff --git a/generator/API.ml b/generator/API.ml
index aa970e6..4cd425b 100644
--- a/generator/API.ml
+++ b/generator/API.ml
@@ -87,6 +87,7 @@ and enum = {
}
and flags = {
flag_prefix : string;
+ guard : string option;
flags : (string * int) list
}
and permitted_state =
@@ -165,6 +166,7 @@ let all_enums = [ tls_enum; block_size_enum ]
(* Flags. See also Constants below. *)
let cmd_flags = {
flag_prefix = "CMD_FLAG";
+ guard = Some "((h->strict &...
2020 Sep 07
4
[libnbd PATCH v2 0/3] Improve type-safety of ocaml/golang getters
Well, the golang changes (patch 1 and 2/3 of v1) were already
committed, all that was left was the OCaml changes. I'm a lot happier
with how things turned out with an UNKNOWN constructor in the OCaml
variants.
Eric Blake (3):
tests: Enhance coverage of enum/flag range checking
ocaml: Support unknown values for Enum/Flags
ocaml: Typesafe returns for REnum/RFlags
generator/OCaml.ml
2020 Sep 11
0
[libnbd PATCH v2 2/5] generator: Refactor filtering of accepted OFlags
...uot; 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 (unlikely ((%s & ~LIBNBD_%s_MASK) != 0)) {\n" n flag_prefix;
+ let mask = match subset wi...
2020 Sep 06
8
[libnbd PATCH 0/3] Improve type-safety of ocaml/golang getters
Natural fallout after my recent testsuite additions that fixed a
couple of ocaml bugs in the setters. However, on at least the OCaml
code, I'm not sure what we should do if a newer libnbd ever returns a
bit that an older NBD.mli was not expecting at the time the OCaml
compiler ran (see below). I'm also not sure if there is a more
efficient way to avoid outputting Val_FOO() converters for
2019 Aug 10
0
[PATCH libnbd 3/9] generator: Add Enum type for enumerated types / unions.
...CBString of string (* like String *)
| CBUInt of string (* like UInt *)
| CBUInt64 of string (* like UInt64 *)
+and enum = {
+ enum_prefix : string; (* prefix of each enum variant *)
+ enums : (string * int) list (* enum names and their values in C *)
+}
and flags = {
flag_prefix : string; (* prefix of each flag name *)
flags : (string * int) list (* flag names and their values in C *)
@@ -910,6 +915,17 @@ let non_blocking_test_call_description = "\n
This call does not block, because it returns data that is saved in
the handle from the NBD protocol handshake.&q...
2020 Sep 06
0
[libnbd PATCH 2/3] golang: Typesafe returns for REnum/RFlags
...losed
*)
| RUInt -> Some "uint"
- | REnum (_) -> Some "uint" (* XXX return typed constant instead? *)
- | RFlags (_) -> Some "uint" (* XXX return typed constant instead? *)
+ | REnum ({ enum_prefix}) -> Some (camel_case enum_prefix)
+ | RFlags ({ flag_prefix}) -> Some (camel_case flag_prefix)
let go_ret_error = function
| RErr -> None
@@ -393,10 +393,10 @@ let print_binding (name, { args; optargs; ret; shortdesc }) =
pr " return &r, nil\n"
| RUInt ->
pr " return uint (ret), nil\n"
- | REnu...
2019 Aug 10
0
[PATCH libnbd 6/9] generator: Add non-optional Flags type.
...| Int64 n -> n
| Path n -> n
@@ -4706,6 +4723,7 @@ and ocaml_arg_to_string = function
| Closure { cbargs } ->
sprintf "(%s)" (ocaml_closuredecl_to_string cbargs)
| Enum (_, { enum_prefix }) -> sprintf "%s.t" enum_prefix
+ | Flags (_, { flag_prefix }) -> sprintf "%s.t" flag_prefix
| Int _ -> "int"
| Int64 _ -> "int64"
| Path _ -> "string"
@@ -4753,6 +4771,7 @@ let ocaml_name_of_arg = function
| BytesPersistOut (n, len) -> n
| Closure { cbname } -> cbname
| Enum (n, _)...
2019 Aug 13
0
[PATCH libnbd 5/6] generator: Implement OClosure.
...let args = args @ optargs in
@@ -4756,6 +4774,8 @@ and ocaml_ret_to_string = function
| RUInt -> "int"
and ocaml_optarg_to_string = function
+ | OClosure { cbname; cbargs } ->
+ sprintf "?%s:(%s)" cbname (ocaml_closuredecl_to_string cbargs)
| OFlags (n, { flag_prefix }) -> sprintf "?%s:%s.t list" n flag_prefix
and ocaml_closuredecl_to_string cbargs =
@@ -4794,6 +4814,7 @@ let ocaml_name_of_arg = function
| UInt64 n -> n
let ocaml_name_of_optarg = function
+ | OClosure { cbname } -> cbname
| OFlags (n, _) -> n
let num_params...
2019 Aug 13
0
[PATCH libnbd v2 1/3] generator: Implement OClosure.
...let args = args @ optargs in
@@ -4767,6 +4786,8 @@ and ocaml_ret_to_string = function
| RUInt -> "int"
and ocaml_optarg_to_string = function
+ | OClosure { cbname; cbargs } ->
+ sprintf "?%s:(%s)" cbname (ocaml_closuredecl_to_string cbargs)
| OFlags (n, { flag_prefix }) -> sprintf "?%s:%s.t list" n flag_prefix
and ocaml_closuredecl_to_string cbargs =
@@ -4805,6 +4826,7 @@ let ocaml_name_of_arg = function
| UInt64 n -> n
let ocaml_name_of_optarg = function
+ | OClosure { cbname } -> cbname
| OFlags (n, _) -> n
let num_params...
2019 Oct 04
0
[PATCH libnbd 3/4] api: Add nbd_connect_socket.
...one, None
@@ -5431,6 +5469,7 @@ and ocaml_arg_to_string = function
| Closure { cbargs } ->
sprintf "(%s)" (ocaml_closuredecl_to_string cbargs)
| Enum (_, { enum_prefix }) -> sprintf "%s.t" enum_prefix
+ | Fd _ -> "Unix.file_descr"
| Flags (_, { flag_prefix }) -> sprintf "%s.t" flag_prefix
| Int _ -> "int"
| Int64 _ -> "int64"
@@ -5482,6 +5521,7 @@ let ocaml_name_of_arg = function
| BytesPersistOut (n, len) -> n
| Closure { cbname } -> cbname
| Enum (n, _) -> n
+ | Fd n -> n
| Flags...
2020 Sep 17
0
Re: [libnbd PATCH v2 4/5] api: Add STRICT_FLAGS to set_strict_mode
...put that change in a
> separate commit. Also you could consider having a default_flags
> parameter to avoid having to set guard = None everywhere, although you
> would still have to make a one-off change to every *_flags. It would
> look like this:
>
> let default_flags = { flag_prefix = ""; guard = None; flags = [] }
> ...
> let handshake_flags = {
> default_flags with
> flag_prefix = "HANDSHAKE_FLAG";
> flags = [ ... ]
> }
>
> (We already do this with "default_call"). Neither of these is a big d...
2020 Sep 06
0
[libnbd PATCH 1/3] generator: Introduce REnum/RFlags return types
...ing to avoid a memory leak.\n";
| RUInt ->
- pr "This call returns a bitmask.\n"
+ pr "This call returns a bitmask.\n";
+ | REnum ({ enum_prefix }) ->
+ pr "This call returns one of the LIBNBD_%s_* values.\n" enum_prefix;
+ | RFlags ({ flag_prefix }) ->
+ pr "This call returns a bitmask of LIBNBD_%s_* values.\n" flag_prefix;
);
pr "\n";
diff --git a/generator/GoLang.ml b/generator/GoLang.ml
index 65b3690..732b81f 100644
--- a/generator/GoLang.ml
+++ b/generator/GoLang.ml
@@ -1,3 +1,4 @@
+(* hey emacs, this...