From: Amos Jeffries Date: Sun, 3 May 2009 13:02:50 +0000 (-0600) Subject: Wrap C++ headers. Fixes define clash with libcompat X-Git-Tag: SQUID_3_2_0_1~1024 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=27e059d4426e9fd776b4e5527df21df9bed9e1d7;p=thirdparty%2Fsquid.git Wrap C++ headers. Fixes define clash with libcompat ostream and family were including sys/types.h which causes FD_SET rediefinition with libcompat at times. Current autoconf allows these headers to be wrapped and config.h included before to prevent this and other things. --- diff --git a/configure.in b/configure.in index 7cf82cf153..101ceb5e49 100644 --- a/configure.in +++ b/configure.in @@ -2250,10 +2250,12 @@ AC_HEADER_DIRENT AC_HEADER_STDC AC_CHECK_HEADERS( \ + aio.h \ arpa/inet.h \ arpa/nameser.h \ assert.h \ bstring.h \ + cassert \ crypt.h \ ctype.h \ errno.h \ @@ -2264,6 +2266,9 @@ AC_CHECK_HEADERS( \ glob.h \ gnumalloc.h \ grp.h \ + iosfwd \ + iomanip \ + iostream \ ip_compat.h \ ip_fil_compat.h \ ip_fil.h \ @@ -2285,6 +2290,7 @@ AC_CHECK_HEADERS( \ openssl/ssl.h \ netinet/tcp.h \ openssl/engine.h \ + ostream \ paths.h \ poll.h \ pwd.h \ @@ -2292,10 +2298,13 @@ AC_CHECK_HEADERS( \ regex.h \ sched.h \ signal.h \ + sstream \ stdarg.h \ stddef.h \ + stdexcept \ stdio.h \ stdlib.h \ + string \ string.h \ strings.h \ sys/bitypes.h \ diff --git a/include/Range.h b/include/Range.h index e23c947d68..7e89171dd2 100644 --- a/include/Range.h +++ b/include/Range.h @@ -1,4 +1,3 @@ - /* * $Id$ * @@ -34,13 +33,18 @@ #ifndef SQUID_RANGE_H #define SQUID_RANGE_H +#include "config.h" + +#if HAVE_IOSFWD #include +#endif +#if HAVE_OSTREAM #include +#endif /* represents [start, end) */ template - class Range { diff --git a/include/RefCount.h b/include/RefCount.h index 3d83d1ab39..527ae4ff6b 100644 --- a/include/RefCount.h +++ b/include/RefCount.h @@ -1,4 +1,3 @@ - /* * $Id$ * @@ -36,10 +35,13 @@ #ifndef _SQUID_REFCOUNT_H_ #define _SQUID_REFCOUNT_H_ +#include "config.h" + +#if HAVE_IOSTREAM #include +#endif template - class RefCount { diff --git a/lib/libTrie/test/trie.cc b/lib/libTrie/test/trie.cc index 8e6924b600..468f6a2897 100644 --- a/lib/libTrie/test/trie.cc +++ b/lib/libTrie/test/trie.cc @@ -19,7 +19,10 @@ #include "Trie.h" #include "TrieCharTransform.h" + +#if HAVE_IOSTREAM #include +#endif bool CaseSensitiveCheck() diff --git a/src/Debug.h b/src/Debug.h index a4f1fcf21e..6e4c13c64d 100644 --- a/src/Debug.h +++ b/src/Debug.h @@ -34,13 +34,23 @@ #ifndef SQUID_DEBUG_H #define SQUID_DEBUG_H +#include "config.h" + +#if HAVE_IOSTREAM #include +#endif + #undef assert +#if HAVE_SSTREAM #include +#endif +#if HAVE_IOMANIP #include -#if defined assert +#endif +#if defined(assert) #undef assert #endif + #if PURIFY #define assert(EX) ((void)0) #elif defined(NODEBUG) diff --git a/src/DiskIO/AIO/async_io.h b/src/DiskIO/AIO/async_io.h index f2c1f45cfa..7bd92fcd9e 100644 --- a/src/DiskIO/AIO/async_io.h +++ b/src/DiskIO/AIO/async_io.h @@ -1,11 +1,15 @@ #ifndef __ASYNC_IO_H__ #define __ASYNC_IO_H__ +#include "config.h" + #ifdef _SQUID_WIN32_ #include "aio_win32.h" #else +#if HAVE_AIO_H #include #endif +#endif /* for FREE* */ #include "typedefs.h" diff --git a/src/Generic.h b/src/Generic.h index 18d6801767..69aefcb06a 100644 --- a/src/Generic.h +++ b/src/Generic.h @@ -32,11 +32,12 @@ #ifndef SQUID_GENERIC_H #define SQUID_GENERIC_H -/** \todo CLEANUP: checks towrap this header properly */ -#include - #include "dlink.h" +#if HAVE_OSTREAM +#include +#endif + template struct unary_function { typedef _Arg argument_type; diff --git a/src/Mem.h b/src/Mem.h index 89ddcb6760..d1401f1ae4 100644 --- a/src/Mem.h +++ b/src/Mem.h @@ -34,13 +34,16 @@ #ifndef SQUID_MEM #define SQUID_MEM +#include "config.h" + +#if HAVE_OSTREAM +#include +#endif + class StoreEntry; class MemPoolStats; class MemPoolMeter; -/** \todo CLEANUP: protection to wrap this system include */ -#include - class Mem { diff --git a/src/SquidString.h b/src/SquidString.h index f3aa7d4a3b..657cd7dfcc 100644 --- a/src/SquidString.h +++ b/src/SquidString.h @@ -37,8 +37,9 @@ #include "config.h" -/** todo checks to wrap this include properly */ +#if HAVE_OSTREAM #include +#endif /* squid string placeholder (for printf) */ #ifndef SQUIDSTRINGPH diff --git a/src/Store.h b/src/Store.h index 833d4cc7f8..fde6afcb33 100644 --- a/src/Store.h +++ b/src/Store.h @@ -38,10 +38,6 @@ */ #include "squid.h" - -/// \todo protect the 'ostream' file includes via configure file tests as per squid conventions. -#include - #include "StoreIOBuffer.h" #include "Range.h" #include "RefCount.h" @@ -53,6 +49,11 @@ #include "esi/Element.h" #endif +#if HAVE_OSTREAM +#include +#endif + + class AsyncCall; class StoreClient; class MemObject; diff --git a/src/StoreEntryStream.h b/src/StoreEntryStream.h index db929cf736..fb9b715759 100644 --- a/src/StoreEntryStream.h +++ b/src/StoreEntryStream.h @@ -1,4 +1,3 @@ - /* * $Id$ * @@ -36,7 +35,9 @@ #include "Store.h" +#if HAVE_OSTREAM #include +#endif /* * This class provides a streambuf interface for writing diff --git a/src/fs/ufs/store_dir_ufs.cc b/src/fs/ufs/store_dir_ufs.cc index 062a81b00f..3273547d4e 100644 --- a/src/fs/ufs/store_dir_ufs.cc +++ b/src/fs/ufs/store_dir_ufs.cc @@ -43,8 +43,8 @@ #include "DiskIO/DiskIOModule.h" #include "Parsing.h" #include "SquidTime.h" - #include "SwapDir.h" + int UFSSwapDir::NumberOfUFSDirs = 0; int *UFSSwapDir::UFSDirToGlobalDirMapping = NULL; diff --git a/src/ip/IpAddress.h b/src/ip/IpAddress.h index 94507c5581..54b5fe040f 100644 --- a/src/ip/IpAddress.h +++ b/src/ip/IpAddress.h @@ -59,9 +59,12 @@ #include #endif +#if HAVE_IOSFWD #include +#endif +#if HAVE_OSTREAM #include - +#endif /* FreeBSD hack: * This OS has at least one version that defines these as private diff --git a/src/ip/testIpAddress.cc b/src/ip/testIpAddress.cc index 8743519541..67c6670548 100644 --- a/src/ip/testIpAddress.cc +++ b/src/ip/testIpAddress.cc @@ -1,14 +1,26 @@ #include "config.h" +#include "testIpAddress.h" +#include "ip/IpAddress.h" -#include +#if HAVE_CSTRING #include +#endif +#if HAVE_NETINET_IN_H #include +#endif +#if HAVE_ARPA_INET_H #include +#endif +#if HAVE_NETDB_H #include +#endif +#if HAVE_STRING #include +#endif +#if HAVE_STDEXCEPT +#include +#endif -#include "testIpAddress.h" -#include "ip/IpAddress.h" CPPUNIT_TEST_SUITE_REGISTRATION( testIpAddress ); diff --git a/src/mem.cc b/src/mem.cc index 34c462c547..334304506b 100644 --- a/src/mem.cc +++ b/src/mem.cc @@ -33,10 +33,6 @@ */ #include "squid.h" - -#include -#include - #include "event.h" #include "CacheManager.h" #include "ClientInfo.h" @@ -47,6 +43,13 @@ #include "MemBuf.h" #include "SquidTime.h" +#if HAVE_IOMANIP +#include +#endif +#if HAVE_OSTREAM +#include +#endif + /* module globals */ /* local prototypes */ diff --git a/src/tests/testACLMaxUserIP.cc b/src/tests/testACLMaxUserIP.cc index bd286da28d..97a4c80729 100644 --- a/src/tests/testACLMaxUserIP.cc +++ b/src/tests/testACLMaxUserIP.cc @@ -1,11 +1,13 @@ #define SQUID_UNIT_TEST 1 #include "squid.h" -#include - #include "testACLMaxUserIP.h" #include "auth/AclMaxUserIp.h" +#if HAVE_STDEXCEPT +#include +#endif + CPPUNIT_TEST_SUITE_REGISTRATION( testACLMaxUserIP ); diff --git a/src/tests/testAuth.cc b/src/tests/testAuth.cc index dd20e4a718..161bd0aa9d 100644 --- a/src/tests/testAuth.cc +++ b/src/tests/testAuth.cc @@ -161,7 +161,9 @@ testAuthConfig::create() } } +#if HAVE_IOSTREAM #include +#endif /* AuthUserRequest::scheme returns the correct scheme for all * authentication types diff --git a/src/tests/testBoilerplate.cc b/src/tests/testBoilerplate.cc index 59559fe0f5..8d7d2d39cd 100644 --- a/src/tests/testBoilerplate.cc +++ b/src/tests/testBoilerplate.cc @@ -1,10 +1,12 @@ #define SQUID_UNIT_TEST 1 #include "squid.h" -#include - #include "testBoilerplate.h" +#if HAVE_STDEXCEPT +#include +#endif + CPPUNIT_TEST_SUITE_REGISTRATION( testBoilerplate ); diff --git a/src/tests/testCoss.cc b/src/tests/testCoss.cc index 925bb54997..4d3adb8e62 100644 --- a/src/tests/testCoss.cc +++ b/src/tests/testCoss.cc @@ -1,6 +1,4 @@ #include "squid.h" -#include - #include "testCoss.h" #include "Store.h" #include "SwapDir.h" @@ -14,6 +12,10 @@ #include "StoreFileSystem.h" #include "testStoreSupport.h" +#if HAVE_STDEXCEPT +#include +#endif + #define TESTDIR "testCoss__testCossSearch" CPPUNIT_TEST_SUITE_REGISTRATION( testCoss ); diff --git a/src/tests/testDiskIO.cc b/src/tests/testDiskIO.cc index 4e9688f708..4c5b4cdcea 100644 --- a/src/tests/testDiskIO.cc +++ b/src/tests/testDiskIO.cc @@ -1,8 +1,6 @@ #define SQUID_UNIT_TEST 1 #include "squid.h" -#include - #include "testDiskIO.h" #include "Store.h" #include "SwapDir.h" @@ -18,6 +16,10 @@ #include "StoreFileSystem.h" #include "testStoreSupport.h" +#if HAVE_STDEXCEPT +#include +#endif + CPPUNIT_TEST_SUITE_REGISTRATION( testDiskIO ); void diff --git a/src/tests/testHttpRequestMethod.cc b/src/tests/testHttpRequestMethod.cc index 6c113dabf1..57c4e819c8 100644 --- a/src/tests/testHttpRequestMethod.cc +++ b/src/tests/testHttpRequestMethod.cc @@ -1,13 +1,15 @@ #define SQUID_UNIT_TEST 1 #include "squid.h" -#include #include #include "Mem.h" #include "testHttpRequestMethod.h" #include "HttpRequestMethod.h" +#if HAVE_SSTREAM +#include +#endif CPPUNIT_TEST_SUITE_REGISTRATION( testHttpRequestMethod ); diff --git a/src/tests/testNull.cc b/src/tests/testNull.cc index f2d04a3afd..b2b4694c99 100644 --- a/src/tests/testNull.cc +++ b/src/tests/testNull.cc @@ -1,6 +1,4 @@ #include "squid.h" -#include - #include "testNull.h" #include "Store.h" #include "SwapDir.h" @@ -14,6 +12,10 @@ #include "StoreFileSystem.h" #include "testStoreSupport.h" +#if HAVE_STDEXCEPT +#include +#endif + #define TESTDIR "testNull__testNullSearch" CPPUNIT_TEST_SUITE_REGISTRATION( testNull ); diff --git a/src/tests/testStoreEntryStream.cc b/src/tests/testStoreEntryStream.cc index ed07fabc43..4b0abdc4b2 100644 --- a/src/tests/testStoreEntryStream.cc +++ b/src/tests/testStoreEntryStream.cc @@ -8,7 +8,9 @@ #include "Store.h" #include "StoreEntryStream.h" +#if HAVE_IOMANIP #include +#endif #include diff --git a/src/tests/testURL.cc b/src/tests/testURL.cc index eb04c532d1..fbf7edcd21 100644 --- a/src/tests/testURL.cc +++ b/src/tests/testURL.cc @@ -1,12 +1,15 @@ #include "config.h" -#include #include #include "testURL.h" #include "URL.h" #include "Mem.h" +#if HAVE_SSTREAM +#include +#endif + CPPUNIT_TEST_SUITE_REGISTRATION( testURL ); /* stub functions to link successfully */ diff --git a/src/tests/testURLScheme.cc b/src/tests/testURLScheme.cc index c18bfaad52..eebcbcd27d 100644 --- a/src/tests/testURLScheme.cc +++ b/src/tests/testURLScheme.cc @@ -1,13 +1,16 @@ #define SQUID_UNIT_TEST 1 #include "squid.h" -#include + #include #include "Mem.h" #include "testURLScheme.h" #include "URLScheme.h" +#if HAVE_SSTREAM +#include +#endif CPPUNIT_TEST_SUITE_REGISTRATION( testURLScheme ); diff --git a/src/tests/testUfs.cc b/src/tests/testUfs.cc index 58ee2e3429..99efc93dc1 100644 --- a/src/tests/testUfs.cc +++ b/src/tests/testUfs.cc @@ -1,7 +1,4 @@ #include "config.h" - -#include - #include "testUfs.h" #include "Store.h" #include "SwapDir.h" @@ -13,6 +10,10 @@ #include "HttpReply.h" #include "testStoreSupport.h" +#if HAVE_STDEXCEPT +#include +#endif + #define TESTDIR "testUfs__testUfsSearch" CPPUNIT_TEST_SUITE_REGISTRATION( testUfs ); diff --git a/src/ufsdump.cc b/src/ufsdump.cc index 457dc76e65..e65e93234d 100644 --- a/src/ufsdump.cc +++ b/src/ufsdump.cc @@ -40,9 +40,16 @@ #include "Generic.h" #undef malloc #undef free + +#if HAVE_STDEXCEPT #include +#endif +#if HAVE_IOSTREAM #include +#endif +#if HAVE_CASSERT #include +#endif /* stub functions for parts of squid not factored to be dynamic yet */ void diff --git a/test-suite/MemPoolTest.cc b/test-suite/MemPoolTest.cc index 5b42a59fe9..bafb2891de 100644 --- a/test-suite/MemPoolTest.cc +++ b/test-suite/MemPoolTest.cc @@ -34,7 +34,10 @@ #include "squid.h" #include "MemPool.h" + +#if HAVE_IOSTREAM #include +#endif /* TODO: put this in a libTest */ void diff --git a/test-suite/VirtualDeleteOperator.cc b/test-suite/VirtualDeleteOperator.cc index 7aa5eb2e03..51db1e6c0f 100644 --- a/test-suite/VirtualDeleteOperator.cc +++ b/test-suite/VirtualDeleteOperator.cc @@ -34,7 +34,10 @@ */ #include "squid.h" + +#if HAVE_IOSTREAM #include +#endif class CallCounter { diff --git a/test-suite/debug.cc b/test-suite/debug.cc index 023d471510..02f5b08a6b 100644 --- a/test-suite/debug.cc +++ b/test-suite/debug.cc @@ -37,7 +37,6 @@ #include "squid.h" #include "stmem.h" #include "mem_node.h" -#include class StreamTest { diff --git a/test-suite/mem_hdr_test.cc b/test-suite/mem_hdr_test.cc index b553329517..98b8a7f6f7 100644 --- a/test-suite/mem_hdr_test.cc +++ b/test-suite/mem_hdr_test.cc @@ -37,9 +37,12 @@ #include "squid.h" #include "stmem.h" #include "mem_node.h" -#include #include "Generic.h" +#if HAVE_IOSTREAM +#include +#endif + void testLowAndHigh() { diff --git a/test-suite/mem_node_test.cc b/test-suite/mem_node_test.cc index 5ad25d2534..f1d3a5b31b 100644 --- a/test-suite/mem_node_test.cc +++ b/test-suite/mem_node_test.cc @@ -35,7 +35,10 @@ #include "squid.h" #include "mem_node.h" + +#if HAVE_IOSTREAM #include +#endif /* TODO: put this in a libTest */ void diff --git a/test-suite/syntheticoperators.cc b/test-suite/syntheticoperators.cc index 3f1baadbc7..dbdebd4e6d 100644 --- a/test-suite/syntheticoperators.cc +++ b/test-suite/syntheticoperators.cc @@ -36,7 +36,10 @@ #include "squid.h" #include "stmem.h" #include "mem_node.h" + +#if HAVE_IOSTREAM #include +#endif class HasExplicit { diff --git a/test-suite/test_tools.cc b/test-suite/test_tools.cc index 50f0e5df5d..4ebcf4b94d 100644 --- a/test-suite/test_tools.cc +++ b/test-suite/test_tools.cc @@ -7,12 +7,11 @@ #define _SQUID_EXTERNNEW_ #include "squid.h" -#include -#include /* AYJ: the debug stuff here should really be in a stub_debug.cc file for tests to link */ /* for correct pre-definitions of debug objects */ +/* and stream headers */ #include "Debug.h" FILE *debug_log = NULL;