All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Lindig <christian.lindig@citrix.com>
To: Edwin Torok <edvin.torok@citrix.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	"David Scott" <dave@recoil.org>, Ian Jackson <iwj@xenproject.org>,
	Wei Liu <wl@xen.org>, Andrew Cooper <Andrew.Cooper3@citrix.com>
Subject: Re: [PATCH] tools/ocaml/libs/xc: add OCaml stubs to query CPU policy
Date: Fri, 18 Jun 2021 13:09:38 +0000	[thread overview]
Message-ID: <70BA77FE-045D-4F67-A61E-030CFAACC8B1@citrix.com> (raw)
In-Reply-To: <5fdb7b4cdee69af8e2b9d77b56b1027a8799cf04.1624012999.git.edvin.torok@citrix.com>

[-- Attachment #1: Type: text/plain, Size: 1605 bytes --]



On 18 Jun 2021, at 11:45, Edwin Török <edvin.torok@citrix.com<mailto:edvin.torok@citrix.com>> wrote:

Introduces following functions in Xenctrl and associated types:
get_system_cpu_policy
cpu_policy_to_featureset,
string_of_xen_cpu_policy_index

These are wrappers around the existing C functions in xenctrl.h,
that will be used by xenopsd initially.

-Wno-declaration-after-statement is disabled to allow mixing
declarations and code to simplify writing the stubs
by using variable length arrays on the stack instead of
allocating/freeing memory
(which would require additional error-handling logic).

Signed-off-by: Edwin Török <edvin.torok@citrix.com<mailto:edvin.torok@citrix.com>>
---
tools/ocaml/libs/xc/Makefile        |   2 +-
tools/ocaml/libs/xc/xenctrl.ml      |  37 ++++++
tools/ocaml/libs/xc/xenctrl.mli     |  71 ++++++++++
tools/ocaml/libs/xc/xenctrl_stubs.c | 195 ++++++++++++++++++++++++++++
4 files changed, 304 insertions(+), 1 deletion(-)

Acked-by: Christian Lindig <christian.lindig@citrix.com<mailto:christian.lindig@citrix.com>>


+static CAMLprim value Val_leaves(const xen_cpuid_leaf_t *leaves, uint32_t nr_leaves)
+{
+    CAMLparam0();
+    CAMLlocal1(result);
+    uint32_t i;
+
+    result = caml_alloc(nr_leaves, 0);
+    for (i=0;i<nr_leaves;i++)
+        Store_field(result, i, Val_cpuid_leaf(&leaves[i]));
+
+    CAMLreturn(result);
+}

Is  caml_alloc(nr_leaves, 0) the right allocation? The 0 is the tag. There is another instance of this below. What is the type of the returned value from an OCaml perspective?

— C


[-- Attachment #2: Type: text/html, Size: 3199 bytes --]

  reply	other threads:[~2021-06-18 13:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-18 10:45 [PATCH] tools/ocaml/libs/xc: add OCaml stubs to query CPU policy Edwin Török
2021-06-18 13:09 ` Christian Lindig [this message]
2021-06-18 13:42   ` Edwin Torok
2021-06-18 13:17 ` Andrew Cooper
2021-06-18 13:46   ` Edwin Torok
2021-06-18 17:07     ` Andrew Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=70BA77FE-045D-4F67-A61E-030CFAACC8B1@citrix.com \
    --to=christian.lindig@citrix.com \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=dave@recoil.org \
    --cc=edvin.torok@citrix.com \
    --cc=iwj@xenproject.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.