This is the mail archive of the
libc-hacker@cygnus.com
mailing list for the glibc project.
Re: struct sockaddr_storage
- To: Philip Blundell <philb@gnu.org>
- Subject: Re: struct sockaddr_storage
- From: Andreas Schwab <schwab@issan.cs.uni-dortmund.de>
- Date: 11 May 1999 10:14:32 +0200
- Cc: libc-hacker@cygnus.com
- References: <E10gxtR-0000ky-00@kings-cross.london.uk.eu.org>
Philip Blundell <philb@gnu.org> writes:
|> Here's a patch to add a definition for `struct sockaddr_storage', which was
|> introduced by the IPv6 API. The intention is that it provides a block of
|> memory with sufficient size and alignment that you can cast it to any `struct
|> sockaddr_xxx *' and get sensible behaviour.
|>
|> Please check that it doesn't cause any breakage, especially on Hurd and MIPS.
|>
|> p.
|>
|> 1999-05-10 Philip Blundell <philb@gnu.org>
|>
|> * sysdeps/generic/bits/socket.h (struct sockaddr_storage): New
|> structure; storage suitable for any socket address.
|> * sysdeps/unix/sysv/linux/bits/socket.h: Likewise.
|> * sysdeps/unix/sysv/linux/mips/bits/socket.h: Likewise.
|>
|> --- libc/sysdeps/generic/bits/socket.h Fri Apr 24 21:52:30 1998
|> +++ libc/sysdeps/generic/bits/socket.h Mon May 10 20:03:52 1999
|> @@ -127,6 +127,25 @@
|> };
|>
|>
|> +/* Structure large enough to hold any socket address (with the historical
|> + exception of AF_UNIX). We reserve 128 bytes. */
|> +#include <sys/types.h>
|> +#if (~0UL) > 0xffffffff
This is wrong. The preprocessor must use the widest type for evaluation,
which is intmax_t in C9x, so that ~0U is _always_ bigger than 0xffffffff
(independent of the suffix, which is ignored by the preprocessor, and
intmax_t must have at least 64 bits). You must use ULONG_MAX instead.
Andreas.
--
Andreas Schwab "And now for something
schwab@issan.cs.uni-dortmund.de completely different"
schwab@gnu.org