From patchwork Fri Feb 1 22:26:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 217604 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 E7ECA2C029C for ; Sat, 2 Feb 2013 09:34:29 +1100 (EST) Received: from localhost ([::1]:59218 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1PBk-0004SI-4F for incoming@patchwork.ozlabs.org; Fri, 01 Feb 2013 17:34:28 -0500 Received: from eggs.gnu.org ([208.118.235.92]:60152) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1P81-00039h-Tm for qemu-devel@nongnu.org; Fri, 01 Feb 2013 17:34:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U1P4Q-00027j-0p for qemu-devel@nongnu.org; Fri, 01 Feb 2013 17:30:37 -0500 Received: from mail-ie0-x22a.google.com ([2607:f8b0:4001:c03::22a]:38544) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1P4P-00027X-SF for qemu-devel@nongnu.org; Fri, 01 Feb 2013 17:26:53 -0500 Received: by mail-ie0-f170.google.com with SMTP id c11so3968968ieb.1 for ; Fri, 01 Feb 2013 14:26:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :mime-version:content-type:content-transfer-encoding; bh=npsf8QVNXONUKBZgGv9hWFxvYzHRMQhjwsNnACJfQnY=; b=rYJ+ydXIQnSw6kWilw6an6FnZAnS0HwoQe140fw1IyEdYttjN3gqZPuRS+znZZMhcV 1omVCUxhNEBVPdHy4k70ntIneinMSh3SwUKDtqdduQjHqKeMTPKo/81OoMtt1jOpKKzZ CmpyWaXToBjGqlF5Dy8uUFhVlsFnSYMt+oqPo9ZjAM4HHTU9hEyHksV+TsvtxHnfEvtS Q5FAr78pGjd832OA5xejjkUSiOxz/xoqw8q/BPR8el1jLBeFDuz+8YhP3dWJtBzN4ycB LTbsi6usgsW7gnfxeQAMmucmJ2NEq0Finjp49GGpZed4XuU+c7lN/egdv9mya5DZ95iB gyhQ== X-Received: by 10.42.204.79 with SMTP id fl15mr10609110icb.57.1359757613370; Fri, 01 Feb 2013 14:26:53 -0800 (PST) Received: from anchor.twiddle.home.com (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPS id c3sm8244618igj.1.2013.02.01.14.26.51 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 01 Feb 2013 14:26:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Feb 2013 14:26:48 -0800 Message-Id: <1359757608-1927-1-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.11.7 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4001:c03::22a Cc: blauwirbel@gmail.com, afaerber@suse.de Subject: [Qemu-devel] =?utf-8?q?=5BPATCH_v2=5D_bswap=3A_Fix_width_of_swap_?= =?utf-8?q?in_leul=5Fto=5Fcpu?= 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 The misnamed HOST_LONG_BITS is really HOST_POINTER_BITS. Here we're explicitly using an unsigned long, rather than uintptr_t, so it is more correct to select the swap size via ULONG_MAX. Signed-off-by: Richard Henderson Acked-by: Andreas Färber --- include/qemu/bswap.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) This is the patch from http://lists.gnu.org/archive/html/qemu-devel/2013-01/msg05868.html with the commit message re-worded as per Andreas Färber feedback. r~ 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