tech-userlevel archive

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

Incorrect #if usage in netdb.h



While trying to accurately replicate NetBSD's struct addrinfo for
crystal[0], I noticed this pattern occurs twice in netdb.h...

#if defined(__alpha__) || (defined(__i386__) && defined(_LP64))
        int             __ai_pad0;      /* ABI compatibility */
#endif

This was added in 2004 in response to a change of ai_addrlen
in POSIX from size_t to socklen_t. The problem is... it doesn't
work. __i386__ is not defined on amd64.

The person who committed this change appeared to be thinking
in terms of sparc, where a test like this is valid.

My hunch is that "|| (defined(__i386___) && defined(_LP64))" is
totally bogus and should be removed. If the ABI was accidentally
and happily not broken, we have nothing to worry about. If it
was... it was broken 16 years ago, and that break is now
irrelevant.

[0]: https://github.com/crystal-lang/crystal/pull/9360


Home | Main Index | Thread Index | Old Index