Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

platform.H

Go to the documentation of this file.
00001 
00002 //
00003 //
00004 // jot configuration file
00005 //
00006 // XXX - At some point, this should be replaced by autoconf
00007 //
00008 #ifndef PLATFORM_H_IS_INCLUDED
00009 #define PLATFORM_H_IS_INCLUDED
00010 
00011 #if defined(__GNUC__)
00012 
00013 #if (__GNUC__ > 3 || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 2 ))
00014 #define JOT_NEW_STYLE_IOSTREAM
00015 //#include <bits/stl_algobase.h>
00016 #define JOT_STDCPP_HEADER_ALGORITHM_INCLUDED
00017 #include <algorithm>
00018 using namespace std;
00019 
00020 #elif (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97))
00021 #define JOT_BACKWARD_IOSTREAM
00022 //#include <bits/stl_algobase.h>
00023 #define JOT_STDCPP_HEADER_ALGORITHM_INCLUDED
00024 #include <algorithm>
00025 using namespace std;
00026 
00027 #elif (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
00028 //#include <stl_algobase.h>
00029 #define JOT_STDCPP_HEADER_ALGORITHM_INCLUDED
00030 #include <algorithm>
00031 using namespace std;
00032 #endif 
00033 
00034 // _MSC_VER defines the version of the Microsoft Compiler.
00035 // 12xx = Visual Studio 6.0
00036 // 13xx = Visual Studio .Net
00037 #elif defined(WIN32)
00038 //#ifdef _MSC_VER
00039 //#if(_MSC_VER >= 1300)
00040 #define JOT_NEW_STYLE_IOSTREAM
00041 #include <ios>
00042 #define JOT_STDCPP_HEADER_ALGORITHM_INCLUDED
00043 #include <algorithm>
00044 using namespace std;
00045 //#endif
00046 //#endif
00047 #endif 
00048 
00049 
00050 
00051 //YYY - Moved here from geom/fsa.H (and fixed)
00052 #if (defined(__sgi) && !defined(__GNUC__) && defined(_STANDARD_C_PLUS_PLUS)) || defined(__VACPP_MULTI__)
00053 #define TYPENAME typename
00054 #elif (defined(__GNUC__) && (__GNUC__ > 3 || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 2 )))
00055 #define TYPENAME typename
00056 #elif (defined(WIN32) && defined(_MSC_VER) && (_MSC_VER >= 1300))
00057 #define TYPENAME typename
00058 #else
00059 #define TYPENAME
00060 #endif
00061 
00062 // Let us define 'bool' to look the same as the proposed standard C++ 
00063 // data type 'bool'. Try to avoid redefining it if some other header 
00064 // file already defined it.
00065 //
00066 #if !defined(true) && !defined(__GNUC__) && !defined(WIN32) && !defined(_ABIN32) && !defined(__VACPP_MULTI__)
00067 #if !defined(__SUNPRO_CC) || __SUNPRO_CC < 0x500
00068 #if !defined(sgi) || !defined(_BOOL)
00069 #if !defined(__KCC)
00070 typedef int bool;     
00071 const   int true  = 1;
00072 const   int false = 0;
00073 #endif
00074 #endif
00075 #endif
00076 #endif
00077 
00078 
00079 #ifdef WIN32
00080 #ifdef _MSC_VER
00081 #if (_MSC_VER <= 1200)
00082 #define NOMINMAX
00083 #endif
00084 #endif
00085 #include <windows.h>
00086 #include <winbase.h>    // findFirstFile, etc.
00087 #include <sys/types.h>  //need this...
00088 #include <sys/stat.h>   //    ...and this for for _stat
00089 #include <direct.h>     // for _chdir, _getcwd, _mkdir, _rmdir
00090 #include <cstdlib>      // for _splitpath
00091 #include <cstdio>       // for rename, remove
00092 #include <ctime>        // for strftime
00093 #include <climits>
00094 #include <cfloat>
00095 #include <cstring>
00096 #include <cerrno>
00097 #include <cctype>
00098 #include <cmath>
00099 #define strncasecmp _strnicmp
00100 inline double drand48() { return rand()/double(RAND_MAX); }
00101 inline void   srand48(long seed) { srand((unsigned int) seed); }
00102 inline long   lrand48() { return rand(); }
00103 #else
00104 #include <sys/types.h>  // need this...
00105 #include <sys/stat.h>   //    ...and this for for stat, mkdir
00106 #include <sys/time.h>   // for timezone, timeval, gettimeofday
00107 #include <unistd.h>     // for chdir, getcwd, rmdir     
00108 #include <dirent.h>     // for readdir
00109 #include <fnmatch.h>    // for fnmatch
00110 #include <termios.h>
00111 #include <cstdlib>
00112 #include <cstdio>       // for rename, remove
00113 #include <ctime>        // for strftime
00114 #include <climits>
00115 #include <cfloat>
00116 #include <cstring>
00117 #include <cerrno>
00118 #include <cstdarg>     // vsprintf, va_list, va_start, va_end
00119 #include <cctype>
00120 #include <cmath>
00121 #endif
00122 
00123 #if defined(__KCC) || defined(__GNUC__) || defined(sgi) || defined(WIN32) || defined(_AIX) || (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x500)
00124 // If return type is a nested class, make sure to return the fullly specified
00125 // type (ie, TexManip::ConsType, not ConsType)
00126 #define JOT_NEEDS_FULL_CLASS_TYPE
00127 #endif
00128 
00129 // For some reason makedepend defines __GNUC__, so we consider __GNUC__
00130 // set only if MAKE_DEPEND isn't
00131 
00132 #if defined(WIN32) || defined(_AIX) || (defined(__GNUC__) && !defined(MAKE_DEPEND))
00133 #define JOT_NEEDS_TEMPLATES_IN_H_FILE
00134 #endif
00135 
00136 
00137 #ifdef _AIX
00138 #define unix
00139 #endif
00140 
00141 #if defined(WIN32) || (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x500)
00142 #define JOT_AVOID_STATIC_LOCAL_INLINE_VAR
00143 #endif
00144 // Currently egcs++ can't handle a templated operator(double s, const T&)
00145 //#ifdef __GNUC__
00146 #define JOT_NEEDS_DOUBLE_STAR_EXPLICIT
00147 //#endif
00148 
00149 // Left-multiplication by scalars (for points and vectors, e.g.):
00150 #ifndef JOT_NEEDS_DOUBLE_STAR_EXPLICIT
00151 template <class T>
00152 inline T operator *(double s, const T &p) { return p * s; }
00153 #endif
00154 
00155 // Squaring:
00156 template <class T>
00157 inline T sqr(const T& x)                       { return x*x; }
00158 
00159 // Rounding:
00160 #if (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)))
00161 //#include <cmath>
00162 #else
00163 inline int round(double x) { return int(x + ((x<0) ? -0.5 : 0.5)); }
00164 #endif
00165 
00166 // Swap values:
00167 // XXX - hack!  This depends on knowing what symbols are defined when
00168 // stl_algobase.h is included
00169 // YYY - Added new symbol...
00170 //#if (!defined(_XUTILITY_) && !defined(ALGOBASE_H) && !defined(__SGI_STL_ALGOBASE_H) && !defined(__SGI_STL_INTERNAL_ALGO_H) && !defined(__SGI_STL_INTERNAL_ALGOBASE_H) && !defined(__GLIBCPP_INTERNAL_ALGOBASE_H) )
00171 //#if !(defined(JOT_NEW_STYLE_IOSTREAM) || defined(JOT_BACKWARD_IOSTREAM))
00172 #ifndef JOT_STDCPP_HEADER_ALGORITHM_INCLUDED
00173 template <class T>
00174 inline void swap(T &a, T &b)      { T c(a); a = b; b = c; }
00175 #endif
00176 
00177 // Define templated swap, min, & max methods, but only if they haven't
00178 // already been defined by STL
00179 // XXX - hack!  This depends on knowing what symbols are defined when
00180 // stl_algobase.h is included
00181 // YYY - Added new symbol...
00182 //#if  !defined(ALGOBASE_H) && !defined(__SGI_STL_ALGOBASE_H) && !defined(__SGI_STL_INTERNAL_ALGOBASE_H) && !defined(__GLIBCPP_INTERNAL_ALGOBASE_H) && !defined(_ALGORITHM_)
00183 //#if defined(WIN32) || !(defined(JOT_NEW_STYLE_IOSTREAM) || defined(JOT_BACKWARD_IOSTREAM))
00184 #ifndef JOT_STDCPP_HEADER_ALGORITHM_INCLUDED
00185 template <class T>
00186 inline T min(const T& a, const T& b)         { return a < b ? a : b; }
00187 template <class T>
00188 inline T max(const T& a, const T& b)         { return a > b ? a : b; }
00189 #endif
00190 
00191 // Clamp value a to range [b,c], where b < c:
00192 template <class T>
00193 inline T 
00194 clamp(const T& a, const T& b, const T& c) 
00195 {
00196    return (a > b) ? (a < c ? a : c) : b ; 
00197 }
00198 
00199 // Interpolate between values A and B with the given weight w
00200 // ranging from 0 to 1 as values range from A to B:
00201 template <class T>
00202 inline T 
00203 interp(const T& A, const T& B, double w) 
00204 {
00205    return A + (B - A)*w;
00206 }
00207 
00208 // Returns true if p lies in the interval [a,b]:
00209 template <class T>
00210 inline bool 
00211 in_interval(const T& p, const T& a, const T& b) 
00212 {
00213    return (p >= a && p <= b); 
00214 }
00215 
00216 // Returns the sign of a number as follows:
00217 //       non-negative: return  1
00218 //           negative: return -1
00219 inline int  
00220 Sign(double a) { return (a >= 0) ? 1 : -1; }
00221 
00222 // Returns the sign of a number as follows:
00223 //           positive: return  1
00224 //               zero: return  0
00225 //           negative: return -1
00226 inline int  
00227 Sign2(double a) { return (a > 0) ? 1 : (a < 0) ? -1 : 0; }
00228 
00229 inline bool 
00230 XOR(bool x, bool y)
00231 {
00232    return (x && !y) || (!x && y);
00233 }
00234 
00235 #if (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x510)
00236 #define JOT_NEW_STYLE_IOSTREAM
00237 #endif
00238 
00239 #if defined(__PGI)
00240 #define JOT_NEW_STYLE_IOSTREAM
00241 #define JOT_AVOID_STATIC_LOCAL_INLINE_VAR
00242 #endif
00243 
00244 #endif // CONFIG_H_IS_INCLUDED
00245 
00246 /* end of file platform.H */

Generated on Mon Sep 18 11:39:32 2006 for jot by  doxygen 1.4.4