From patchwork Wed Apr 13 15:44:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 8823941 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 2FD31C0553 for ; Wed, 13 Apr 2016 15:47:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 904CF20272 for ; Wed, 13 Apr 2016 15:47:40 +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 D848720270 for ; Wed, 13 Apr 2016 15:47:39 +0000 (UTC) Received: from localhost ([::1]:46162 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aqN11-0006Ln-66 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 13 Apr 2016 11:47:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33387) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aqMyf-0001Rj-61 for qemu-devel@nongnu.org; Wed, 13 Apr 2016 11:45:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aqMyZ-0004mR-AU for qemu-devel@nongnu.org; Wed, 13 Apr 2016 11:45:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56861) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aqMyZ-0004lu-5G for qemu-devel@nongnu.org; Wed, 13 Apr 2016 11:45:07 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BB798C05E176 for ; Wed, 13 Apr 2016 15:45:06 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-24.ams2.redhat.com [10.36.116.24]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3DFj5L8025786; Wed, 13 Apr 2016 11:45:06 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 356FC8191A; Wed, 13 Apr 2016 17:45:05 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 13 Apr 2016 17:44:56 +0200 Message-Id: <1460562303-17079-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1460562303-17079-1-git-send-email-kraxel@redhat.com> References: <1460562303-17079-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 2/9] move const_le{16, 23} to qemu/bswap.h, add comment X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 Signed-off-by: Gerd Hoffmann Reviewed-by: Eric Blake Message-id: 1460441239-867-1-git-send-email-kraxel@redhat.com --- include/hw/virtio/virtio-input.h | 14 -------------- include/qemu/bswap.h | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/include/hw/virtio/virtio-input.h b/include/hw/virtio/virtio-input.h index 169adee..1b414c4 100644 --- a/include/hw/virtio/virtio-input.h +++ b/include/hw/virtio/virtio-input.h @@ -13,20 +13,6 @@ typedef struct virtio_input_absinfo virtio_input_absinfo; typedef struct virtio_input_config virtio_input_config; typedef struct virtio_input_event virtio_input_event; -#if defined(HOST_WORDS_BIGENDIAN) -# define const_le32(_x) \ - ((((_x) & 0x000000ffU) << 24) | \ - (((_x) & 0x0000ff00U) << 8) | \ - (((_x) & 0x00ff0000U) >> 8) | \ - (((_x) & 0xff000000U) >> 24)) -# define const_le16(_x) \ - ((((_x) & 0x00ff) << 8) | \ - (((_x) & 0xff00) >> 8)) -#else -# define const_le32(_x) (_x) -# define const_le16(_x) (_x) -#endif - /* ----------------------------------------------------------------- */ /* qemu internals */ diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h index fcedf0d..ce3c42e 100644 --- a/include/qemu/bswap.h +++ b/include/qemu/bswap.h @@ -125,6 +125,25 @@ static inline uint32_t qemu_bswap_len(uint32_t value, int len) return bswap32(value) >> (32 - 8 * len); } +/* + * Same as cpu_to_le{16,23}, except that gcc will figure the result is + * a compile-time constant if you pass in a constant. So this can be + * used to initialize static variables. + */ +#if defined(HOST_WORDS_BIGENDIAN) +# define const_le32(_x) \ + ((((_x) & 0x000000ffU) << 24) | \ + (((_x) & 0x0000ff00U) << 8) | \ + (((_x) & 0x00ff0000U) >> 8) | \ + (((_x) & 0xff000000U) >> 24)) +# define const_le16(_x) \ + ((((_x) & 0x00ff) << 8) | \ + (((_x) & 0xff00) >> 8)) +#else +# define const_le32(_x) (_x) +# define const_le16(_x) (_x) +#endif + /* Unions for reinterpreting between floats and integers. */ typedef union {