From patchwork Wed Jan 30 21:56:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Weil X-Patchwork-Id: 216992 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1E0CB2C007C for ; Thu, 31 Jan 2013 08:56:53 +1100 (EST) Received: from localhost ([::1]:49949 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U0feF-0003xh-Bu for incoming@patchwork.ozlabs.org; Wed, 30 Jan 2013 16:56:51 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U0fe5-0003xb-PY for qemu-devel@nongnu.org; Wed, 30 Jan 2013 16:56:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U0fe4-0002NE-E2 for qemu-devel@nongnu.org; Wed, 30 Jan 2013 16:56:41 -0500 Received: from v220110690675601.yourvserver.net ([78.47.199.172]:33822) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U0fe4-0002My-2Q for qemu-devel@nongnu.org; Wed, 30 Jan 2013 16:56:40 -0500 Received: from localhost (v220110690675601.yourvserver.net.local [127.0.0.1]) by v220110690675601.yourvserver.net (Postfix) with ESMTP id 5548D7280045; Wed, 30 Jan 2013 22:56:38 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at weilnetz.de Received: from v220110690675601.yourvserver.net ([127.0.0.1]) by localhost (v220110690675601.yourvserver.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hrQq6ukKXpxh; Wed, 30 Jan 2013 22:56:37 +0100 (CET) Received: from flocke.fritz.box (p5086E81A.dip.t-dialin.net [80.134.232.26]) by v220110690675601.yourvserver.net (Postfix) with ESMTPSA id 98C547280043; Wed, 30 Jan 2013 22:56:37 +0100 (CET) Received: from localhost ([127.0.0.1] ident=stefan) by flocke.fritz.box with esmtp (Exim 4.72) (envelope-from ) id 1U0fe1-0001b5-8M; Wed, 30 Jan 2013 22:56:37 +0100 Message-ID: <51099715.8050602@weilnetz.de> Date: Wed, 30 Jan 2013 22:56:37 +0100 From: Stefan Weil User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20121215 Iceowl/1.0b1 Icedove/3.0.11 MIME-Version: 1.0 To: Richard Henderson References: <1359579300-27862-1-git-send-email-rth@twiddle.net> <51098AF7.3090902@weilnetz.de> In-Reply-To: <51098AF7.3090902@weilnetz.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 78.47.199.172 Cc: blauwirbel@gmail.com, qemu-devel@nongnu.org, afaerber@suse.de Subject: Re: [Qemu-devel] [PATCH] bswap: Don't rely on HOST_LONG_BITS X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Am 30.01.2013 22:04, schrieb Stefan Weil: > Am 30.01.2013 21:55, schrieb Richard Henderson: >> This is not always defined in all places qemu/bswap.h is used. >> If we include qemu-common.h to get it, we create an include loop. >> This resolves a build problem on any big-endian host like ppc64. >> >> Signed-off-by: Richard Henderson >> --- >> include/qemu/bswap.h | 12 ++++++++++-- >> 1 file changed, 10 insertions(+), 2 deletions(-) >> >> diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h >> index e6d4798..d3af35d 100644 >> --- a/include/qemu/bswap.h >> +++ b/include/qemu/bswap.h >> @@ -2,8 +2,8 @@ >> #define BSWAP_H >> >> #include "config-host.h" >> - >> #include >> +#include >> #include "fpu/softfloat.h" >> >> #ifdef CONFIG_MACHINE_BSWAP_H >> @@ -458,7 +458,15 @@ static inline void cpu_to_32wu(uint32_t *p, >> uint32_t v) >> >> static inline unsigned long leul_to_cpu(unsigned long v) >> { >> - return le_bswap(v, HOST_LONG_BITS); >> + /* In order to break an include loop between here and >> + qemu-common.h, don't rely on HOST_LONG_BITS. */ >> +#if ULONG_MAX == UINT32_MAX >> + return le_bswap(v, 32); >> +#elif ULONG_MAX == UINT64_MAX >> + return le_bswap(v, 64); >> +#else >> +# error Unknown sizeof long >> +#endif >> } >> >> #undef le_bswap > > That would be wrong for 64 bit MinGW-w64 because > HOST_LONG_BITS is _not_ the bit size of a long value. > > See qemu-common.h for the correct definition. > > Regards > Stefan W. Could you please try whether this patch fixes the build problems: From 4dd39af7a3e493669977ec6f50e91bf649b5727f Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Wed, 30 Jan 2013 22:52:12 +0100 Subject: [PATCH] Fix build problems for big endian hosts Make sure that HOST_LONG_BITS is always defined when qemu/bswap.h is included. Signed-off-by: Stefan Weil --- fsdev/virtio-9p-marshal.c | 12 +----------- hw/spapr_nvram.c | 2 ++ include/qemu/bswap.h | 4 ++++ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/fsdev/virtio-9p-marshal.c b/fsdev/virtio-9p-marshal.c index 20f308b..4e634df 100644 --- a/fsdev/virtio-9p-marshal.c +++ b/fsdev/virtio-9p-marshal.c @@ -11,20 +11,10 @@ * */ -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include "qemu/compiler.h" +#include "qemu-common.h" #include "virtio-9p-marshal.h" -#include "qemu/bswap.h" void v9fs_string_free(V9fsString *str) { diff --git a/hw/spapr_nvram.c b/hw/spapr_nvram.c index 680cdba..2960b15 100644 --- a/hw/spapr_nvram.c +++ b/hw/spapr_nvram.c @@ -22,6 +22,8 @@ * THE SOFTWARE. */ +#include "qemu-common.h" + #include #include "sysemu/device_tree.h" diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h index e6d4798..07dadc2 100644 --- a/include/qemu/bswap.h +++ b/include/qemu/bswap.h @@ -13,6 +13,10 @@ #elif defined(CONFIG_BYTESWAP_H) # include +#if !defined(HOST_LONG_BITS) +# error needs HOST_LONG_BITS +#endif + static inline uint16_t bswap16(uint16_t x) { return bswap_16(x);