Received: from eggs.gnu.org ([2001:4830:134:3::10]:60316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5JA9-00050t-7E for qemu-devel@nongnu.org; Wed, 17 Jun 2015 15:38:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z5JA5-0001eZ-2E for qemu-devel@nongnu.org; Wed, 17 Jun 2015 15:38:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39313) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5JA4-0001eS-RP for qemu-devel@nongnu.org; Wed, 17 Jun 2015 15:38:12 -0400 Date: Wed, 17 Jun 2015 21:38:09 +0200 From: "Michael S. Tsirkin" Message-ID: <1434569795-10524-4-git-send-email-mst@redhat.com> References: <1434569795-10524-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1434569795-10524-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL 03/10] virtio: introduce virtio_legacy_is_cross_endian() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Cornelia Huck , Peter Maydell , Rusty Russell , Alexander Graf From: Greg Kurz This helper will be used by vhost and tap to detect cross-endianness in the legacy virtio case. Signed-off-by: Greg Kurz Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-access.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-access.h index ee28c21..cee5dd7 100644 --- a/include/hw/virtio/virtio-access.h +++ b/include/hw/virtio/virtio-access.h @@ -32,6 +32,19 @@ static inline bool virtio_access_is_big_endian(VirtIODevice *vdev) #endif } +static inline bool virtio_legacy_is_cross_endian(VirtIODevice *vdev) +{ +#ifdef TARGET_IS_BIENDIAN +#ifdef HOST_WORDS_BIGENDIAN + return !virtio_is_big_endian(vdev); +#else + return virtio_is_big_endian(vdev); +#endif +#else + return false; +#endif +} + static inline uint16_t virtio_lduw_phys(VirtIODevice *vdev, hwaddr pa) { if (virtio_access_is_big_endian(vdev)) { -- MST