[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 4/7] tools/ocaml/evtchn: Misc cleanup


  • To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Tue, 31 Jan 2023 21:29:10 +0000
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Christian Lindig <christian.lindig@xxxxxxxxxx>, David Scott <dave@xxxxxxxxxx>, Edwin Török <edwin.torok@xxxxxxxxx>, Rob Hoes <Rob.Hoes@xxxxxxxxxx>
  • Delivery-date: Tue, 31 Jan 2023 21:29:40 +0000
  • Ironport-data: A9a23:UaIn26Dp78IZrxVW/yjjw5YqxClBgxIJ4kV8jS/XYbTApG8ghmNWy TcbCG+EOvyDYmOgL4t1O4Ti9RsHuZ/Wm9M1QQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48T8nk/nNHuCnYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbyRFtMpvlDs15K6p4GpD5wRlDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIw0/5SWVMJ1 +IhMTkAYjTY28uE8qOCY7w57igjBJGD0II3v3hhyXfSDOo8QICFSKLPjTNa9G5u3IYUR6+YP pdHL2M1N3wsYDUWUrsTILs4kP2lmT/UdDpApUjOjaE2/3LS3Ep6172F3N/9K4HWFJQMzh/wS mTu2zrFWkslF8Wl8BWZ8m6QivTwwy3UcddHfFG/3qEz2wDCroAJMzUGWF3+rfSnh0qWX9NEN 1dS6icotbI19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Bdr9ljbdUU6YtHNZA7co6MLmK41b2MGfxGXPXJU6iGLAMOnrLpZKy6LIp5PuycJhNyJcpgp zOXF5RqGZ3IivVeLuz9YwO9gqITHS2XDzrxM0b759luqfkTL6uNSGYUlghn8apvv1aCMzGXP S4Po5QHpbYXBzTMJcM2xe7V4hZKHEYXsFQstEnW0iWqsaOMYHuvvyzSoehGFMsK0dVZorSOA pzYNGoHrQ+0qmCYA6HvCTs
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

 * Remove local integers when all we're returning is Val_int() of another
   variable.  The CAMLlocal*() can't be optimised automatically, as it's
   registered with the GC.
 * Rename "virq_type" to "virq" and "_port" to "port".
 * In stub_eventchn_pending(), rename 'port' to 'rc', to be consistent with
   all other stubs that return xenevtchn_port_or_error_t.
 * In stub_eventchn_unmask(), check for rc == -1 to be consistent with all
   other stubs.

No practical change.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Christian Lindig <christian.lindig@xxxxxxxxxx>
CC: David Scott <dave@xxxxxxxxxx>
CC: Edwin Török <edwin.torok@xxxxxxxxx>
CC: Rob Hoes <Rob.Hoes@xxxxxxxxxx>
---
 tools/ocaml/libs/eventchn/xeneventchn_stubs.c | 45 +++++++++++----------------
 1 file changed, 18 insertions(+), 27 deletions(-)

diff --git a/tools/ocaml/libs/eventchn/xeneventchn_stubs.c 
b/tools/ocaml/libs/eventchn/xeneventchn_stubs.c
index d7881ca95f98..34dcfed30275 100644
--- a/tools/ocaml/libs/eventchn/xeneventchn_stubs.c
+++ b/tools/ocaml/libs/eventchn/xeneventchn_stubs.c
@@ -98,17 +98,15 @@ CAMLprim value stub_eventchn_fdopen(value fdval)
 CAMLprim value stub_eventchn_fd(value xce_val)
 {
        CAMLparam1(xce_val);
-       CAMLlocal1(result);
        xenevtchn_handle *xce = xce_of_val(xce_val);
        int fd;
 
+       /* Don't drop the GC lock.  This is a simple read out of memory */
        fd = xenevtchn_fd(xce);
        if (fd == -1)
                caml_failwith("evtchn fd failed");
 
-       result = Val_int(fd);
-
-       CAMLreturn(result);
+       CAMLreturn(Val_int(fd));
 }
 
 CAMLprim value stub_eventchn_notify(value xce_val, value port)
@@ -131,37 +129,34 @@ CAMLprim value stub_eventchn_bind_interdomain(value 
xce_val, value domid,
                                               value remote_port)
 {
        CAMLparam3(xce_val, domid, remote_port);
-       CAMLlocal1(port);
        xenevtchn_handle *xce = xce_of_val(xce_val);
        xenevtchn_port_or_error_t rc;
 
        caml_enter_blocking_section();
-       rc = xenevtchn_bind_interdomain(xce, Int_val(domid), 
Int_val(remote_port));
+       rc = xenevtchn_bind_interdomain(xce, Int_val(domid),
+                                       Int_val(remote_port));
        caml_leave_blocking_section();
 
        if (rc == -1)
                caml_failwith("evtchn bind_interdomain failed");
-       port = Val_int(rc);
 
-       CAMLreturn(port);
+       CAMLreturn(Val_int(rc));
 }
 
-CAMLprim value stub_eventchn_bind_virq(value xce_val, value virq_type)
+CAMLprim value stub_eventchn_bind_virq(value xce_val, value virq)
 {
-       CAMLparam2(xce_val, virq_type);
-       CAMLlocal1(port);
+       CAMLparam2(xce_val, virq);
        xenevtchn_handle *xce = xce_of_val(xce_val);
        xenevtchn_port_or_error_t rc;
 
        caml_enter_blocking_section();
-       rc = xenevtchn_bind_virq(xce, Int_val(virq_type));
+       rc = xenevtchn_bind_virq(xce, Int_val(virq));
        caml_leave_blocking_section();
 
        if (rc == -1)
                caml_failwith("evtchn bind_virq failed");
-       port = Val_int(rc);
 
-       CAMLreturn(port);
+       CAMLreturn(Val_int(rc));
 }
 
 CAMLprim value stub_eventchn_unbind(value xce_val, value port)
@@ -183,35 +178,31 @@ CAMLprim value stub_eventchn_unbind(value xce_val, value 
port)
 CAMLprim value stub_eventchn_pending(value xce_val)
 {
        CAMLparam1(xce_val);
-       CAMLlocal1(result);
        xenevtchn_handle *xce = xce_of_val(xce_val);
-       xenevtchn_port_or_error_t port;
+       xenevtchn_port_or_error_t rc;
 
        caml_enter_blocking_section();
-       port = xenevtchn_pending(xce);
+       rc = xenevtchn_pending(xce);
        caml_leave_blocking_section();
 
-       if (port == -1)
+       if (rc == -1)
                caml_failwith("evtchn pending failed");
-       result = Val_int(port);
 
-       CAMLreturn(result);
+       CAMLreturn(Val_int(rc));
 }
 
-CAMLprim value stub_eventchn_unmask(value xce_val, value _port)
+CAMLprim value stub_eventchn_unmask(value xce_val, value port)
 {
-       CAMLparam2(xce_val, _port);
+       CAMLparam2(xce_val, port);
        xenevtchn_handle *xce = xce_of_val(xce_val);
-       evtchn_port_t port;
        int rc;
 
-       port = Int_val(_port);
-
        caml_enter_blocking_section();
-       rc = xenevtchn_unmask(xce, port);
+       rc = xenevtchn_unmask(xce, Int_val(port));
        caml_leave_blocking_section();
 
-       if (rc)
+       if (rc == -1)
                caml_failwith("evtchn unmask failed");
+
        CAMLreturn(Val_unit);
 }
-- 
2.11.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.