From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDAmU-0004A5-CV for qemu-devel@nongnu.org; Mon, 19 Jan 2015 06:46:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDAmR-0003yj-7s for qemu-devel@nongnu.org; Mon, 19 Jan 2015 06:46:06 -0500 Received: from mail-la0-f42.google.com ([209.85.215.42]:65495) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDAmQ-0003ya-Uh for qemu-devel@nongnu.org; Mon, 19 Jan 2015 06:46:03 -0500 Received: by mail-la0-f42.google.com with SMTP id ms9so5889048lab.1 for ; Mon, 19 Jan 2015 03:45:59 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: From: Peter Maydell Date: Mon, 19 Jan 2015 11:45:39 +0000 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] virtio_tswaps() vs virtio_ld/st_p() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel On 19 January 2015 at 11:35, Stefan Hajnoczi wrote: > What is the difference between the virtio_tswaps() and > virtio_ld/st_p() families of functions? virtio_ld/st*_p() perform a load or store from memory pointed to by the (host) pointer argument. virtio_tswap16 &c take a value, swap it as appropriate and return a value. virtio_tswap16s &c do an in-place byteswap on the value pointed to by the host pointer argument. (The tswap*/tswap*s pairs are a mirror of the equivalent families of functions bswap16/bswap16s provided by bswap.h.) The most important distinction here is that the ld/st functions will handle possibly unaligned accesses, whereas the tswap functions will not. The former are intended for "fish this value out from some guest RAM" and the latter for "we have a structure we've copied from guest RAM already via memcpy and want to swizzle the entries in it". -- PMM