Define CMSG_ALIGN, CMSG_SPACE, and CMSG_LEN for old Solaris.

This was reported by Dagobert Michelsen and comes from
http://wiki.opencsw.org/porting-faq#toc10.
This commit is contained in:
david 2011-09-03 01:51:35 +00:00
parent d18c149e8c
commit 1ef0db4b33

View file

@ -111,6 +111,26 @@
#endif
#include <net/if_arp.h>
/* Define CMSG_* symbols for Solaris 9 and earlier. See
http://wiki.opencsw.org/porting-faq#toc10. */
#if defined(__sun) || defined(__sun__)
# ifndef CMSG_ALIGN
# ifdef __sun__
# define CMSG_ALIGN(len) _CMSG_DATA_ALIGN (len)
# else
/* aligning to sizeof (long) is assumed to be portable (fd.o#40235) */
# define CMSG_ALIGN(len) (((len) + sizeof (long) - 1) & ~(sizeof (long) - 1))
# endif
# endif
# ifndef CMSG_SPACE
# define CMSG_SPACE(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + CMSG_ALIGN (len))
# endif
# ifndef CMSG_LEN
# define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
# endif
#endif /* Solaris */
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif