From patchwork Wed Jan 11 16:28:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 9510641 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 31B29601E7 for ; Wed, 11 Jan 2017 16:43:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B8B4283F7 for ; Wed, 11 Jan 2017 16:43:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 006B82858F; Wed, 11 Jan 2017 16:43:46 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 03C9F28584 for ; Wed, 11 Jan 2017 16:43:35 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cRLzq-0003Td-O8; Wed, 11 Jan 2017 16:43:34 +0000 Received: from mail-wj0-x233.google.com ([2a00:1450:400c:c01::233]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cRLlx-0008Sq-1Z for linux-arm-kernel@lists.infradead.org; Wed, 11 Jan 2017 16:29:14 +0000 Received: by mail-wj0-x233.google.com with SMTP id i20so106232467wjn.2 for ; Wed, 11 Jan 2017 08:28:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tQyXzVbqwEwRJtpPaDwDJTwOoudsJQeu41IJaI9OIeI=; b=WZWdrYvQOY0ORdkTZ3ycZIVO2DLoEfUDJ1iU9Q6oQch9AySwSEcRFy+CQ1mf1IutLH R7MhzOJpi0FogdgN0LnYzL5zPIObPPhR/3ENXYGxu/3lH1uv2JW7E9G/yGbGdnry/tOY 8k78Lw/jJNpuPrmjjIVpOgZycutGQZ0AhyRG0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tQyXzVbqwEwRJtpPaDwDJTwOoudsJQeu41IJaI9OIeI=; b=DPQ+VNqksnSDPmoReWv4Pckzcc4vSYmE9rXYbKCxeIRpWsctmQ4v9PBF/YqftAtoiD MvDceWbvysMQyUOo4w05gOsw/4QZV5eWhnZNWcn3iz/bVCIEU6LcUZEVHmwRhfR3ptLS sqjLnufrHkM9bC1B5mfvFPfcOhVR4ZsfAvJFukTR/Xn45lM8AxSlXZC1zYqlG7VdU3q+ TA3dfuRdOIF03WWXxpfTvcCXorYeUodHB9dXRqS9k9pQeFWSz5tbeiJyfr0DteD790Bz lXiQyycR7PL5kgS4g7+dk0i/AlNjvOuq1SIExlGud2VJcKpktgryzrlpHy28C/8SmFG8 iOAQ== X-Gm-Message-State: AIkVDXKHGKkOHEORd6+7K5F5RO785LR0vrPrbsQ4H4uD4yOUgRP74hvuAdC19RkjYSxoQLxR X-Received: by 10.194.93.37 with SMTP id cr5mr5735609wjb.95.1484152131135; Wed, 11 Jan 2017 08:28:51 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id lr10sm9229469wjb.6.2017.01.11.08.28.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jan 2017 08:28:49 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id B1FA03E0664; Wed, 11 Jan 2017 16:28:48 +0000 (GMT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: drjones@redhat.com, pbonzini@redhat.com Subject: [kvm-unit-tests PATCH 1/6] libcflat: add PRI(dux)32 format types Date: Wed, 11 Jan 2017 16:28:36 +0000 Message-Id: <20170111162841.15569-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170111162841.15569-1-alex.bennee@linaro.org> References: <20170111162841.15569-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170111_082913_241257_AC1D6A3C X-CRM114-Status: GOOD ( 10.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, marc.zyngier@arm.com, linux-arm-kernel@lists.infradead.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP So we can have portable formatting of uint32_t types. However there is a catch. Different compilers can use legally subtly different types though so we need to probe the compiler defined intdef.h first. Signed-off-by: Alex Bennée --- Makefile | 1 + configure | 13 +++++++++++++ lib/libcflat.h | 9 +++++++++ 3 files changed, 23 insertions(+) diff --git a/Makefile b/Makefile index a32333b..9822d9a 100644 --- a/Makefile +++ b/Makefile @@ -55,6 +55,7 @@ CFLAGS += $(fomit_frame_pointer) CFLAGS += $(fno_stack_protector) CFLAGS += $(fno_stack_protector_all) CFLAGS += $(wno_frame_address) +CFLAGS += $(if $(U32_LONG_FMT),-D__U32_LONG_FMT__,) CXXFLAGS += $(CFLAGS) diff --git a/configure b/configure index 995c8fa..127868c 100755 --- a/configure +++ b/configure @@ -109,6 +109,18 @@ if [ -f $testdir/run ]; then ln -fs $testdir/run $testdir-run fi +# check if uint32_t needs a long format modifier +cat << EOF > lib_test.c +#include +EOF + +$cross_prefix$cc lib_test.c -E | grep "typedef" | grep "long" | grep "uint32_t" &> /dev/null +exit=$? +if [ $exit -eq 0 ]; then + u32_long=true +fi +rm -f lib_test.c + # check for dependent 32 bit libraries if [ "$arch" != "arm" ]; then cat << EOF > lib_test.c @@ -155,4 +167,5 @@ TEST_DIR=$testdir FIRMWARE=$firmware ENDIAN=$endian PRETTY_PRINT_STACKS=$pretty_print_stacks +U32_LONG_FMT=$u32_long EOF diff --git a/lib/libcflat.h b/lib/libcflat.h index 380395f..e80fc50 100644 --- a/lib/libcflat.h +++ b/lib/libcflat.h @@ -58,12 +58,21 @@ typedef _Bool bool; #define true 1 #if __SIZEOF_LONG__ == 8 +# define __PRI32_PREFIX # define __PRI64_PREFIX "l" # define __PRIPTR_PREFIX "l" #else +#if defined(__U32_LONG_FMT__) +# define __PRI32_PREFIX "l" +#else +# define __PRI32_PREFIX +#endif # define __PRI64_PREFIX "ll" # define __PRIPTR_PREFIX #endif +#define PRId32 __PRI32_PREFIX "d" +#define PRIu32 __PRI32_PREFIX "u" +#define PRIx32 __PRI32_PREFIX "x" #define PRId64 __PRI64_PREFIX "d" #define PRIu64 __PRI64_PREFIX "u" #define PRIx64 __PRI64_PREFIX "x"