From patchwork Thu Jul 14 15:58:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 9230061 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B610960572 for ; Thu, 14 Jul 2016 16:01:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A668227F94 for ; Thu, 14 Jul 2016 16:01:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A07028285; Thu, 14 Jul 2016 16:01:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6CFC427F94 for ; Thu, 14 Jul 2016 16:01:29 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNj2W-0000AH-1U; Thu, 14 Jul 2016 15:59:04 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNj2U-00009t-CS for xen-devel@lists.xen.org; Thu, 14 Jul 2016 15:59:02 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id E9/FD-32245-5C6B7875; Thu, 14 Jul 2016 15:59:01 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprAIsWRWlGSWpSXmKPExsXitHSDve7Rbe3 hBhsnClos+biYxYHR4+ju30wBjFGsmXlJ+RUJrBm9u+axF1zQrPje/Za9gfGQchcjJ4eEgL/E n+ZFbCA2m4C+xO4Xn5hAbBEBdYnTHRdZuxi5OJgFnjJJXH12hhkkISxgIPHoVyc7iM0ioCrxZ fobsDivgKfEhaedLBBD5STOH/8JFOfg4BTwkli7zQwkLARU8v/VVyYIW03iWv8ldohWQYmTM5 +AtTILSEgcfPECrFVCgFvib7f9BEa+WUiqZiGpWsDItIpRozi1qCy1SNfQUi+pKDM9oyQ3MTN H19DAWC83tbg4MT01JzGpWC85P3cTIzCk6hkYGHcw/j7ud4hRkoNJSZRXu78tXIgvKT+lMiOx OCO+qDQntfgQowwHh5IErx4wRIUEi1LTUyvSMnOAwQ2TluDgURLh/bIVKM1bXJCYW5yZDpE6x agoJc5rDtInAJLIKM2Da4NF1CVGWSlhXkYGBgYhnoLUotzMElT5V4ziHIxKwrz/QcbzZOaVwE 1/BbSYCWixtTnY4pJEhJRUAyOLqWJnX+J9s4X+aWy8upMfx8uGb6p5Pf2tlKToDNd2nhJ+m26 dS4WHt678VW4ZIuYdylFq6vFuAavo0zapiiVNJ9asYOP694E9WKyvPnJO3abnhw4cN+hi/Re8 feaXOSHL3ZmE71uqd7S+59sa1Wte8/2X0lfHPak5X9pPLAozNL0+RW2BuBJLcUaioRZzUXEiA AKN12yjAgAA X-Env-Sender: prvs=996c6fe0e=Andrew.Cooper3@citrix.com X-Msg-Ref: server-3.tower-31.messagelabs.com!1468511938!50617899!2 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19344 invoked from network); 14 Jul 2016 15:59:00 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-3.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 14 Jul 2016 15:59:00 -0000 X-IronPort-AV: E=Sophos;i="5.28,363,1464652800"; d="scan'208";a="373233572" From: Andrew Cooper To: Xen-devel Date: Thu, 14 Jul 2016 16:58:56 +0100 Message-ID: <1468511936-13351-2-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1468511936-13351-1-git-send-email-andrew.cooper3@citrix.com> References: <1468511936-13351-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 2/2] xen/build: Use C99 booleans X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP and switch bool_t to being of type _Bool rather than char. Using bool_t as char causes several subtle problems; first that a bool_t actually has more than two values, and that (bool_t)0x100 actually has the value 0 rather than the expected 1, due to truncation. Making this change reveals two bugs now caught by the compiler. errata_c6_eoi_workaround() actually makes use of bool_t having more than two states, while generic_apic_probe() has a integer in the middle of a compound bool_t assignment (which triggers a [-Werror=parentheses] warning on Debian Jessie). Finally, it turns out that ARM is mixing and matching bool_t and bool, despite their different semantics. This change brings the semantics of bool_t to match bool, but does not alter the current mix. Signed-off-by: Andrew Cooper Acked-by: Julien Grall Acked-by: Tim Deegan --- CC: Stefano Stabellini CC: Julien Grall CC: George Dunlap CC: Ian Jackson CC: Jan Beulich CC: Konrad Rzeszutek Wilk CC: Tim Deegan CC: Wei Liu v2: * Leave the matter of std libaries to one side for now. Fixing bool_t is far more important, and can be done without making the std include issue any worse. * Type tweaks, per v1 review. --- xen/arch/arm/p2m.c | 1 - xen/arch/arm/platforms/xgene-storm.c | 1 - xen/arch/arm/traps.c | 1 - xen/arch/x86/acpi/cpu_idle.c | 2 +- xen/arch/x86/genapic/probe.c | 3 ++- xen/include/asm-arm/types.h | 4 ---- xen/include/asm-x86/types.h | 4 ---- xen/include/xen/device_tree.h | 1 - xen/include/xen/types.h | 6 ++++++ 9 files changed, 9 insertions(+), 14 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 976f97b..a4bc55a 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1,7 +1,6 @@ #include #include #include -#include #include #include #include diff --git a/xen/arch/arm/platforms/xgene-storm.c b/xen/arch/arm/platforms/xgene-storm.c index 70cb655..686b19b 100644 --- a/xen/arch/arm/platforms/xgene-storm.c +++ b/xen/arch/arm/platforms/xgene-storm.c @@ -20,7 +20,6 @@ #include #include -#include #include #include #include diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 3326122..a2eb1da 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -17,7 +17,6 @@ */ #include -#include #include #include #include diff --git a/xen/arch/x86/acpi/cpu_idle.c b/xen/arch/x86/acpi/cpu_idle.c index a21aeed..7e235a3 100644 --- a/xen/arch/x86/acpi/cpu_idle.c +++ b/xen/arch/x86/acpi/cpu_idle.c @@ -480,7 +480,7 @@ void trace_exit_reason(u32 *irq_traced) */ bool_t errata_c6_eoi_workaround(void) { - static bool_t fix_needed = -1; + static int8_t fix_needed = -1; if ( unlikely(fix_needed == -1) ) { diff --git a/xen/arch/x86/genapic/probe.c b/xen/arch/x86/genapic/probe.c index a5f2a24..860201e 100644 --- a/xen/arch/x86/genapic/probe.c +++ b/xen/arch/x86/genapic/probe.c @@ -56,7 +56,8 @@ custom_param("apic", genapic_apic_force); void __init generic_apic_probe(void) { - int i, changed; + bool changed; + int i; record_boot_APIC_mode(); diff --git a/xen/include/asm-arm/types.h b/xen/include/asm-arm/types.h index 09e5455..71d2e42 100644 --- a/xen/include/asm-arm/types.h +++ b/xen/include/asm-arm/types.h @@ -62,10 +62,6 @@ typedef unsigned long size_t; #endif typedef signed long ssize_t; -typedef char bool_t; -#define test_and_set_bool(b) xchg(&(b), 1) -#define test_and_clear_bool(b) xchg(&(b), 0) - #endif /* __ASSEMBLY__ */ #endif /* __ARM_TYPES_H__ */ diff --git a/xen/include/asm-x86/types.h b/xen/include/asm-x86/types.h index b82fa58..e75b744 100644 --- a/xen/include/asm-x86/types.h +++ b/xen/include/asm-x86/types.h @@ -41,10 +41,6 @@ typedef unsigned long size_t; #endif typedef signed long ssize_t; -typedef char bool_t; -#define test_and_set_bool(b) xchg(&(b), 1) -#define test_and_clear_bool(b) xchg(&(b), 0) - #endif /* __ASSEMBLY__ */ #endif /* __X86_TYPES_H__ */ diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index d7d1b40..3657ac2 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -17,7 +17,6 @@ #include #include #include -#include #include #define DEVICE_TREE_MAX_DEPTH 16 diff --git a/xen/include/xen/types.h b/xen/include/xen/types.h index 8596ded..78410de 100644 --- a/xen/include/xen/types.h +++ b/xen/include/xen/types.h @@ -1,6 +1,8 @@ #ifndef __TYPES_H__ #define __TYPES_H__ +#include + #include #define BITS_TO_LONGS(bits) \ @@ -59,4 +61,8 @@ typedef __u64 __be64; typedef unsigned long uintptr_t; +typedef _Bool bool_t; +#define test_and_set_bool(b) xchg(&(b), true) +#define test_and_clear_bool(b) xchg(&(b), false) + #endif /* __TYPES_H__ */