[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] tools/ocaml/evtchn: Misc cleanup
commit 40893f5ac6f2405656ffe0c75099f75b1817b641 Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> AuthorDate: Mon Jan 30 16:37:49 2023 +0000 Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CommitDate: Mon Feb 6 10:22:12 2023 +0000 tools/ocaml/evtchn: Misc cleanup * 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> Acked-by: Christian Lindig <christian.lindig@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 d7881ca95f..34dcfed302 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); } -- generated by git-patchbot for /home/xen/git/xen.git#master
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |