From patchwork Fri Aug 9 07:36:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 2841700 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 5BC9C9F294 for ; Fri, 9 Aug 2013 07:37:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 31024202C8 for ; Fri, 9 Aug 2013 07:37:20 +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 DFDC3202C7 for ; Fri, 9 Aug 2013 07:37:18 +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 1V7hG7-0006iS-G2; Fri, 09 Aug 2013 07:37:15 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7hG5-0004tS-9u; Fri, 09 Aug 2013 07:37:13 +0000 Received: from mail-we0-f175.google.com ([74.125.82.175]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7hG2-0004t5-Uy for linux-arm-kernel@lists.infradead.org; Fri, 09 Aug 2013 07:37:11 +0000 Received: by mail-we0-f175.google.com with SMTP id q58so3200368wes.6 for ; Fri, 09 Aug 2013 00:36: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:from:to:cc:subject:date:message-id; bh=1bQ9W2TSkRJRD+EcQKg+o/HJ3/J8EjnaRPP8e7E3F3s=; b=i+OrHa2D1spxZQia3lj/sqH/vJBUGLyI3wWiqJFgK59q+nOhz2pYYfKfpL+7w9E5+U MZnXI4IZbL5Ma0k7Y2hDlqKxCH9ZAH/C4B0N9MbtGuOW5BOjMBFcU/gUSdsijN746pyj NGxrjpBss8/whmqJlaCD2iQl7jG9SozPxquxnE7ZoJePG64N0yK8TzujF6hKVRPcglnO f4BM3xZO/eQltYiNVoDc9Ynb/g9HHQWZMgQM5+EF+KWzglug1cEDmZctRFk8C8D2qudb JJPUcJ3LXL4NepWTRljL4Lgj84OZ/LDPteMpnk57VUfOkoJsyym+OKO6H2sFHkj7vmcj iS7w== X-Gm-Message-State: ALoCoQlPG3EngzsqLbEci+I4Tnt8M3VtuvLm0yowXwpvNgELzgQMjexy2o2f6jlnHKOgfHi/hpU5 X-Received: by 10.180.189.37 with SMTP id gf5mr1430648wic.9.1376033808831; Fri, 09 Aug 2013 00:36:48 -0700 (PDT) Received: from ards-mac-mini.homenet.telecomitalia.it ([95.235.231.18]) by mx.google.com with ESMTPSA id n2sm1118418wiz.4.2013.08.09.00.36.47 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 09 Aug 2013 00:36:48 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH] ARM: add workaround for ambiguous C99 stdint.h types Date: Fri, 9 Aug 2013 09:36:42 +0200 Message-Id: <1376033802-12826-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-20130809_033711_101541_066F9153 X-CRM114-Status: GOOD ( 11.83 ) X-Spam-Score: -2.6 (--) Cc: linux@arm.linux.org.uk, Dave.Martin@arm.com, 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=-4.2 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 long glibc GCC int unsigned int unsigned int kernel int unsigned int unsigned long Signed-off-by: Ard Biesheuvel Acked-by: Nicolas Pitre --- Hi all, This is another, less obtrusive way of handling the problem for which I previously sent an RFC patch 'types.h: use GCC supplied typedefs if appropriate' In this case, only source files that in fact include stdint.h and are being built for ARM should be affected. Regards, diff --git a/arch/arm/include/asm/types.h b/arch/arm/include/asm/types.h new file mode 100644 index 0000000..976ac31 --- /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 long + * 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 */