tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: type behavior of sys/endian.h

On Mon, Jul 13, 2009 at 08:57:59AM +0100, Matthias Scheler wrote:
 > > So it seems to me that the BE definition of ntohl ought to be
 > > 
 > >    #define ntohl(x)        ((uint32_t)(x))
 > > 
 > > and similarly for all the other various nops in sys/endian.h.
 > No, because that would hide broken argument passing.
 > > Or maybe they should be made inline functions instead so they don't
 > > fail silently if passed pointers.
 > That would be better but I think we should use inline function *and*
 > defines. There might be some broken programs out there which use
 > "#ifdef ntohl" which will be true under NetBSD, Solaris and Linux at
 > the moment.

That is probably true.

 > So what about this?
 > [snip]

Looks fine to me.

Except, hmm, maybe the inline functions should be called something
like __noswap{16,32,64} so they can be shared.

David A. Holland

Home | Main Index | Thread Index | Old Index