[PATCH v2 1/1] inet: add support for 64-bit network byte order

Florian Weimer fweimer@redhat.com
Tue Mar 11 20:07:31 GMT 2025


* Joseph Myers:

> On Tue, 11 Mar 2025, Philip Prindeville wrote:
>
>> Y’all know where I was going to go with this next, right?
>> 
>> Yup, standardized marshaling for float and double…
>
> You can use printf with %a to output those as hex float strings.
>
> Alternatively, C23 Annex H defines encodefN / decodefN functions that can 
> be used with _Float32 / _Float64 (and that follow __STDC_ENDIAN_NATIVE__, 
> so you'd then need to do endian conversion; endian-aware loads / stores 
> didn't get into the C standard before C2Y, but you could of course combine 
> encodefN / decodefN with interfaces such as htobe64; encodefN / decodefN 
> use unsigned char arrays, so you can cast a pointer to an integer and the 
> aliasing is OK).  Since _Float32 and _Float64 are defined to follow the 
> semantics of IEEE interchange formats, they are semantically preferable to 
> float and double for this - just as uint64_t is preferable to unsigned 
> long long for such purposes (both in the types used in the interfaces, and 
> in the naming where "64" is preferable to "ll").

Do any of these interfaces cover the mixed endian doubles that some
32-bit Arm ABIs use?  Or are all of these obsolete/not supported by
glibc?

Thanks,
Florian



More information about the Libc-alpha mailing list