Displaying 20 results from an estimated 187 matches for "val_int".
2020 Sep 01
3
Re: [nbdkit PATCH 2/2] ocaml: Implement .list_exports and friends
...he
export record.
https://caml.inria.fr/pub/docs/manual-ocaml/intfc.html#s%3Ac-ocaml-datatype-repr
didn't directly answer my question, but my understanding is that since
'string option' is the same as:
type 'a t = a' option =
| None (* Is_block is false, value is Val_int(0) *)
| Some of 'a (* Is_block is true, value is block with tag 0 *)
then checking Is_block tells me whether I have None or Some string, at
which point another Field() deref gets me to the string contained in
that block.
diff --git i/plugins/ocaml/NBDKit.mli w/plugins/ocaml/NBDKit.mli...
2020 Sep 01
1
Re: [nbdkit PATCH 2/2] ocaml: Implement .list_exports and friends
...OCaml blocks are lists of values allocated on the OCaml heap:
> https://rwmj.wordpress.com/2009/08/05/ocaml-internals-part-2-strings-and-other-types/
> and those values may be ints or pointers.
>
> Therefore the easiest way to tell if something is None from C is
> to compare it with Val_int(0), ie:
>
> value v = /* something which has type ‘string option’ */;
>
> if (v == Val_int(0)) /* It's None */
> printf ("None\n");
> else {
> /* It's Some string, set sv to the string value */
> value sv = Field (v, 0);
>...
2020 Sep 07
0
[libnbd PATCH v2 3/3] ocaml: Typesafe returns for REnum/RFlags
...uot;Val_%s (int i)\n" enum_prefix;
+ pr "{\n";
+ pr " CAMLparam0 ();\n";
+ pr " CAMLlocal1 (rv);\n";
+ pr "\n";
+ pr " switch (i) {\n";
+ List.iteri (
+ fun i (enum, _) ->
+ pr " case LIBNBD_%s_%s: rv = Val_int (%d); break;\n" enum_prefix enum i
+ ) enums;
+ pr " default:\n";
+ pr " rv = caml_alloc (1, 0); /* UNKNOWN of int */\n";
+ pr " Store_field (rv, 0, Val_int (i));\n";
+ pr " }\n";
+ pr "\n";
+ pr " CAMLretur...
2020 Sep 01
0
Re: [nbdkit PATCH 2/2] ocaml: Implement .list_exports and friends
...tps://caml.inria.fr/pub/docs/manual-ocaml/intfc.html#s%3Ac-ocaml-datatype-repr
> didn't directly answer my question, but my understanding is that
> since 'string option' is the same as:
>
> type 'a t = a' option =
> | None (* Is_block is false, value is Val_int(0) *)
> | Some of 'a (* Is_block is true, value is block with tag 0 *)
>
> then checking Is_block tells me whether I have None or Some string,
> at which point another Field() deref gets me to the string contained
> in that block.
All ‘value’ things in OCaml are just 64 bit...
2019 Apr 08
0
[PATCH v4 2/7] common: Bundle the libvirt-ocaml library for use by virt-v2v
...RROR (!r, \"$c_name\");
+
+ rv = caml_copy_string (r);
+ CAMLreturn (rv);
+"
+ } elsif ($sig =~ /^(\w+) : int$/) {
+ "\
+ " . gen_unpack_args ($1) . "
+ int r;
+
+ NONBLOCKING (r = $c_name ($1));
+ CHECK_ERROR (r == -1, \"$c_name\");
+
+ CAMLreturn (Val_int (r));
+"
+ } elsif ($sig =~ /^(\w+) : uuid$/) {
+ "\
+ CAMLlocal1 (rv);
+ " . gen_unpack_args ($1) . "
+ unsigned char uuid[VIR_UUID_BUFLEN];
+ int r;
+
+ NONBLOCKING (r = $c_name ($1, uuid));
+ CHECK_ERROR (r == -1, \"$c_name\");
+
+ /* UUIDs are byte arrays...
2019 Dec 16
3
[v2v PATCH 0/2] Move libvirt-ocaml copy to v2v repo
libvirt-ocaml is used only by virt-v2v, so move it to this repository,
instead of having it around in the common submodule.
The removal from common will happen later.
Pino Toscano (2):
common: Bundle the libvirt-ocaml library for use by virt-v2v
build: switch embedded copy of libvirt-ocaml
.gitignore | 2 +
3rdparty/libvirt-ocaml/Makefile.am |
2017 Jul 31
0
[PATCH v11 02/10] daemon: Embed the ocaml-augeas library in the daemon.
...ring option -> flag list -> t */
+CAMLprim value
+ocaml_augeas_create (value rootv, value loadpathv, value flagsv)
+{
+ CAMLparam1 (rootv);
+ char *root = String_val (rootv);
+ char *loadpath;
+ int flags = 0, i;
+ augeas_t t;
+
+ /* Optional loadpath. */
+ loadpath =
+ loadpathv == Val_int (0)
+ ? NULL
+ : String_val (Field (loadpathv, 0));
+
+ /* Convert list of flags to C. */
+ for (; flagsv != Val_int (0); flagsv = Field (flagsv, 1)) {
+ i = Int_val (Field (flagsv, 0));
+ flags |= flag_map[i];
+ }
+
+ t = aug_init (root, loadpath, flags);
+
+ if (t == NULL)
+ r...
2018 Aug 30
8
[PATCH 0/7] RFC: switch v2v to ocaml-libvirt
Hi,
this is a mostly done attempt to switch to ocaml-libvirt, embedding the
latest version of it from git. This way, it is possible to improve the
way v2v connects to libvirt for both input, and output modules, and
interacts with libvirt (e.g. no more virsh calls needed in virt-v2v).
As side effect, virt-v2v now requires libvirt, as keeping it optional
would create too much burden.
I could not
2018 Nov 27
8
[PATCH v2 0/7] RFC: switch v2v to ocaml-libvirt
Hi,
this is a mostly done attempt to switch to ocaml-libvirt, embedding the
latest version of it from git. This way, it is possible to improve the
way v2v connects to libvirt for both input, and output modules, and
interacts with libvirt (e.g. no more virsh calls needed in virt-v2v).
As side effect, virt-v2v now requires libvirt, as keeping it optional
would create too much burden.
I could not
2019 Jan 30
8
[PATCH v3 0/7] RFC: switch v2v to ocaml-libvirt
Hi,
this is a mostly done attempt to switch to ocaml-libvirt, embedding the
latest version of it from git. This way, it is possible to improve the
way v2v connects to libvirt for both input, and output modules, and
interacts with libvirt (e.g. no more virsh calls needed in virt-v2v).
As side effect, virt-v2v now requires libvirt, as keeping it optional
would create too much burden.
I could not
2015 Aug 24
3
[PATCH 1/3] ocaml: dynamically generate the content of Guestfs.Errno
...t gcc warnings. */
+";
+ List.iter (
+ fun e ->
+ pr "value ocaml_guestfs_get_%s (value unitv);\n" e
+ ) ocaml_errnos;
+
+ List.iter (
+ fun e ->
+ pr "\
+
+/* NB: \"noalloc\" function. */
+value
+ocaml_guestfs_get_%s (value unitv)
+{
+ return Val_int (%s);
+}
+" e e
+ ) ocaml_errnos
+
and generate_ocaml_structure_decls () =
List.iter (
fun { s_name = typ; s_cols = cols } ->
diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am
index db13a8f..e781363 100644
--- a/ocaml/Makefile.am
+++ b/ocaml/Makefile.am
@@ -21,6 +21,7 @@ generato...
2019 May 20
8
[PATCH v5 0/7] v2v: switch to ocaml-libvirt
Hi,
this series switches virt-2v to ocaml-libvirt, embedding the latest
version of it from git. This way, it is possible to improve the way
v2v connects to libvirt for both input, and output modules, and
interacts with libvirt (e.g. no more virsh calls needed in virt-v2v).
As side effect, virt-v2v now requires libvirt, as keeping it optional
would create too much burden.
I could not test all
2020 Sep 06
0
[libnbd PATCH 3/3] ocaml: Typesafe returns for REnum/RFlags
...";
+ pr "Val_%s (int i)\n" enum_prefix;
+ pr "{\n";
+ pr " CAMLparam0 ();\n";
+ pr " CAMLlocal1 (rv);\n";
+ pr "\n";
+ pr " switch (i) {\n";
+ List.iteri (
+ fun i (enum, _) ->
+ pr " case LIBNBD_%s_%s: rv = Val_int (%d); break;\n" enum_prefix enum i
+ ) enums;
+ (* Possible if newer libnbd returns value not present in older compilation *)
+ pr " default: abort ();\n";
+ pr " }\n";
+ pr "\n";
+ pr " CAMLreturn (rv);\n";
+ pr "}\n";
pr "...
2013 Mar 25
86
[PATCH 00/28] libxl: ocaml: improve the bindings
The following series of patches fill in most of the gaps in the OCaml bindings
to libxl, to make them useful for clients such as xapi/xenopsd (from XCP).
There are a number of bugfixes to the existing bindings as well. I have an
experimental version of xenopsd that successfully uses the new bindings.
An earlier version of the first half of the series was submitted to the last
by Ian Campbell on
2019 Apr 08
12
[PATCH 43 0/7] v2v: switch to ocaml-libvirt
Hi,
this series switches virt-2v to ocaml-libvirt, embedding the latest
version of it from git. This way, it is possible to improve the way
v2v connects to libvirt for both input, and output modules, and
interacts with libvirt (e.g. no more virsh calls needed in virt-v2v).
As side effect, virt-v2v now requires libvirt, as keeping it optional
would create too much burden.
I could not test all
2017 Aug 09
0
[PATCH v12 02/11] common: Bundle the ocaml-augeas library for use by the daemon.
...ring option -> flag list -> t */
+CAMLprim value
+ocaml_augeas_create (value rootv, value loadpathv, value flagsv)
+{
+ CAMLparam1 (rootv);
+ char *root = String_val (rootv);
+ char *loadpath;
+ int flags = 0, i;
+ augeas_t t;
+
+ /* Optional loadpath. */
+ loadpath =
+ loadpathv == Val_int (0)
+ ? NULL
+ : String_val (Field (loadpathv, 0));
+
+ /* Convert list of flags to C. */
+ for (; flagsv != Val_int (0); flagsv = Field (flagsv, 1)) {
+ i = Int_val (Field (flagsv, 0));
+ flags |= flag_map[i];
+ }
+
+ t = aug_init (root, loadpath, flags);
+
+ if (t == NULL)
+ r...
2020 Oct 03
0
[PATCH nbdkit v2 3/3] ocaml: Add bindings for nbdkit_peer_{pid, uid, gid}.
...100644
--- a/plugins/ocaml/bindings.c
+++ b/plugins/ocaml/bindings.c
@@ -190,3 +190,27 @@ ocaml_nbdkit_debug (value strv)
return Val_unit;
}
+
+value
+ocaml_nbdkit_peer_pid (value unitv)
+{
+ int id = nbdkit_peer_pid ();
+ if (id == -1) caml_failwith ("nbdkit_peer_pid");
+ return Val_int (id);
+}
+
+value
+ocaml_nbdkit_peer_uid (value unitv)
+{
+ int id = nbdkit_peer_uid ();
+ if (id == -1) caml_failwith ("nbdkit_peer_uid");
+ return Val_int (id);
+}
+
+value
+ocaml_nbdkit_peer_gid (value unitv)
+{
+ int id = nbdkit_peer_gid ();
+ if (id == -1) caml_failwith ("n...
2016 Jul 18
2
[PATCH] mllib: Getopt: fix integer parsing
...nf (optarg, "%d", &num) != 1) {
- fprintf (stderr, _("'%s' is not a numeric value.\n"),
- guestfs_int_program_name);
- show_error (EXIT_FAILURE);
- }
+ num = strtoint (optarg);
v = Field (actionv, 1);
do_call1 (v, Val_int (num));
break;
case 6: /* Set_int of string * int ref */
- if (sscanf (optarg, "%d", &num) != 1) {
- fprintf (stderr, _("'%s' is not a numeric value.\n"),
- guestfs_int_program_name);
- show_error (EXIT_FAILURE);
-...
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
2019 Dec 16
4
[PATCH 0/2] Move ocaml-augeas copy to libguestfs repo
ocaml-augeas is used only by virtlibguestfs, so move it to this
repository, instead of having it around in the common submodule.
The removal from common will happen later.
Pino Toscano (2):
Bundle the ocaml-augeas library for use by libguestfs
build: switch embedded copy of ocaml-augeas
.gitignore | 1 +
3rdparty/ocaml-augeas/COPYING.LIB | 515