From nobody Mon Feb 9 17:24:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1623155777; cv=none; d=zohomail.com; s=zohoarc; b=USBZyU9Y3I2UaxgQ6sM4Okwz2O6sUBKMqb9VO9419HkHGS7HcX7UHsfIl97Bhn5bxZGjLjRJe2X8mtv4XrVITg5BldvN0t4lsjAugxmuqOrkTJVmSYLW1btTAMNiljA2kZmPgoj+bpDXknseJ03NoCJAUAJpr9gtv0g5BsQZ7+w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623155777; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=d+aT00SixwfN6y3TbETKjs2Mm4cbtsEqdyAtNOgVz9Q=; b=SCZjBDeyHLQA0uSJ7Y3z3cA88lQGFXtJ3rZJu7ZzGpobnLl9fG2W44YChVS0SMrCsMlXFIOud8PlFmaHF2nRJnxZX9Q76KSyR6IfDUaSF/jXP5yJK0+WNNm5SnJZTeCJurNprZLsjbMULElHrsvYB2rlk++RjMbCKHaza1/ln/Y= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1623155777193612.1314469797973; Tue, 8 Jun 2021 05:36:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.138462.256343 (Exim 4.92) (envelope-from ) id 1lqaxh-00010L-4R; Tue, 08 Jun 2021 12:36:05 +0000 Received: by outflank-mailman (output) from mailman id 138462.256343; Tue, 08 Jun 2021 12:36:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lqaxh-00010A-0N; Tue, 08 Jun 2021 12:36:05 +0000 Received: by outflank-mailman (input) for mailman id 138462; Tue, 08 Jun 2021 12:36:03 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lqaxf-0007Ok-8w for xen-devel@lists.xenproject.org; Tue, 08 Jun 2021 12:36:03 +0000 Received: from mx.upb.ro (unknown [141.85.13.201]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id ec443ab5-320a-4712-918f-847d522ef42d; Tue, 08 Jun 2021 12:35:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 144CDB56019A; Tue, 8 Jun 2021 15:35:43 +0300 (EEST) Received: from mx.upb.ro ([127.0.0.1]) by localhost (mx.upb.ro [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id C8chw8VKlSZH; Tue, 8 Jun 2021 15:35:40 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 56AC1B560192; Tue, 8 Jun 2021 15:35:40 +0300 (EEST) Received: from mx.upb.ro ([127.0.0.1]) by localhost (mx.upb.ro [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id hIA9l4veBTRc; Tue, 8 Jun 2021 15:35:40 +0300 (EEST) Received: from localhost.localdomain (unknown [188.25.174.245]) by mx.upb.ro (Postfix) with ESMTPSA id 819B0B56019B; Tue, 8 Jun 2021 15:35:39 +0300 (EEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ec443ab5-320a-4712-918f-847d522ef42d X-Virus-Scanned: amavisd-new at upb.ro From: Costin Lupu To: xen-devel@lists.xenproject.org Cc: Christian Lindig , David Scott , Ian Jackson , Wei Liu , Julien Grall , Dario Faggioli Subject: [PATCH v4 5/5] tools/ocaml: Fix redefinition errors Date: Tue, 8 Jun 2021 15:35:29 +0300 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If PAGE_SIZE is already defined in the system (e.g. in /usr/include/limits.h header) then gcc will trigger a redefinition error because of -Werror. This patch replaces usage of PAGE_* macros with XC_PAGE_* macros in order to avo= id confusion between control domain page granularity (PAGE_* definitions) and guest domain page granularity (which is what we are dealing with here). Same issue applies for redefinitions of Val_none and Some_val macros which can be already define in the OCaml system headers (e.g. /usr/lib/ocaml/caml/mlvalues.h). Signed-off-by: Costin Lupu Reviewed-by: Julien Grall Tested-by: Dario Faggioli --- tools/ocaml/libs/xc/xenctrl_stubs.c | 10 ++++------ tools/ocaml/libs/xentoollog/xentoollog_stubs.c | 4 ++++ tools/ocaml/libs/xl/xenlight_stubs.c | 4 ++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenc= trl_stubs.c index d05d7bb30e..f9e33e599a 100644 --- a/tools/ocaml/libs/xc/xenctrl_stubs.c +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c @@ -36,14 +36,12 @@ =20 #include "mmap_stubs.h" =20 -#define PAGE_SHIFT 12 -#define PAGE_SIZE (1UL << PAGE_SHIFT) -#define PAGE_MASK (~(PAGE_SIZE-1)) - #define _H(__h) ((xc_interface *)(__h)) #define _D(__d) ((uint32_t)Int_val(__d)) =20 +#ifndef Val_none #define Val_none (Val_int(0)) +#endif =20 #define string_of_option_array(array, index) \ ((Field(array, index) =3D=3D Val_none) ? NULL : String_val(Field(Field(ar= ray, index), 0))) @@ -818,7 +816,7 @@ CAMLprim value stub_xc_domain_memory_increase_reservati= on(value xch, CAMLparam3(xch, domid, mem_kb); int retval; =20 - unsigned long nr_extents =3D ((unsigned long)(Int64_val(mem_kb))) >> (PAG= E_SHIFT - 10); + unsigned long nr_extents =3D ((unsigned long)(Int64_val(mem_kb))) >> (XC_= PAGE_SHIFT - 10); =20 uint32_t c_domid =3D _D(domid); caml_enter_blocking_section(); @@ -924,7 +922,7 @@ CAMLprim value stub_pages_to_kib(value pages) { CAMLparam1(pages); =20 - CAMLreturn(caml_copy_int64(Int64_val(pages) << (PAGE_SHIFT - 10))); + CAMLreturn(caml_copy_int64(Int64_val(pages) << (XC_PAGE_SHIFT - 10))); } =20 =20 diff --git a/tools/ocaml/libs/xentoollog/xentoollog_stubs.c b/tools/ocaml/l= ibs/xentoollog/xentoollog_stubs.c index bf64b211c2..e4306a0c2f 100644 --- a/tools/ocaml/libs/xentoollog/xentoollog_stubs.c +++ b/tools/ocaml/libs/xentoollog/xentoollog_stubs.c @@ -53,8 +53,12 @@ static char * dup_String_val(value s) #include "_xtl_levels.inc" =20 /* Option type support as per http://www.linux-nantes.org/~fmonnier/ocaml/= ocaml-wrapping-c.php */ +#ifndef Val_none #define Val_none Val_int(0) +#endif +#ifndef Some_val #define Some_val(v) Field(v,0) +#endif =20 static value Val_some(value v) { diff --git a/tools/ocaml/libs/xl/xenlight_stubs.c b/tools/ocaml/libs/xl/xen= light_stubs.c index 352a00134d..45b8af61c7 100644 --- a/tools/ocaml/libs/xl/xenlight_stubs.c +++ b/tools/ocaml/libs/xl/xenlight_stubs.c @@ -227,8 +227,12 @@ static value Val_string_list(libxl_string_list *c_val) } =20 /* Option type support as per http://www.linux-nantes.org/~fmonnier/ocaml/= ocaml-wrapping-c.php */ +#ifndef Val_none #define Val_none Val_int(0) +#endif +#ifndef Some_val #define Some_val(v) Field(v,0) +#endif =20 static value Val_some(value v) { --=20 2.20.1