From: <sv...@ww...> - 2005-12-30 03:27:37
|
Author: mkrose Date: 2005-12-29 19:27:24 -0800 (Thu, 29 Dec 2005) New Revision: 1809 Added: trunk/CSP/csp/csplib/util/undef.h Modified: trunk/CSP/csp/csplib/net/NetworkInterface.cpp trunk/CSP/csp/csplib/net/NetworkNode.h trunk/CSP/csp/csplib/net/Sockets.h trunk/CSP/csp/csplib/thread/AtomicCounter.h trunk/CSP/csp/csplib/thread/Synchronization.h trunk/CSP/csp/csplib/thread/Thread.h trunk/CSP/csp/csplib/util/LogConstants.h trunk/CSP/csp/csplib/util/Modules.cpp trunk/CSP/csp/csplib/util/Testing.cpp Log: Forcibly undefine symbols that external headers have dumped into the global namespace. These symbols are used as shorthand arguments to logging macros, but not directly defined in csplib. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1809 Modified: trunk/CSP/csp/csplib/net/NetworkInterface.cpp =================================================================== --- trunk/CSP/csp/csplib/net/NetworkInterface.cpp 2005-12-28 02:53:24 UTC (rev 1808) +++ trunk/CSP/csp/csplib/net/NetworkInterface.cpp 2005-12-30 03:27:24 UTC (rev 1809) @@ -41,18 +41,11 @@ #ifdef _WIN32 // use this to fix compile problems with mulitple includes of windows and winsock headers. #define _WINSOCKAPI_ -#define NOMINMAX #endif + #include <cc++/network.h> #include <cc++/thread.h> -#ifdef _WIN32 -# ifdef min -# undef min -# endif -# ifdef max -# undef max -# endif -#endif +#include <csp/csplib/util/undef.h> #include <string.h> #include <sys/types.h> Modified: trunk/CSP/csp/csplib/net/NetworkNode.h =================================================================== --- trunk/CSP/csp/csplib/net/NetworkNode.h 2005-12-28 02:53:24 UTC (rev 1808) +++ trunk/CSP/csp/csplib/net/NetworkNode.h 2005-12-30 03:27:24 UTC (rev 1809) @@ -31,21 +31,15 @@ #include <csp/csplib/util/Uniform.h> #ifdef _WIN32 -# define NOMINMAX # pragma warning(push) # pragma warning(disable: 4100 4996) #endif #include <cc++/socket.h> +#include <csp/csplib/util/undef.h> #ifdef _WIN32 # pragma warning(pop) -# ifdef min -# undef min -# endif -# ifdef max -# undef max -# endif #endif #include <string> Modified: trunk/CSP/csp/csplib/net/Sockets.h =================================================================== --- trunk/CSP/csp/csplib/net/Sockets.h 2005-12-28 02:53:24 UTC (rev 1808) +++ trunk/CSP/csp/csplib/net/Sockets.h 2005-12-30 03:27:24 UTC (rev 1809) @@ -28,21 +28,15 @@ #ifdef _WIN32 // use this to fix compile problems with mulitple includes of windows and winsock headers. # define _WINSOCKAPI_ -# define NOMINMAX # pragma warning(push) # pragma warning(disable: 4100) #endif #include <cc++/network.h> +#include <csp/csplib/util/undef.h> #ifdef _WIN32 # pragma warning(pop) -# ifdef min -# undef min -# endif -# ifdef max -# undef max -# endif #endif CSP_NAMESPACE Modified: trunk/CSP/csp/csplib/thread/AtomicCounter.h =================================================================== --- trunk/CSP/csp/csplib/thread/AtomicCounter.h 2005-12-28 02:53:24 UTC (rev 1808) +++ trunk/CSP/csp/csplib/thread/AtomicCounter.h 2005-12-30 03:27:24 UTC (rev 1809) @@ -31,10 +31,8 @@ #include <csp/csplib/util/Namespace.h> #include <csp/csplib/util/Properties.h> -#ifdef WIN32 -#define NOMINMAX -#endif #include <cc++/thread.h> +#include <csp/csplib/util/undef.h> CSP_NAMESPACE Modified: trunk/CSP/csp/csplib/thread/Synchronization.h =================================================================== --- trunk/CSP/csp/csplib/thread/Synchronization.h 2005-12-28 02:53:24 UTC (rev 1808) +++ trunk/CSP/csp/csplib/thread/Synchronization.h 2005-12-30 03:27:24 UTC (rev 1809) @@ -29,10 +29,9 @@ #include <csp/csplib/util/Namespace.h> #include <csp/csplib/util/Properties.h> -#ifdef WIN32 -#define NOMINMAX -#endif #include <cc++/thread.h> +#include <csp/csplib/util/undef.h> + #include <algorithm> #include <cerrno> #include <cmath> @@ -268,12 +267,9 @@ */ Semaphore(size_t count): m_semaphore(count) { } - /** Wait for an available resource, or until the specified timeout expires. - * - * @param timeout The maximum time (in seconds) to wait, or zero for no limit. - * @return true if a resource is available, false if the timeout expired first. + /** Wait for an available resource. */ - bool wait(double timeout=0) { return m_semaphore.wait(makeMilliTimeout(timeout)); } + void wait() { m_semaphore.wait(); } /** Release a resource so that other waiting threads can use it. Should only * be called after wait() has succeeded. Modified: trunk/CSP/csp/csplib/thread/Thread.h =================================================================== --- trunk/CSP/csp/csplib/thread/Thread.h 2005-12-28 02:53:24 UTC (rev 1808) +++ trunk/CSP/csp/csplib/thread/Thread.h 2005-12-30 03:27:24 UTC (rev 1809) @@ -33,10 +33,8 @@ #include <csp/csplib/thread/AtomicCounter.h> #include <csp/csplib/thread/Synchronization.h> -#ifdef WIN32 -#define NOMINMAX -#endif #include <cc++/thread.h> +#include <csp/csplib/util/undef.h> CSP_NAMESPACE Modified: trunk/CSP/csp/csplib/util/LogConstants.h =================================================================== --- trunk/CSP/csp/csplib/util/LogConstants.h 2005-12-28 02:53:24 UTC (rev 1808) +++ trunk/CSP/csp/csplib/util/LogConstants.h 2005-12-30 03:27:24 UTC (rev 1809) @@ -27,26 +27,6 @@ #include <csp/csplib/util/Namespace.h> -// the following symbols are used in the logging macros, so -// previous macro declarations must be deleted. note that we -// do *not* redefine these macros, the symbols are ## joined -// with cLogPriority_ to construct the priority constants below. -#ifdef DEBUG -#undef DEBUG -#endif -#ifdef INFO -#undef INFO -#endif -#ifdef WARNING -#undef WARNING -#endif -#ifdef ERROR -#undef ERROR -#endif -#ifdef FATAL -#undef FATAL -#endif - CSP_NAMESPACE /** Log message priorities @@ -73,14 +53,13 @@ cLogCategory_REGISTRY = 0x00000004, cLogCategory_THREAD = 0x00000008, cLogCategory_TIME = 0x00000010, - cLogCategory_FILE = 0x00000020, - cLogCategory_NETWORK = 0x00000040, - cLogCategory_AUDIO = 0x00000080, - cLogCategory_OPENGL = 0x00000100, - cLogCategory_INPUT = 0x00000200, - cLogCategory_NUMERIC = 0x00000400, - cLogCategory_PHYSICS = 0x00000400, // same as NUMERIC - cLogCategory_TESTING = 0x00000800, + cLogCategory_NETWORK = 0x00000020, + cLogCategory_AUDIO = 0x00000040, + cLogCategory_OPENGL = 0x00000080, + cLogCategory_INPUT = 0x00000100, + cLogCategory_NUMERIC = 0x00000200, + cLogCategory_PHYSICS = 0x00000200, // same as NUMERIC + cLogCategory_TESTING = 0x00000400, // net cLogCategory_TIMING = 0x00001000, Modified: trunk/CSP/csp/csplib/util/Modules.cpp =================================================================== --- trunk/CSP/csp/csplib/util/Modules.cpp 2005-12-28 02:53:24 UTC (rev 1808) +++ trunk/CSP/csp/csplib/util/Modules.cpp 2005-12-30 03:27:24 UTC (rev 1809) @@ -26,11 +26,9 @@ #include <csp/csplib/util/Ref.h> #include <csp/csplib/util/ScopedPointer.h> -#ifdef WIN32 -#define NOMINMAX -#endif -#include <cc++/file.h> #include <map> +#include <cc++/file.h> +#include <csp/csplib/util/undef.h> CSP_NAMESPACE Modified: trunk/CSP/csp/csplib/util/Testing.cpp =================================================================== --- trunk/CSP/csp/csplib/util/Testing.cpp 2005-12-28 02:53:24 UTC (rev 1808) +++ trunk/CSP/csp/csplib/util/Testing.cpp 2005-12-30 03:27:24 UTC (rev 1809) @@ -26,11 +26,9 @@ #include <csp/csplib/util/Testing.h> #include <csp/csplib/util/Timing.h> -#ifdef WIN32 -#define NOMINMAX -#endif -#include <cc++/file.h> #include <vector> +#include <cc++/file.h> +#include <csp/csplib/util/undef.h> CSP_NAMESPACE Added: trunk/CSP/csp/csplib/util/undef.h =================================================================== --- trunk/CSP/csp/csplib/util/undef.h 2005-12-28 02:53:24 UTC (rev 1808) +++ trunk/CSP/csp/csplib/util/undef.h 2005-12-30 03:27:24 UTC (rev 1809) @@ -0,0 +1,117 @@ +/** @file undef.h + * + * This header should be included immediately after including external + * headers that may define any of the symbols below as macros. + */ + +// the following symbols are used in the logging macros, so previous macro +// declarations must be deleted. note that csplib does *not* redefine these +// macros (see LogConstants.h for details). +#ifdef DEBUG +#undef DEBUG +#endif +#ifdef INFO +#undef INFO +#endif +#ifdef WARNING +#undef WARNING +#endif +#ifdef ERROR +#undef ERROR +#endif +#ifdef FATAL +#undef FATAL +#endif + +// logging categories (see LogConstants.h) +#ifdef DATA +#undef DATA +#endif +#ifdef ARCHIVE +#undef ARCHIVE +#endif +#ifdef REGISTRY +#undef REGISTRY +#endif +#ifdef THREAD +#undef THREAD +#endif +#ifdef TIME +#undef TIME +#endif +#ifdef NETWORK +#undef NETWORK +#endif +#ifdef AUDIO +#undef AUDIO +#endif +#ifdef OPENGL +#undef OPENGL +#endif +#ifdef INPUT +#undef INPUT +#endif +#ifdef NUMERIC +#undef NUMERIC +#endif +#ifdef PHYSICS +#undef PHYSICS +#endif +#ifdef TESTING +#undef TESTING +#endif +#ifdef TIMING +#undef TIMING +#endif +#ifdef HANDSHAKE +#undef HANDSHAKE +#endif +#ifdef BALANCING +#undef BALANCING +#endif +#ifdef PACKET +#undef PACKET +#endif +#ifdef PEER +#undef PEER +#endif +#ifdef MESSAGE +#undef MESSAGE +#endif +#ifdef TERRAIN +#undef TERRAIN +#endif +#ifdef SCENE +#undef SCENE +#endif +#ifdef BATTLEFIELD +#undef BATTLEFIELD +#endif +#ifdef OBJECT +#undef OBJECT +#endif +#ifdef APP +#undef APP +#endif +#ifdef VIEW +#undef VIEW +#endif +#ifdef THEATER +#undef THEATER +#endif +#ifdef NONE +#undef NONE +#endif +#ifdef ALL +#undef ALL +#endif + +// some external headers define min and max as macros. we use the standard +// inline functions (std::min and std::max) instead. +#ifdef min +#undef min +#endif +#ifdef max +#undef max +#endif + |