Main Page   Namespace List   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

sysconfig.h

Go to the documentation of this file.
00001 
00014 #ifndef SYSCONFIG_H
00015 #define SYSCONFIG_H
00016 
00017 /* \def __BORLANDC__
00018  Manifest constant present in all Borland compilers that contains the
00019  compiler version number.  
00020  */
00021 
00022 /* \def __CYGWIN__
00023  Manifest constant present in cygwin compilers.
00024  */
00025 
00026 /* \def _MSC_VER
00027  Manifest constant present in all Microsoft Visual C compilers that
00028  contains the compiler version number.
00029  */
00030 
00044 #if ( defined (__WIN32__) || defined (_WIN32) ) && !defined (WIN32)
00045  #define WIN32 1
00046 #elif defined(__CYGWIN__)
00047  #define UNIX 1
00048 #endif
00049 
00050 #if !defined(UNIX) && !defined(WIN32) && !defined(__cplusplus)
00051  #error Unsupported compiler and/or operating system.
00052  #error Please update sysconfig.h with your compiler or OS information.
00053 #endif
00054 
00059 #ifdef WIN32
00060  #define WIN32_LEAN_AND_MEAN 1
00061 #endif
00062 
00063 // BC++ uses _MT which is a manifest constant picked by compiler options.
00064 // VC++ 6.0 compiler options by default are multi-threaded
00065 #ifdef UNIX
00066  #define _MULTI_THREADED
00067 #endif
00068 
00069 // Disable some noise and blather from VC++ compiler
00070 #ifdef _MSC_VER
00071  #pragma warning(disable:4786)  // names over 255 characters in templates
00072  #pragma warning(disable:4068)  // unknown pragma warnings
00073  #pragma warning(disable:4101)  // unreferenced variables
00074 #endif
00075 
00076 // C++ STL headers used
00077 #include <iostream>
00078 #include <fstream>
00079 #include <list>
00080 #include <queue>
00081 #include <string>
00082 #include <exception>
00083 // C++ wrappers for C stdlib functions
00084 #include <cstdio>
00085 #include <ctime>
00086 #if defined(WIN32) && defined(__BORLANDC__) 
00087  #include <cprocess>
00088 #endif
00089 
00094 using namespace std;
00095 
00096 #if defined(WIN32)
00097  #include <winsock2.h>
00098 #else
00099  #include <netinet/in.h>
00100  #include <sys/socket.h>
00101  #include <sys/ioctl.h>
00102 #endif
00103 
00104 // For threading - Borland has a cprocess header - see above
00105 #if defined(WIN32) && defined(_MSC_VER)
00106  #include <process.h>
00107 #endif
00108 
00109 // Additional headers required for Unix.
00110 #if defined(UNIX)
00111  #include <pthread.h>   // pthreads library
00112  #include <unistd.h>
00113  #include <stdarg.h>    // for variable arguments - used by Log
00114 #endif
00115 #pragma hdrstop
00116 
00117 /*
00118   This is a feeble attempt to minimize the changes to this code for
00119   Cygwin/Unix by making use of macros that disguise, hide, morph and
00120   otherwise obfuscate the code.  With the side effect of confusing
00121   programmers looking at it.  So I lied above when I said I'd be careful.
00122  */
00123 #if defined(WIN32)
00124  // Thread stuff
00125  typedef unsigned long THREADHANDLE_T;
00126  #define StartThread(T_HANDLE, FUNCTION, STACKSIZE, ARGS) \
00127    T_HANDLE = _beginthread((FUNCTION), (STACKSIZE), (ARGS));
00128 #elif defined(UNIX)
00129  // Network stuff
00130  typedef int SOCKET;
00131  #define INVALID_SOCKET -1  // Better look for side-effects with this! - 0 on Windows
00132  #define SOCKET_ERROR -1
00133  #define WSAEWOULDBLOCK EWOULDBLOCK  // Used in Server and Socket
00134  #define SD_SEND SHUT_WR             // Used in Server::Disconnect
00135  #define closesocket(X) close(X)
00136  #define WSAGetLastError(X) errno
00137  #define ioctlsocket(X,Y,Z) ioctl(X,Y,Z) 
00138  // Synchronization stuff
00139  #define InitializeCriticalSection(X) *(X) = PTHREAD_MUTEX_INITIALIZER;
00140  #define DeleteCriticalSection(X) 
00141  #define CRITICAL_SECTION pthread_mutex_t
00142  #define EnterCriticalSection(X)  pthread_mutex_lock(X);
00143  #define LeaveCriticalSection(X)  pthread_mutex_unlock(X);
00144 
00145  // Thread stuff
00146  typedef pthread_t THREADHANDLE_T;
00147  #define StartThread(T_HANDLE, FUNCTION, STACKSIZE, ARGS) \
00148    pthread_create(&(T_HANDLE), NULL, (FUNCTION), (ARGS));
00149  #define WaitForSingleObject(T_HANDLE, WAIT) \
00150    pthread_join(*(T_HANDLE), NULL)
00151 #endif
00152 
00153 #endif // SYSCONFIG_H

Generated on Mon Mar 29 23:12:53 2004 for Paradigm by doxygen1.2.17