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

[PATCH v4 11/11] tools/ocaml/libs/xb: drop Xs_ring.write


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Edwin Török <edvin.torok@xxxxxxxxxx>
  • Date: Fri, 16 Dec 2022 18:25:20 +0000
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Edwin Török <edvin.torok@xxxxxxxxxx>, "Christian Lindig" <christian.lindig@xxxxxxxxxx>, David Scott <dave@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Fri, 16 Dec 2022 18:35:14 +0000
  • Ironport-data: A9a23:eOu/0qsLfcxAOp4K2gFheW1dIufnVFheMUV32f8akzHdYApBsoF/q tZmKWyFOq7bYWTxf9l/YInnpkNVvMeAmIBhTFY4qS40FyJB+JbJXdiXEBz9bniYRiHhoOCLz O1FM4Wdc5pkJpP4jk3wWlQ0hSAkjclkfpKlVKiffHg0HVU/IMsYoUoLs/YjhYJ1isSODQqIu Nfjy+XSI1bg0DNvWo4uw/vrRChH4bKj5lv0gnRkPaoR5QWHySFPZH4iDfrZw0XQE9E88tGSH 44v/JnhlkvF8hEkDM+Sk7qTWiXmlZaLYGBiIlIPM0STqkAqSh4ai87XB9JFAatjsB2bnsgZ9 Tl4ncfYpTHFnEH7sL91vxFwS0mSNEDdkVPNCSDXXce7lyUqf5ZwqhnH4Y5f0YAwo45K7W9yG fMwNDQdXDq9rOWP8om2Fe5+q55zPvTXBdZK0p1g5Wmx4fcORJnCR+PB5MNC3Sd2jcdLdRrcT 5NHM3w1Nk2GOkARfAdMYH49tL7Aan3XfjFGqVTTua0t5Gv7xw1tyrn9dtHSf7RmQO0Fzx/J+ DidrwwVBDlHLdGd8R/d0E6woeXUxyW4Ut0+KIeRo6sCbFq7mTVIVUx+uUGAiea9ol6zXZRYM UN80iYns6Ua7kGgSdj5GRqirxasrhMaHtZdDeA+wAWM0bbPpRaUAHAeSTxMY8Bgs9U5LQHGz XfQwYmvX2Y29uTIFzTNrd94sA9eJwAJKX8wTxEvSjI32NS8p5Me1ELdc+paRfvdYsLOJRn8x DWDrS4bjroVjNIW26jTwW0rkw5AtbCSEFdru1y/snaNq1ogOdX7P9DABU3zt64oEWqPcrWWU JHoceC65ftGM5yCnTflrA4lTODwvKbt3NExbDdS83gdG9aFoSbLkWN4umsWyKJV3iEsJ1fUj Lf741852XOqFCLCgVVLS4ywEd826qPrCM7oUPvZBvIXPMcoLVXWpXA+PRLOt4wIrKTLufhvU ap3jO72VSpKYUiZ5GTeqxghPU8DmXllmDK7qWHTxBW7y7uODEN5up9cWGZimtsRtfveyC2Mq oY3Cid/40kHOAEISnWNoNF7wJFjBSRTOK0aXOQLLr/ef1Y7Rj5xYxITqJt4E7FYc21uvr+g1 hmAtoVwmTITWVWvxd22V01e
  • Ironport-hdrordr: A9a23:c7rWG6wBgPE0eKs+LT7gKrPwy71zdoMgy1knxilNoEpuA6qlfq GV88jzsCWftN9/Yh0dcLy7SdK9qDbnhOZICOoqU4tKPjOW31dAd7sSj7cKqgeIcxEWtNQttp uIFZIObeEYZmIK9PoSjjPUL/8QhPGb9eSRmevDw1dBJDsaEZ1I3kNQFwOSCFd3TA4DIZI4Ed 656tBcrzStPVQbB/7bOlA1G8DfotXQjpLvZlojDx4jrDSUhTSz4LTmEx6emjcSOgku/V8tmV K19zARtp/Jj82G
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Unused, only Xs_ring.write_substring is used.
Also the bytes/string conversion here is backwards: the C stub implements the
bytes version and then we use a Bytes.unsafe_of_string to convert a string into
bytes.

However the operation here really is read-only: we read from the string and
write it to the ring, so the C stub should implement the read-only string
version, and if needed we could use Bytes.unsafe_to_string to be able to send
'bytes'. However that is not necessary as the 'bytes' version is dropped above.

Signed-off-by: Edwin Török <edvin.torok@xxxxxxxxxx>
---
Changes:
* new patch
---
 tools/ocaml/libs/xb/xs_ring.ml      | 5 +----
 tools/ocaml/libs/xb/xs_ring_stubs.c | 2 +-
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/tools/ocaml/libs/xb/xs_ring.ml b/tools/ocaml/libs/xb/xs_ring.ml
index 2a27aa56c2..87c6b243e4 100644
--- a/tools/ocaml/libs/xb/xs_ring.ml
+++ b/tools/ocaml/libs/xb/xs_ring.ml
@@ -25,14 +25,11 @@ module Server_features = Set.Make(struct
   end)
 
 external read: Xenmmap.mmap_interface -> bytes -> int -> int = 
"ml_interface_read"
-external write: Xenmmap.mmap_interface -> bytes -> int -> int = 
"ml_interface_write"
+external write_substring: Xenmmap.mmap_interface -> string -> int -> int = 
"ml_interface_write"
 
 external _internal_set_server_features: Xenmmap.mmap_interface -> int -> unit 
= "ml_interface_set_server_features" [@@noalloc]
 external _internal_get_server_features: Xenmmap.mmap_interface -> int = 
"ml_interface_get_server_features" [@@noalloc]
 
-let write_substring mmap buff len =
-  write mmap (Bytes.unsafe_of_string buff) len
-
 let get_server_features mmap =
   (* NB only one feature currently defined above *)
   let x = _internal_get_server_features mmap in
diff --git a/tools/ocaml/libs/xb/xs_ring_stubs.c 
b/tools/ocaml/libs/xb/xs_ring_stubs.c
index 28c79ee139..dca6059b0d 100644
--- a/tools/ocaml/libs/xb/xs_ring_stubs.c
+++ b/tools/ocaml/libs/xb/xs_ring_stubs.c
@@ -119,7 +119,7 @@ CAMLprim value ml_interface_write(value ml_interface,
     CAMLlocal1(ml_result);
 
     struct mmap_interface *interface = GET_C_STRUCT(ml_interface);
-    const unsigned char *buffer = Bytes_val(ml_buffer);
+    const char *buffer = String_val(ml_buffer);
     int len = Int_val(ml_len);
     int result;
 
-- 
2.34.1




 


Rackspace

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