libcompat_squid_a_SOURCES = \
assert.cc \
assert.h \
+ cmsg.h \
compat.cc \
compat.h \
compat_shared.h \
--- /dev/null
+#ifndef SQUID_COMPAT_CMSG_H
+#define SQUID_COMPAT_CMSG_H
+
+// CMSG_SPACE is not constant on some systems (in particular Max OS X),
+// provide a replacement that can be used at build time in that case
+
+#if HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+#if HAVE_CONSTANT_CMSG_SPACE
+#define SQUID_CMSG_SPACE CMSG_SPACE
+#else
+// add 16 bytes for header and data alignment
+#define SQUID_CMSG_SPACE(len) (sizeof(struct cmsghdr) + (len) + 16)
+#endif
+
+#endif /* SQUID_COMPAT_CMSG_H */
//#define s6_addr16 __u6_addr.__u6_addr16
#define s6_addr32 __u6_addr.__u6_addr32
+#include "compat/cmsg.h"
+
#endif /* _SQUID_APPLE_ */
#endif /* SQUID_OS_MACOSX_H */
AC_DEFINE(HAVE_SETRESUID,1,[Yay! Another Linux brokenness. Knowing that setresuid() exists is not enough, because RedHat 5.0 declares setresuid() but does not implement it.])
fi
+AC_MSG_CHECKING([for constant CMSG_SPACE])
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+ #if HAVE_SYS_SOCKET_H
+ #include <sys/socket.h>
+ #endif
+
+ int a[CMSG_SPACE(int)];
+]])], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_CONSTANT_CMSG_SPACE, 1, [Define to 1 if CMSG_SPACE is constant])
+], [
+ AC_MSG_RESULT(no)
+])
+
SQUID_CHECK_FUNC_STRNSTR
SQUID_CHECK_FUNC_VACOPY
SQUID_CHECK_FUNC___VACOPY
#ifndef SQUID_IPC_TYPED_MSG_HDR_H
#define SQUID_IPC_TYPED_MSG_HDR_H
+#include "compat/cmsg.h"
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
} data; ///< same as .msg_iov[0].iov_base
struct CtrlBuffer {
- char raw[CMSG_SPACE(sizeof(int))]; ///< control buffer space for one fd
+ /// control buffer space for one fd
+ char raw[SQUID_CMSG_SPACE(sizeof(int))];
} ctrl; ///< same as .msg_control
/// data offset for the next get/put*() to start with