From: Wouter Wijngaards Date: Fri, 16 Apr 2010 08:41:08 +0000 (+0000) Subject: portability of CMSG_SPACE X-Git-Tag: release-1.4.4rc1~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1085e72135b9c80171ba87b74b18a8981106e3ad;p=thirdparty%2Funbound.git portability of CMSG_SPACE git-svn-id: file:///svn/unbound/trunk@2081 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/doc/Changelog b/doc/Changelog index d32886b02..403f7dd97 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,6 @@ +16 April 2010: Wouter + - more portability defines for CMSG_SPACE, CMSG_ALIGN, CMSG_LEN. + 15 April 2010: Wouter - ECC-GOST algorithm number 12 that is assigned by IANA. New test example key and signatures for GOST. GOST requires openssl-1.0.0. diff --git a/util/netevent.c b/util/netevent.c index 2c0a9577e..4b6a0a3ce 100644 --- a/util/netevent.c +++ b/util/netevent.c @@ -46,6 +46,29 @@ #include "util/fptr_wlist.h" /* -------- Start of local definitions -------- */ +/** if CMSG_ALIGN is not defined on this platform, a workaround */ +#ifndef CMSG_ALIGN +# ifdef _CMSG_DATA_ALIGN +# define CMSG_ALIGN _CMSG_DATA_ALIGN +# else +# define CMSG_ALIGN(len) (((len)+sizeof(long)-1) & ~(sizeof(long)-1)) +# endif +#endif + +/** if CMSG_LEN is not defined on this platform, a workaround */ +#ifndef CMSG_LEN +# define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr))+(len)) +#endif + +/** if CMSG_SPACE is not defined on this platform, a workaround */ +#ifndef CMSG_SPACE +# ifdef _CMSG_HDR_ALIGN +# define CMSG_SPACE(l) (CMSG_ALIGN(l)+_CMSG_HDR_ALIGN(sizeof(struct cmsghdr))) +# else +# define CMSG_SPACE(l) (CMSG_ALIGN(l)+CMSG_ALIGN(sizeof(struct cmsghdr))) +# endif +#endif + /** The TCP reading or writing query timeout in seconds */ #define TCP_QUERY_TIMEOUT 120 @@ -295,11 +318,6 @@ comm_point_send_udp_msg(struct comm_point *c, ldns_buffer* packet, return 1; } -/** if no CMSG_LEN (Solaris 9) define something reasonable for one element */ -#ifndef CMSG_LEN -#define CMSG_LEN(x) (sizeof(struct cmsghdr)+(x)) -#endif - /** print debug ancillary info */ void p_ancil(const char* str, struct comm_reply* r) {