]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - compat/os/linux.h
SourceFormat Enforcement
[thirdparty/squid.git] / compat / os / linux.h
index 34ff1a404c7f2d011fe7d1249ad06098606765b4..1ab0df5aab6f9f5b552801f6924ace67a751dc43 100644 (file)
@@ -1,7 +1,15 @@
+/*
+ * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
 #ifndef SQUID_OS_LINUX_H
 #define SQUID_OS_LINUX_H
 
-#ifdef _SQUID_LINUX_
+#if _SQUID_LINUX_
 
 /****************************************************************************
  *--------------------------------------------------------------------------*
@@ -9,7 +17,6 @@
  *--------------------------------------------------------------------------*
  ****************************************************************************/
 
-
 #if USE_ASYNC_IO
 #define _SQUID_LINUX_THREADS_
 #endif
 #define HAVE_RES_INIT  HAVE___RES_INIT
 #endif
 
+/*
+ * Netfilter header madness. (see Bug 4323)
+ *
+ * Netfilter have a history of defining their own versions of network protocol
+ * primitives without sufficient protection against the POSIX defines which are
+ * aways present in Linux.
+ *
+ * netinet/in.h must be included before any other sys header in order to properly
+ * activate include guards in <linux/libc-compat.h> the kernel maintainers added
+ * to workaround it.
+ */
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
 
 /*
  * sys/capability.h is only needed in Linux apparently.
@@ -40,6 +61,30 @@ typedef uint32_t __u32;
 #include <sys/capability.h>
 #endif /* HAVE_SYS_CAPABILITY_H */
 
+/*
+ * glob.h is provided by GNU on Linux and contains some unavoidable preprocessor
+ * logic errors in its 64-bit definitions which are hit by non-GCC compilers.
+ *
+ * #if __USE_FILE_OFFSET64 && __GNUC__ < 2
+ *  # define glob glob64
+ * #endif
+ * #if !defined __USE_FILE_OFFSET64 || __GNUC__ < 2
+ * extern "C" glob(...);
+ * #endif
+ * extern "C" glob64(...);
+ *
+ * ... and multiple "C" definitions of glob64 refuse to compile.
+ * Because __GNUC__ being undefined equates to 0 and (0 < 2)
+ */
+#if __USE_FILE_OFFSET64 && __GNUC__ < 2
+#if HAVE_GLOB_H
+#undef HAVE_GLOB_H
+#endif
+#if HAVE_GLOB
+#undef HAVE_GLOB
+#endif
+#endif
 
 #endif /* _SQUID_LINUX_ */
 #endif /* SQUID_OS_LINUX_H */
+