Index | Thread | Search

From:
Christian Weisgerber <naddy@mips.inka.de>
Subject:
Re: Cruft: drop htonl() etc. from libc
To:
Philip Guenther <guenther@gmail.com>
Cc:
George Koehler <kernigh@gmail.com>, Mark Kettenis <mark.kettenis@xs4all.nl>, tech@openbsd.org
Date:
Sat, 13 Apr 2024 02:15:33 +0200

Download raw body.

Thread
Philip Guenther:

> > I believe that macros like htonl don't need functions, but this
> > diff is correct to keep a function which already exists.
> 
> Unless explicitly specified as a macro, POSIX requires all functional
> interfaces to have a function prototype and external symbol.

We only have htonl() etc. as macros and that is permitted by POSIX:
"On some implementations, these functions are defined as macros."

We don't have any prototype for htonl() in our headers.

If you want to get at the functions in libc, you need to #undef
htonl (or avoid including any headers that pull in the macro), and
provide your own prototype.

Importantly, my proposed diff doesn't change any of that.

-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de