From 9c01a3d0db18c41c0186b12e3d40e7c6ab00623a Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 19 May 2010 21:40:49 +0000 Subject: [PATCH] Solaris 9 is missing CMSG_ALIGN and some of the RFC2292 CMSG_*. From Dagobert Michelsen. --- compat.h | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/compat.h b/compat.h index dd18840a..83ae841d 100644 --- a/compat.h +++ b/compat.h @@ -1,4 +1,4 @@ -/* $Id: compat.h,v 1.21 2010-05-19 21:31:37 nicm Exp $ */ +/* $Id: compat.h,v 1.22 2010-05-19 21:40:49 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -84,14 +84,31 @@ typedef uint64_t u_int64_t; #endif #ifdef HAVE_BROKEN_CMSG_FIRSTHDR -/* Broken on OS X. */ +/* CMSG_FIRSTHDR broken on OS X. */ #undef CMSG_FIRSTHDR #define CMSG_FIRSTHDR(mhdr) \ - ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \ - (struct cmsghdr *)(mhdr)->msg_control : \ + ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \ + (struct cmsghdr *)(mhdr)->msg_control : \ (struct cmsghdr *)NULL) #endif +/* CMSG_ALIGN, CMSG_SPACE, CMSG_LEN missing from Solaris 9. */ +#ifndef CMSG_ALIGN +#ifdef __sun +#define CMSG_ALIGN _CMSG_DATA_ALIGN +#else +#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 + #ifndef INFTIM #define INFTIM -1 #endif @@ -135,7 +152,7 @@ typedef uint64_t u_int64_t; #endif #ifndef HAVE_BZERO -#define bzero(buf, len) memset((buf), 0, (len)); +#define bzero(buf, len) memset(buf, 0, len); #endif #ifndef HAVE_STRCASESTR