18.11.2015, 17:29, "Anton D. Kachalov" <mo...@yandex-team.ru>:
> Hi.
>
>
> struct {
>   uint16_t foo;
>   uint32_t bar;
> }
>
> What alignment would be on "bar" access (ptr address input for read_uint32)?

This might work:

uint32_t read_uint32(uint8_t *ptr) {
   return ptr[3] << 24 | ... | ptr[0];
}

but question in the byte-access overhead code versus memcpy code.

>
> May be better to use memcpy? It is align-safe.

memcpy should be definitely better choice for float/double reads/writes. 
Meanwhile, current protocol doesn't have such fields' types.

-- 
Anton D. Kachalov
_______________________________________________
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel

Reply via email to