From patchwork Mon Jan 18 10:56:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 43056 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 46DA4B7C7E for ; Mon, 18 Jan 2010 22:06:38 +1100 (EST) Received: from localhost ([127.0.0.1]:45497 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NWpQs-0002kp-Qn for incoming@patchwork.ozlabs.org; Mon, 18 Jan 2010 06:06:06 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NWpKz-0001hi-33 for qemu-devel@nongnu.org; Mon, 18 Jan 2010 06:00:01 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NWpKu-0001fQ-4y for qemu-devel@nongnu.org; Mon, 18 Jan 2010 06:00:00 -0500 Received: from [199.232.76.173] (port=51049 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NWpKt-0001fI-Uo for qemu-devel@nongnu.org; Mon, 18 Jan 2010 05:59:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55918) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NWpKt-0002GC-GE for qemu-devel@nongnu.org; Mon, 18 Jan 2010 05:59:55 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0IAxbXH028862 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 18 Jan 2010 05:59:37 -0500 Received: from redhat.com (vpn1-4-121.ams2.redhat.com [10.36.4.121]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o0IAxV19028830; Mon, 18 Jan 2010 05:59:32 -0500 Date: Mon, 18 Jan 2010 12:56:30 +0200 From: "Michael S. Tsirkin" To: "Michael S. Tsirkin" Message-ID: <20100118105630.GB8277@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: qemu-devel@nongnu.org, agraf@suse.de, Blue Swirl , Isaku Yamahata , paul@codesourcery.com, Aurelien Jarno Subject: [Qemu-devel] [PATCHv2 1/3] bwap: add qemu_bswap helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org add helper that can swap values of 4, 2, 1 bytes Signed-off-by: Michael S. Tsirkin --- bswap.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/bswap.h b/bswap.h index 4558704..aace9b7 100644 --- a/bswap.h +++ b/bswap.h @@ -214,4 +214,10 @@ static inline void cpu_to_be32wu(uint32_t *p, uint32_t v) #undef le_bswaps #undef be_bswaps +/* len must be one of 1, 2, 4 */ +static inline uint32_t qemu_bswap_len(uint32_t value, int len) +{ + return bswap32(value) >> (32 - 8 * len); +} + #endif /* BSWAP_H */