From patchwork Tue Aug 20 09:50:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 19350 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f70.google.com (mail-vb0-f70.google.com [209.85.212.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B43BA25E11 for ; Tue, 20 Aug 2013 09:50:48 +0000 (UTC) Received: by mail-vb0-f70.google.com with SMTP id h10sf186697vbh.5 for ; Tue, 20 Aug 2013 02:50:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:delivered-to:mime-version:in-reply-to:references :date:message-id:subject:from:to:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=5dSFigOJBGmfG6p9G2hgUx7NBTLUtHCK7/cMOAmisvQ=; b=VvHw3+d7A+z1u3sLUHPvUm0gKc2RevANCUTstT6APNSuLrZ6nnJxpLpwA32oW4rHsd dqX0QDgtRj1NqhpW/lswDtfI/1SzmwqHBe76a3Pp098AC51U6OO/YTYYtbK1ZnU2kRev 5WfHoGVp0qewPV2wtN5EAGidnoUrH3sC4RM/2/cUCi3v02a14vkIf7pK9Og8WH8P2KuT rCwMk/iMv4x073fOq34V9adz9JJDKLwuzzSkfepnTLsUgcA3SCXy6pvBUHcdN17CR6ea j+BktfqPmbbnBQ5B5fE+zqcS4mRWqXzRxnCMqyb5F7cbZ1C6J6qGAvXcz0ND9aVMzePR SFWQ== X-Received: by 10.236.223.130 with SMTP id v2mr271812yhp.34.1376992248103; Tue, 20 Aug 2013 02:50:48 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.82.74 with SMTP id g10ls187176qey.60.gmail; Tue, 20 Aug 2013 02:50:48 -0700 (PDT) X-Received: by 10.58.201.227 with SMTP id kd3mr433176vec.14.1376992247967; Tue, 20 Aug 2013 02:50:47 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id f2si149891vcz.101.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 Aug 2013 02:50:47 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id gf12so109672vcb.22 for ; Tue, 20 Aug 2013 02:50:47 -0700 (PDT) X-Gm-Message-State: ALoCoQkMt7mDgJQKnCotTe/Ehbwgtc7DPK6QYkBW9twykNp+XAp0ikqIzEIqSzzSFkV7HJGw7i2T X-Received: by 10.52.249.102 with SMTP id yt6mr354459vdc.21.1376992247842; Tue, 20 Aug 2013 02:50:47 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp146761vcz; Tue, 20 Aug 2013 02:50:47 -0700 (PDT) X-Received: by 10.112.126.37 with SMTP id mv5mr2013314lbb.20.1376992246723; Tue, 20 Aug 2013 02:50:46 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com [209.85.215.54]) by mx.google.com with ESMTPS id 6si376580lay.148.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 Aug 2013 02:50:46 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.54 is neither permitted nor denied by best guess record for domain of ard.biesheuvel@linaro.org) client-ip=209.85.215.54; Received: by mail-la0-f54.google.com with SMTP id ea20so140846lab.27 for ; Tue, 20 Aug 2013 02:50:45 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.112.168.170 with SMTP id zx10mr2027131lbb.0.1376992245557; Tue, 20 Aug 2013 02:50:45 -0700 (PDT) Received: by 10.112.22.200 with HTTP; Tue, 20 Aug 2013 02:50:45 -0700 (PDT) In-Reply-To: <1376896358-21076-1-git-send-email-ard.biesheuvel@linaro.org> References: <1376896358-21076-1-git-send-email-ard.biesheuvel@linaro.org> Date: Tue, 20 Aug 2013 11:50:45 +0200 Message-ID: Subject: Fwd: [PATCH resend] ARM: add workaround for ambiguous C99 stdint.h types From: Ard Biesheuvel To: Patch Tracking X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , ---------- Forwarded message ---------- From: Ard Biesheuvel Date: 19 August 2013 09:12 Subject: [PATCH resend] ARM: add workaround for ambiguous C99 stdint.h types To: linux@arm.linux.org.uk Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel 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 + +#endif /* _ASM_TYPES_H */ -- 1.8.1.2 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