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: 90950 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1209834qgi; Wed, 11 Jan 2017 08:43:39 -0800 (PST) X-Received: by 10.99.126.27 with SMTP id z27mr11631384pgc.177.1484153019123; Wed, 11 Jan 2017 08:43:39 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id 64si6291971ply.171.2017.01.11.08.43.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jan 2017 08:43:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 1cRLzp-0003Td-Pu; Wed, 11 Jan 2017 16:43:33 +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-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c01:0:0:0:233 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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+patch=linaro.org@lists.infradead.org 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"