On Mon, 19 Jan 2015 11:45:39 +0000
Peter Maydell <peter.mayd...@linaro.org> wrote:

> On 19 January 2015 at 11:35, Stefan Hajnoczi <stefa...@gmail.com> 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
> 

Heh, not sure I would have provided such a comprehensive answer. :)

Stefan,

Feeling curious, what was the intent behind your question ?

Cheers.

--
Greg


Reply via email to