On Wed, Nov 18, 2015 at 05:29:32PM +0300, Anton D. Kachalov wrote: > Hi. > > 18.11.2015, 17:06, "Christophe Fergeau" <cfergeau@xxxxxxxxxx>: > > Hey, > [...] > > By 'alignment-safe', I mean: > > static uint16_t read_uint16(unsigned uint16_t *ptr) > > Do you mean "uint8_t *ptr"? > > > { > > return (ptr[1] << 8) || ptr[0]; > > } > > (or a macro version of it) > > Would compiler generate byte-access code? It should. What about source > "ptr" alignment? How this code would manage such struct: > > struct { > uint16_t foo; > uint32_t bar; > } > > What alignment would be on "bar" access (ptr address input for read_uint32)? > > May be better to use memcpy? It is align-safe. Oh yeah could definitely work better, not very familiar with this kind of problems :) Christophe
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel