From patchwork Tue Mar 15 15:03:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 8589751 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B6E33C0553 for ; Tue, 15 Mar 2016 15:34:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1BF97202AE for ; Tue, 15 Mar 2016 15:34:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 60E8520263 for ; Tue, 15 Mar 2016 15:34:12 +0000 (UTC) Received: from localhost ([::1]:49195 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afqz5-0000QE-OU for patchwork-qemu-devel@patchwork.kernel.org; Tue, 15 Mar 2016 11:34:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afqVn-0004PU-8C for qemu-devel@nongnu.org; Tue, 15 Mar 2016 11:03:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1afqVh-0007d4-JA for qemu-devel@nongnu.org; Tue, 15 Mar 2016 11:03:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49449) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afqVh-0007ck-Ei for qemu-devel@nongnu.org; Tue, 15 Mar 2016 11:03:49 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 148547209E; Tue, 15 Mar 2016 15:03:49 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-46.ams2.redhat.com [10.36.116.46]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2FF3jIO014235 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 15 Mar 2016 11:03:48 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B66EB3011FAC; Tue, 15 Mar 2016 16:03:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 15 Mar 2016 16:03:35 +0100 Message-Id: <1458054221-16923-10-git-send-email-armbru@redhat.com> In-Reply-To: <1458054221-16923-1-git-send-email-armbru@redhat.com> References: <1458054221-16923-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 15 Mar 2016 15:03:49 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH 09/15] Move HOST_LONG_BITS from qemu-common.h to qemu/osdep.h 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 qemu-common.h should only be included by .c files. Its file comment explains why: "No header file should depend on qemu-common.h, as this would easily lead to circular header dependencies." One of the reasons for headers to include it is HOST_LONG_BITS. Move that to its more natural home qemu/osdep.h, to facilitate removing these ill-advised includes later on. This also lets us use HOST_LONG_BITS in bswap.h instead of duplicating its definition there to avoid cyclic inclusion. Signed-off-by: Markus Armbruster --- include/qemu-common.h | 9 --------- include/qemu/bswap.h | 6 ++---- include/qemu/osdep.h | 9 +++++++++ 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/include/qemu-common.h b/include/qemu-common.h index 5a2d997..fbd999c 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -23,15 +23,6 @@ #include "qemu/option.h" #include "qemu/host-utils.h" -/* HOST_LONG_BITS is the size of a native pointer in bits. */ -#if UINTPTR_MAX == UINT32_MAX -# define HOST_LONG_BITS 32 -#elif UINTPTR_MAX == UINT64_MAX -# define HOST_LONG_BITS 64 -#else -# error Unknown pointer size -#endif - void cpu_ticks_init(void); /* icount */ diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h index 95071ba..fcedf0d 100644 --- a/include/qemu/bswap.h +++ b/include/qemu/bswap.h @@ -419,11 +419,9 @@ static inline void stfq_be_p(void *ptr, float64 v) static inline unsigned long leul_to_cpu(unsigned long v) { - /* 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 +#if HOST_LONG_BITS == 32 return le_bswap(v, 32); -#elif ULONG_MAX == UINT64_MAX +#elif HOST_LONG_BITS == 64 return le_bswap(v, 64); #else # error Unknown sizeof long diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 1c0ce4a..64b06e3 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -127,6 +127,15 @@ extern int daemon(int, int); #define TIME_MAX LONG_MAX #endif +/* HOST_LONG_BITS is the size of a native pointer in bits. */ +#if UINTPTR_MAX == UINT32_MAX +# define HOST_LONG_BITS 32 +#elif UINTPTR_MAX == UINT64_MAX +# define HOST_LONG_BITS 64 +#else +# error Unknown pointer size +#endif + #ifndef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif