]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3380: Mac OSX compile errors with CMSG_SPACE
authorDmitry Kurochkin <dmitry.kurochkin@measurement-factory.com>
Tue, 29 May 2012 12:20:02 +0000 (06:20 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 29 May 2012 12:20:02 +0000 (06:20 -0600)
compat/Makefile.am
compat/cmsg.h [new file with mode: 0644]
compat/os/macosx.h
configure.ac
src/ipc/TypedMsgHdr.h

index c9a72487d078632834aa562ecfa46dccd28b2dc9..a3e3ff257aca6a9263fd8cdf63f4a3a2015d34e1 100644 (file)
@@ -13,6 +13,7 @@ noinst_LIBRARIES = libcompat-squid.a
 libcompat_squid_a_SOURCES = \
        assert.cc \
        assert.h \
+       cmsg.h \
        compat.cc \
        compat.h \
        compat_shared.h \
diff --git a/compat/cmsg.h b/compat/cmsg.h
new file mode 100644 (file)
index 0000000..a433f77
--- /dev/null
@@ -0,0 +1,18 @@
+#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 */
index e601614f112e06dc19b145cbdac7fb9364540669..4baf2dc84877e6798a160feea16c660b61b1c53c 100644 (file)
@@ -18,5 +18,7 @@
 //#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 */
index 1b8b466ba5cb59ddc262adedba4de16b4fb8abaf..758909badab152ef9075414be25c8b2cbd0e626e 100644 (file)
@@ -3264,6 +3264,20 @@ if test "x$squid_cv_resuid_works" = "xyes" ; then
   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
index 95afe00dd67201606bae090f2e26e68ac79c77fb..68d9e5ac287b4348d357fa3d7ce15b0b58595c68 100644 (file)
@@ -90,7 +90,8 @@ private:
     } 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