On 28/12/25 17:20, Paolo Bonzini wrote:
Il dom 28 dic 2025, 17:00 Philippe Mathieu-Daudé <[email protected]
<mailto:[email protected]>> ha scritto:
On 28/12/25 16:38, Paolo Bonzini wrote:
>
>
> Il dom 28 dic 2025, 16:14 Philippe Mathieu-Daudé
<[email protected] <mailto:[email protected]>
> <mailto:[email protected] <mailto:[email protected]>>> ha scritto:
>
> > Perhaps the source of the confusion is that they are in
bswap.h
> but they
> > (quite obviously since it's host endianness) never swap?
>
> Hmm, maybe not well named API then.
>
>
> The name is fine, the placement maybe a bit less; they could be
moved
> out of bswap.h but it's not really necessary to do it now.
Indeed not needed now, but already done to figure this API ;) This
helped me to understand what we don't need is "DO_STN_LDN_P(he)"
because this is a convoluted expansion to a plain memcpy().
Without having seen your code, I will note that the simple conversion to
memcpy() only works for little endian hosts. On big endian, you also
need to adjust the first byte, like
memcpy(p, ((uint8_t*)&val) + sizeof(val) - n, n);
Thanks, this is exactly what I had in mind for few replacements.
And likewise for ldn_he_p. (Apologize if you had noticed it, just trying
to avoid a possible round trip over the holidays!)
Thanks for your review and help :)