From patchwork Tue Jun 27 07:56:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13294142 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CCBA7C0015E for ; Tue, 27 Jun 2023 07:56:54 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.555901.868098 (Exim 4.92) (envelope-from ) id 1qE3Z2-0000IM-1i; Tue, 27 Jun 2023 07:56:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 555901.868098; Tue, 27 Jun 2023 07:56:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qE3Z1-0000I6-Ue; Tue, 27 Jun 2023 07:56:39 +0000 Received: by outflank-mailman (input) for mailman id 555901; Tue, 27 Jun 2023 07:56:38 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qE3Z0-0008EH-Bw for xen-devel@lists.xenproject.org; Tue, 27 Jun 2023 07:56:38 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2351cd2f-14c0-11ee-8611-37d641c3527e; Tue, 27 Jun 2023 09:56:35 +0200 (CEST) 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: 2351cd2f-14c0-11ee-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1687852596; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WF6+MO8uRCqSL2DrFswTeiveqvFOb1H6UCIU4GeCi+k=; b=ID0vt8raTQrK7znBArIqamxjI2dz+ivQuK1r4OxRFDCNJNf81eoruraf fjO4sqaJTzYOP+5dVG0Q36lt1s4v+KCYznoA4OI2lwsyYvPjnBqocyl+U mudhIXa9cyjIpV6kawKkm6G7yZZ5c8jCYlBDyR/q60gD4KBpjvp9ez1Cb 4=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 113007169 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:dl2UWqAVKAkIVRVW/w7kw5YqxClBgxIJ4kV8jS/XYbTApDgn02QBz 2AXUT3UP/eLZGX2Kd13aIu/9U1XvpXQn4M1QQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48T8nk/nOHuGmYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbCRMsspvlDs15K6p4G1C4QRnDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIwyLwtB2gXr /0idhc1Zwusnfnn+7zmY7w57igjBJGD0II3v3hhyXfSDOo8QICFSKLPjTNa9G5u3IYUR6+YP pdHL2M1N3wsYDUWUrsTILs4kP2lmT/UdDpApUjOjaE2/3LS3Ep6172F3N/9I4XR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l6QFhLX5VI3KNGOKhILCFu9fBOXZslrdMhy72ulB1b pxN4hSYeeAa2SS9fyKgjVQyuxQpOW6zA== X-Talos-CUID: 9a23:DWPtTm+/WLEwxpVg8uKVv3xOQMYsKyfc9in3G0ajJnxyGYabFHbFrQ== X-Talos-MUID: 9a23:/EgCkwvHh68B5MyQoM2nnR4/NPly/4uVCBorytIj/MCtPhZ2JGLI X-IronPort-AV: E=Sophos;i="6.01,161,1684814400"; d="scan'208";a="113007169" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Bob Eshleman , Alistair Francis , Connor Davis , "Oleksii Kurochko" , Shawn Anastasio , Timothy Pearson , Roberto Bagnara Subject: [PATCH v2 3/3] xen/types: Rework stdint vs __{u,s}$N types Date: Tue, 27 Jun 2023 08:56:18 +0100 Message-ID: <20230627075618.1180248-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230627075618.1180248-1-andrew.cooper3@citrix.com> References: <20230627075618.1180248-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Xen uses the stdint types. Rearrange the types headers to define the compatibility __{u,s}$N types in terms of the stdint types, not the other way around. All all supported compilers on architectures other than x86 support the stdint __*_TYPE__ macros. Move these into a new xen/stdint.h to avoid them being duplicated in each architecture. For the compilers which don't support the __*_TYPE__ macros, synthesize appropriate alternatives. This cleanup has the side effect of removing all use of the undocumented __signed__ GCC keyword. This is a vestigial remnant of `gcc -traditional` mode for dialetcs of C prior to the introduction of the signed keyword. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Oleksii Kurochko --- CC: Jan Beulich CC: Roger Pau Monné CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis CC: Bob Eshleman CC: Alistair Francis CC: Connor Davis CC: Oleksii Kurochko CC: Shawn Anastasio CC: Timothy Pearson CC: Roberto Bagnara v2: * Introduce xen/stdint.h as discussed at XenSummit --- xen/arch/arm/include/asm/types.h | 19 ----------------- xen/arch/riscv/include/asm/types.h | 19 ----------------- xen/arch/x86/include/asm/types.h | 14 ------------- xen/include/xen/stdint.h | 33 ++++++++++++++++++++++++++++++ xen/include/xen/types.h | 20 ++++++++---------- 5 files changed, 42 insertions(+), 63 deletions(-) create mode 100644 xen/include/xen/stdint.h diff --git a/xen/arch/arm/include/asm/types.h b/xen/arch/arm/include/asm/types.h index fb6618ef247f..545a5e9d1175 100644 --- a/xen/arch/arm/include/asm/types.h +++ b/xen/arch/arm/include/asm/types.h @@ -1,25 +1,6 @@ #ifndef __ARM_TYPES_H__ #define __ARM_TYPES_H__ -typedef __signed__ char __s8; -typedef unsigned char __u8; - -typedef __signed__ short __s16; -typedef unsigned short __u16; - -typedef __signed__ int __s32; -typedef unsigned int __u32; - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -#if defined(CONFIG_ARM_32) -typedef __signed__ long long __s64; -typedef unsigned long long __u64; -#elif defined (CONFIG_ARM_64) -typedef __signed__ long __s64; -typedef unsigned long __u64; -#endif -#endif - typedef signed char s8; typedef unsigned char u8; diff --git a/xen/arch/riscv/include/asm/types.h b/xen/arch/riscv/include/asm/types.h index 0c0ce78c8f6e..93a680a8f323 100644 --- a/xen/arch/riscv/include/asm/types.h +++ b/xen/arch/riscv/include/asm/types.h @@ -1,25 +1,6 @@ #ifndef __RISCV_TYPES_H__ #define __RISCV_TYPES_H__ -typedef __signed__ char __s8; -typedef unsigned char __u8; - -typedef __signed__ short __s16; -typedef unsigned short __u16; - -typedef __signed__ int __s32; -typedef unsigned int __u32; - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -#if defined(CONFIG_RISCV_32) -typedef __signed__ long long __s64; -typedef unsigned long long __u64; -#elif defined (CONFIG_RISCV_64) -typedef __signed__ long __s64; -typedef unsigned long __u64; -#endif -#endif - typedef signed char s8; typedef unsigned char u8; diff --git a/xen/arch/x86/include/asm/types.h b/xen/arch/x86/include/asm/types.h index 2d56aed66782..c9d257716551 100644 --- a/xen/arch/x86/include/asm/types.h +++ b/xen/arch/x86/include/asm/types.h @@ -1,20 +1,6 @@ #ifndef __X86_TYPES_H__ #define __X86_TYPES_H__ -typedef __signed__ char __s8; -typedef unsigned char __u8; - -typedef __signed__ short __s16; -typedef unsigned short __u16; - -typedef __signed__ int __s32; -typedef unsigned int __u32; - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -typedef __signed__ long __s64; -typedef unsigned long __u64; -#endif - typedef signed char s8; typedef unsigned char u8; diff --git a/xen/include/xen/stdint.h b/xen/include/xen/stdint.h new file mode 100644 index 000000000000..4cf82790f196 --- /dev/null +++ b/xen/include/xen/stdint.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __XEN_STDINT_H__ +#define __XEN_STDINT_H__ + +#ifndef __INT8_TYPE__ /* GCC <= 4.4 */ + +typedef __INT8_TYPE__ int8_t; +typedef __UINT8_TYPE__ uint8_t; +typedef __INT16_TYPE__ int16_t; +typedef __UINT16_TYPE__ uint16_t; +typedef __INT32_TYPE__ int32_t; +typedef __UINT32_TYPE__ uint32_t; +typedef __INT64_TYPE__ int64_t; +typedef __UINT64_TYPE__ uint64_t; + +#else + +/* + * Define the types using GCC internal notation. Clang understands this too. + * https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html + */ +typedef signed __attribute__((__mode__(QI))) int8_t; +typedef unsigned __attribute__((__mode__(QI))) uint8_t; +typedef signed __attribute__((__mode__(HI))) int16_t; +typedef unsigned __attribute__((__mode__(HI))) uint16_t; +typedef signed __attribute__((__mode__(SI))) int32_t; +typedef unsigned __attribute__((__mode__(SI))) uint32_t; +typedef signed __attribute__((__mode__(DI))) int64_t; +typedef unsigned __attribute__((__mode__(DI))) uint64_t; + +#endif + +#endif /* __XEN_STDINT_H__ */ diff --git a/xen/include/xen/types.h b/xen/include/xen/types.h index 8b22a02eeaa4..c873c81ccf06 100644 --- a/xen/include/xen/types.h +++ b/xen/include/xen/types.h @@ -2,6 +2,7 @@ #define __TYPES_H__ #include +#include #include @@ -39,17 +40,14 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; #define LONG_MIN (-LONG_MAX - 1) #define ULONG_MAX (~0UL) -typedef __u8 uint8_t; -typedef __s8 int8_t; - -typedef __u16 uint16_t; -typedef __s16 int16_t; - -typedef __u32 uint32_t; -typedef __s32 int32_t; - -typedef __u64 uint64_t; -typedef __s64 int64_t; +typedef uint8_t __u8; +typedef int8_t __s8; +typedef uint16_t __u16; +typedef int16_t __s16; +typedef uint32_t __u32; +typedef int32_t __s32; +typedef uint64_t __u64; +typedef int64_t __s64; typedef __u16 __le16; typedef __u16 __be16;