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

Re: [PATCH v2 4/5] tools/ocaml/libs/xc: OCaml 5.0 compatibility


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Edwin Torok <edvin.torok@xxxxxxxxxx>
  • Date: Tue, 27 Sep 2022 16:13:08 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=W7Ui61OuPdjEgYUwdZeyClV9lhVkX8/EMlQPr18LY3Y=; b=QrVjuuA3IFTT0QLHpzH7bnLEyX2z2KD3cm3xFK9d4YZBZOPj1bh8YGp5Gp+nnJoWtEKC8jq7I3yyqq/TAIGcoPD3i24ZKNjyyBJDy9gsVbf7Y5CoLxn3JUEdZ7FAkkWZ8aLKhkRkVsnBwR2SQcRoVPoFyFYGkKsofREweiO/4uVAyswAqTb7bT0y1TNHrtTlki15As5VCldsYJMQDAX73gr2O4gCplvh3xDhpf/1QKjPyVw7fy2Tn83hW8mElXEl2BANCmG+3J5QiMckAMCoY+a8S2Hg1quEiMziIFnn+oi401SdywIcrJuPzhUFLXS79q2qtSaxJxGmFiyun/sOHA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QWV82Km+U7RQPy/v2Nl724KjSDL/jq5iJBoH7+6681JaxLCD0yvHE1hpL76hUTtD7b/uZ5wyYQYdnxfLigtp1FZ8v/HJM+vUHZ08GD9ki2SHnQbu6UxZnfjRj0G0Ttrj1MRT0NSBbnp5QeuZRj2Jlv3FGFnFUZ61cjF79M9KwpM7OzvTkZx+ldaPHrHklBv/S4orOggL+j1adpW3fjITI79eDa1FqHxOu8IQ0hqHgVIyu0glRK13h++rchfGMZV4cQniKqnAxrk3EPC6sAJ4TPcDI+UNDg2/ovEj/LWDYQoyimWO/fvebd5KUGXv8bd4LpQE/6Vl8r8u+keO0TqTmQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Christian Lindig <christian.lindig@xxxxxxxxxx>, David Scott <dave@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Tue, 27 Sep 2022 16:13:23 +0000
  • Ironport-data: A9a23:DVKJFaAUcNUf8xVW/zPiw5YqxClBgxIJ4kV8jS/XYbTApGkk12ZSn GobCGHTaa7fYTD8e9gjPoqy9k9SvJfTndJmQQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48T8mk/ngqoPUUIbsIjp2SRJvVBAvgBdin/9RqoNziJ2yDhjlV ena+qUzA3f4nW8vWo4ow/jb8kk37a6t4GlwUmEWPpingnePzxH5M7pHTU2BByOQapVZGOe8W 9HCwNmRlo8O105wYj8Nuu+TnnwiGtY+DyDX4pZlc/HKbix5jj4zys4G2M80Mi+7vdkrc+dZk 72hvbToIesg0zaldO41C3G0GAkmVUFKFSOuzdFSfqV/wmWfG0YAzcmCA2kGJ4cF3OVbEVtH/ OIKcg0zSTTAoruPlefTpulE3qzPLeHNFaZG4jRK626cCvwrB5feX6/N+NlUmi8qgdxDFurfY MxfbidzaBPHYFtEPVJ/5JAWxb/0wCWgNWIA7gvN9MLb4ECKpOB1+LXhLtvTPMCNX8JWtk2Zu njH7yLyBRRy2Nm3mWPcqyv93LOncSXTd71CS52kx/9WqXKe2Ew6UDsPUXm0rqzs4qK5c5cFQ 6AOwQI+oK53+EG1Q93VWxyjvGXCrhMaQ8BXEeAx9EeK0KW8ywqQGGUsVDNKb90i8sgsSlQCy Vuhj97vQzt1v9WopWm1876VqXa4P3cTJGpbPSscF1Jdsp/kvZ05iQ/JQpB7Cqmpg9bpGDb2h TeXsCw5gLZVhskOv0mmwW36b/uXjsChZmYICs//BDjNAt9RDGJ9W7GV1A==
  • Ironport-hdrordr: A9a23:T+ZmRKC2oapM19TlHegPsceALOsnbusQ8zAXPh9KJCC9I/bzqy nxpp8mPEfP+U0ssHFJo6HiBEEZKUmsuKKdkrNhR4tKOzOW9FdATbsSp7cKpgeNJ8SQzJ876U 4NSclD4ZjLfCBHZKXBkUaF+rQbsb+6GcmT7I+woUuFDzsaEp2IhD0JaDpzZ3cGIDWucqBJca Z0iPAmmxOQPVAsKuirDHgMWObO4/fRkoj9XBIADxk7rCGTkDKB8tfBYlml9yZbdwkK7aYp8G DDnQC8zL6kqeuHxhjV0HKWx4hKmeHm1sBICKW3+4gow3TX+0WVjbZaKvi/VQMO0aWSAZER4Z 7xSiIbToZOArXqDyeISFXWqlDdOX0VmgLfIBej8AfeSIrCNXwH4oN69PxkWwqc5Ew6sN5m1q VXm2qfqppMFBvF2D/w/t7SSnhR5wOJSepLq59ts5Vza/poVFZql/1owGpFVJMbWC7q4oEuF+ djSMna+fZNaFufK3TUpHNmztCgVmk6Wk7ueDlIhuWFlzxN2HxpxUoRw8IS2n8G6ZImUpFBo+ DJKL5hmr1CRtIfKah9GOACS82qDXGle2OFDEuCZVD8UK0XMXPErJD6pL0z+eGxYZQNiIA/nZ zQOWkowVLau3iefPFm8Kc7gSwlGl/NLAgF4vsul6RRq/n7WKfhNzGFRRQnj9agys9vcPHmZw ==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHY0mKHWIzo/zbfF0KNs+muY99n/a3zc0gA
  • Thread-topic: [PATCH v2 4/5] tools/ocaml/libs/xc: OCaml 5.0 compatibility

This accidentally broke compatibility with OCaml 4.02.3, 
only realized when I went back to my Dune based build system which can 
automatically compile with multiple compiler versions.

See below for a patch for that. I've included this patch in the correct place 
(before the patch that breaks it) in the git repository at: 
https://github.com/edwintorok/xen/compare/private/edvint/public0


From 78a613cbb8db7033fe741488912f21b24eaaef56 Mon Sep 17 00:00:00 2001
Message-Id: 
<78a613cbb8db7033fe741488912f21b24eaaef56.1664295046.git.edvin.torok@xxxxxxxxxx>
From: =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= <edvin.torok@xxxxxxxxxx>
Date: Tue, 27 Sep 2022 17:06:57 +0100
Subject: [PATCH] tools/ocaml: fix compatibility with OCaml 4.02.3
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Edwin Török <edvin.torok@xxxxxxxxxx>
---
 tools/ocaml/libs/mmap/mmap_stubs.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/ocaml/libs/mmap/mmap_stubs.h 
b/tools/ocaml/libs/mmap/mmap_stubs.h
index 65e4239890..5c65cc86fb 100644
--- a/tools/ocaml/libs/mmap/mmap_stubs.h
+++ b/tools/ocaml/libs/mmap/mmap_stubs.h
@@ -30,4 +30,9 @@ struct mmap_interface
        int len;
 };

+/* for compatibility with OCaml 4.02.3 */
+#ifndef Data_abstract_val
+#define Data_abstract_val(v) ((void*) Op_val(v))
+#endif
+
 #endif
--
2.34.1

> On 27 Sep 2022, at 12:15, Edwin Török <edvin.torok@xxxxxxxxxx> wrote:
> 
> Follow the manual to avoid naked pointers:
> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fv2.ocaml.org%2Fmanual%2Fintfc.html%23ss%3Ac-outside-head&amp;data=05%7C01%7Cedvin.torok%40citrix.com%7C4bf28f7a32074a49cdf008daa079a807%7C335836de42ef43a2b145348c2ee9ca5b%7C0%7C0%7C637998741634627105%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=GU%2BbmB1ai0llQg0z5zWctzwW0ocUQUOHVlMxkeD3U0U%3D&amp;reserved=0
> 
> No functional change, except on OCaml 5.0 where it is a bugfix.
> 
> Signed-off-by: Edwin Török <edvin.torok@xxxxxxxxxx>
> ---
> tools/ocaml/libs/xc/xenctrl_stubs.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c 
> b/tools/ocaml/libs/xc/xenctrl_stubs.c
> index 19335bdf45..7ff4e00314 100644
> --- a/tools/ocaml/libs/xc/xenctrl_stubs.c
> +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
> @@ -37,7 +37,7 @@
> 
> #include "mmap_stubs.h"
> 
> -#define _H(__h) ((xc_interface *)(__h))
> +#define _H(__h) *((xc_interface **) Data_abstract_val(__h))
> #define _D(__d) ((uint32_t)Int_val(__d))
> 
> #ifndef Val_none
> @@ -70,14 +70,15 @@ static void Noreturn failwith_xc(xc_interface *xch)
> CAMLprim value stub_xc_interface_open(void)
> {
>       CAMLparam0();
> -        xc_interface *xch;
> +     CAMLlocal1(result);
> 
> +     result = caml_alloc(1, Abstract_tag);
>       /* Don't assert XC_OPENFLAG_NON_REENTRANT because these bindings
>        * do not prevent re-entrancy to libxc */
> -        xch = xc_interface_open(NULL, NULL, 0);
> -        if (xch == NULL)
> +     _H(result) = xc_interface_open(NULL, NULL, 0);
> +     if (_H(result) == NULL)
>               failwith_xc(NULL);
> -        CAMLreturn((value)xch);
> +     CAMLreturn(result);
> }
> 
> 
> -- 
> 2.34.1
> 


 


Rackspace

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