From patchwork Mon Aug 19 07:12:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 2846367 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1F0519F271 for ; Mon, 19 Aug 2013 07:13:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F0AA320292 for ; Mon, 19 Aug 2013 07:13:57 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C74162028D for ; Mon, 19 Aug 2013 07:13:56 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VBJer-0001JI-38; Mon, 19 Aug 2013 07:13:45 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VBJeo-0005lD-Up; Mon, 19 Aug 2013 07:13:42 +0000 Received: from mail-we0-f171.google.com ([74.125.82.171]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VBJel-0005jc-MM for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2013 07:13:40 +0000 Received: by mail-we0-f171.google.com with SMTP id q55so3426052wes.16 for ; Mon, 19 Aug 2013 00:13:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=YMOEga53TUy9++MnkBlyY1JoKnxzcp2pRDqGNZYAsvI=; b=ZX+xrd5nWjUeXHwFitWTBL5pB7M+oitj9ucTtCGt4dY2W245La5RcmeUt35H7PDcPx NQi2kAlAuHn5cSAygJ/uYa6fBC6h5mOiuRBazuEbBEzZRD1c3ikvUHuQb6ST1FhG3uVw xdQFVZsUigFb0cXwrgwSce9u3OwSkcw5oUU8IcHDZcThUArJLbFYJfQY0TU7rnEEjRpB Dhyn8vJWLuJtSk5aA0X8WjrmEFwXeTCy8X/Nmc0HqnJDaG0UNYn6lmfJkV10OuxsuzrK S1bc/R1AuuC3gKV8j2YLj9Wm1ZBNZrQegiPjmAvhzdNaYJw+Lfej4zJWCZG5dXa5yQmN h3ng== X-Gm-Message-State: ALoCoQmXtQDoP44bSprToOy4l+Vz1pnoZWq8u1NdOGLRu7KXxqe9UH0unDSDDc8CSrN6CRLdxfGE X-Received: by 10.194.63.228 with SMTP id j4mr1254543wjs.34.1376896397073; Mon, 19 Aug 2013 00:13:17 -0700 (PDT) Received: from ards-mac-mini.homenet.telecomitalia.it (host107-28-dynamic.12-79-r.retail.telecomitalia.it. [79.12.28.107]) by mx.google.com with ESMTPSA id dt17sm14420877wic.1.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 Aug 2013 00:13:16 -0700 (PDT) From: Ard Biesheuvel To: linux@arm.linux.org.uk Subject: [PATCH resend] ARM: add workaround for ambiguous C99 stdint.h types Date: Mon, 19 Aug 2013 09:12:38 +0200 Message-Id: <1376896358-21076-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.1.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130819_031339_827316_03876F3A X-CRM114-Status: GOOD ( 10.66 ) X-Spam-Score: -2.6 (--) Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The C99 types uintXX_t that are usually defined in 'stdint.h' are not as unambiguous on ARM as you would expect. For the types below, there is a difference on ARM between GCC built for bare metal ARM, GCC built for glibc and the kernel itself, which results in build errors if you try to build with -ffreestanding and include 'stdint.h' (such as when you include 'arm_neon.h' in order to use NEON intrinsics) As the typedefs for these types in 'stdint.h' are based on builtin defines supplied by GCC, we can tweak these to align with the kernel's idea of those types, so 'linux/types.h' and 'stdint.h' can be safely included from the same source file (provided that -ffreestanding is used). int32_t uint32_t uintptr_t bare metal GCC long unsigned long unsigned int glibc GCC int unsigned int unsigned int kernel int unsigned int unsigned long Acked-by: Nicolas Pitre Acked by: Dave Martin Acked-by: Mikael Pettersson Signed-off-by: Ard Biesheuvel --- arch/arm/include/asm/types.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 arch/arm/include/asm/types.h diff --git a/arch/arm/include/asm/types.h b/arch/arm/include/asm/types.h new file mode 100644 index 0000000..c4f0bca --- /dev/null +++ b/arch/arm/include/asm/types.h @@ -0,0 +1,40 @@ +#ifndef _ASM_TYPES_H +#define _ASM_TYPES_H + +#include + +/* + * The C99 types uintXX_t that are usually defined in 'stdint.h' are not as + * unambiguous on ARM as you would expect. For the types below, there is a + * difference on ARM between GCC built for bare metal ARM, GCC built for glibc + * and the kernel itself, which results in build errors if you try to build with + * -ffreestanding and include 'stdint.h' (such as when you include 'arm_neon.h' + * in order to use NEON intrinsics) + * + * As the typedefs for these types in 'stdint.h' are based on builtin defines + * supplied by GCC, we can tweak these to align with the kernel's idea of those + * types, so 'linux/types.h' and 'stdint.h' can be safely included from the same + * source file (provided that -ffreestanding is used). + * + * int32_t uint32_t uintptr_t + * bare metal GCC long unsigned long unsigned int + * glibc GCC int unsigned int unsigned int + * kernel int unsigned int unsigned long + */ + +#ifdef __INT32_TYPE__ +#undef __INT32_TYPE__ +#define __INT32_TYPE__ int +#endif + +#ifdef __UINT32_TYPE__ +#undef __UINT32_TYPE__ +#define __UINT32_TYPE__ unsigned int +#endif + +#ifdef __UINTPTR_TYPE__ +#undef __UINTPTR_TYPE__ +#define __UINTPTR_TYPE__ unsigned long +#endif + +#endif /* _ASM_TYPES_H */