[PATCH 1/1] inet: add support for 64-bit network byte order
Florian Weimer
fweimer@redhat.com
Mon Mar 10 13:12:56 GMT 2025
* Philip Prindeville:
> From: Philip Prindeville <philipp@redfish-solutions.com>
>
> As 32-bit machines become increasingly supplanted by 64-bit
> architectures, network protocols likewise leverage those
> larger word capabilities. A good example is POSIX supporting
> 64-bit time_t's to avoid the 2038 problem, or timestamps that
> include micro- or nanosecond precision.
> ---
> conform/data/arpa/inet.h-data | 2 ++
> conform/data/netinet/in.h-data | 2 ++
> inet/Makefile | 1 +
> inet/htonll.c | 35 +++++++++++++++++++
> inet/htontest.c | 11 ++++++
> inet/netinet/in.h | 11 ++++++
> inet/test-hnto-types.c | 4 +++
> manual/socket.texi | 15 ++++++++
> sysdeps/unix/sysv/linux/arm/be/libc.abilist | 2 ++
> sysdeps/unix/sysv/linux/arm/le/libc.abilist | 2 ++
> .../sysv/linux/loongarch/lp64/libc.abilist | 2 ++
> .../sysv/linux/m68k/coldfire/libc.abilist | 2 ++
> .../unix/sysv/linux/m68k/m680x0/libc.abilist | 2 ++
> .../sysv/linux/microblaze/be/libc.abilist | 2 ++
> .../sysv/linux/microblaze/le/libc.abilist | 2 ++
> .../unix/sysv/linux/riscv/rv32/libc.abilist | 2 ++
> .../unix/sysv/linux/riscv/rv64/libc.abilist | 2 ++
> .../unix/sysv/linux/s390/s390-32/libc.abilist | 2 ++
> .../unix/sysv/linux/s390/s390-64/libc.abilist | 2 ++
> sysdeps/unix/sysv/linux/sh/be/libc.abilist | 2 ++
> sysdeps/unix/sysv/linux/sh/le/libc.abilist | 2 ++
> .../sysv/linux/sparc/sparc32/libc.abilist | 2 ++
> .../sysv/linux/sparc/sparc64/libc.abilist | 2 ++
> .../unix/sysv/linux/x86_64/64/libc.abilist | 2 ++
> .../unix/sysv/linux/x86_64/x32/libc.abilist | 2 ++
> 25 files changed, 115 insertions(+)
I think Hurd abilist updates are missing.
Please also add a NEWS entry mentioning the function.
Do you have a copyright assignment with the FSF? If not, please
consider obtaining one, or submit the patch under DCO
<https://developercertificate.org/>, by including a Signed-off-by: line
in the commit message.
> diff --git a/conform/data/arpa/inet.h-data b/conform/data/arpa/inet.h-data
> index 040b8212c73778d2e1272a2841424fdb098ddde2..c80912ffde59e1d6da1c548f3a0e072f4b4ab5f6 100644
> --- a/conform/data/arpa/inet.h-data
> +++ b/conform/data/arpa/inet.h-data
> @@ -11,8 +11,10 @@ macro INET_ADDRSTRLEN
> macro INET6_ADDRSTRLEN
>
> // The following can be declared as functions, defined as macros or both:
> +function uint64_t htonll (uint64_t)
> function uint32_t htonl (uint32_t)
> function uint16_t htons (uint16_t)
> +function uint64_t ntohll (uint64_t)
> function uint32_t ntohl (uint32_t)
> function uint16_t htons (uint16_t)
This looks premature because these functions are not yet part of POSIX
or any other standard.
> diff --git a/conform/data/netinet/in.h-data b/conform/data/netinet/in.h-data
> index ccc74db608727200161d2713a2f7fb171d8b8138..27a8628a99f749e69c0b6456fb875da5cd8da367 100644
> --- a/conform/data/netinet/in.h-data
> +++ b/conform/data/netinet/in.h-data
> @@ -53,8 +53,10 @@ macro INADDR_BROADCAST
>
> constant INET_ADDRSTRLEN == 16
>
> +function uint64_t htonll (uint64_t)
> function uint32_t htonl (uint32_t)
> function uint16_t htons (uint16_t)
> +function uint64_t ntohll (uint64_t)
> function uint32_t ntohl (uint32_t)
> function uint16_t ntohs (uint16_t)
Likewise.
> diff --git a/inet/netinet/in.h b/inet/netinet/in.h
> index fa796be406a7120fd6b85d7851b94fe5938bebc0..4fe19b9ee5181a43cb42b86bae603b1f47cb1c3e 100644
> --- a/inet/netinet/in.h
> +++ b/inet/netinet/in.h
> @@ -406,6 +406,13 @@ extern uint32_t htonl (uint32_t __hostlong)
> extern uint16_t htons (uint16_t __hostshort)
> __THROW __attribute__ ((__const__));
>
> +/* Address the following shortcoming by including unsigned long long,
> + which is useful for things such as nanosecond timestamps, etc. */
> +
> +extern uint64_t ntohll (uint64_t __netlonglong) __THROW __attribute__ ((__const__));
> +extern uint64_t htonll (uint64_t __hostlonglong)
> + __THROW __attribute__ ((__const__));
> +
> #include <endian.h>
I think the comment is unnecessary here.
The actual implementation and the manual update look okay.
Thanks,
Florian
More information about the Libc-alpha
mailing list