| [1253] | 1 | #ifndef MACHDEFS_SEEN | 
|---|
|  | 2 | #define MACHDEFS_SEEN | 
|---|
|  | 3 |  | 
|---|
|  | 4 | #include <config.h> | 
|---|
|  | 5 |  | 
|---|
|  | 6 | /***********************************************************************/ | 
|---|
|  | 7 | /* Find hardware, OS and compiler combination                          */ | 
|---|
|  | 8 | /***********************************************************************/ | 
|---|
|  | 9 |  | 
|---|
|  | 10 | #if defined(OSF1) | 
|---|
|  | 11 | #define MACH_ALPHA | 
|---|
|  | 12 | #define OS_OSF1 | 
|---|
|  | 13 | #endif | 
|---|
|  | 14 |  | 
|---|
|  | 15 | #if defined(_AIX) || defined(AIX) | 
|---|
|  | 16 | #define MACH_IBMRS | 
|---|
|  | 17 | #define OS_AIX | 
|---|
|  | 18 | #endif | 
|---|
|  | 19 |  | 
|---|
|  | 20 | #if defined(__hpux__) || defined(HPUX) | 
|---|
|  | 21 | #define MACH_HP | 
|---|
|  | 22 | #define OS_HPUX | 
|---|
|  | 23 | #endif | 
|---|
|  | 24 |  | 
|---|
|  | 25 | #ifdef __MWERKS__ | 
|---|
|  | 26 | #define MACH_POWERMAC | 
|---|
|  | 27 | #define OS_MACOS | 
|---|
|  | 28 | #endif | 
|---|
|  | 29 |  | 
|---|
|  | 30 | #if defined(SunOS)  || defined ( sun ) | 
|---|
|  | 31 | #define MACH_SUN | 
|---|
|  | 32 | #define OS_SOLARIS | 
|---|
|  | 33 | #endif | 
|---|
|  | 34 |  | 
|---|
|  | 35 | #ifdef IRIX64 | 
|---|
|  | 36 | #define MACH_SGI | 
|---|
|  | 37 | #define OS_IRIX64 | 
|---|
|  | 38 | #endif | 
|---|
|  | 39 |  | 
|---|
|  | 40 | #if defined(Linux)  || defined(linux) | 
|---|
|  | 41 | #if defined(__alpha__) | 
|---|
|  | 42 | #define MACH_ALPHA | 
|---|
|  | 43 | #elif defined(powerpc) | 
|---|
|  | 44 | #define MACH_POWERPC | 
|---|
|  | 45 | #elif defined(__i386__) | 
|---|
|  | 46 | #define MACH_INTEL | 
|---|
|  | 47 | #else | 
|---|
|  | 48 | #error Undefined Platform (machine) type with linux in machdefs.h | 
|---|
|  | 49 | #endif | 
|---|
|  | 50 | #define OS_LINUX | 
|---|
|  | 51 | #endif | 
|---|
|  | 52 |  | 
|---|
|  | 53 |  | 
|---|
|  | 54 | /***********************************************************************/ | 
|---|
|  | 55 | /* Hardware/OS dependent stuff                                         */ | 
|---|
|  | 56 | /***********************************************************************/ | 
|---|
|  | 57 |  | 
|---|
|  | 58 | typedef signed char int_1; | 
|---|
|  | 59 | typedef unsigned char uint_1; | 
|---|
|  | 60 |  | 
|---|
|  | 61 | #if (SIZEOF_SHORT == 2) | 
|---|
|  | 62 | typedef short int_2; | 
|---|
|  | 63 | typedef unsigned short uint_2; | 
|---|
|  | 64 | #elif (SIZEOF_INT == 2) | 
|---|
|  | 65 | typedef int int_2; | 
|---|
|  | 66 | typedef unsigned int uint_2; | 
|---|
|  | 67 | #else | 
|---|
|  | 68 | #error "no size 2 integer" | 
|---|
|  | 69 | #endif | 
|---|
|  | 70 |  | 
|---|
|  | 71 | #if (SIZEOF_INT == 4) | 
|---|
|  | 72 | typedef int int_4; | 
|---|
|  | 73 | typedef unsigned int uint_4; | 
|---|
|  | 74 | #elif (SIZEOF_LONG == 4) | 
|---|
|  | 75 | typedef long int_4; | 
|---|
|  | 76 | typedef unsigned long uint_4; | 
|---|
|  | 77 | #else | 
|---|
|  | 78 | #error "no size 4 integer" | 
|---|
|  | 79 | #endif | 
|---|
|  | 80 |  | 
|---|
|  | 81 | #if (SIZEOF_LONG_LONG == 8) | 
|---|
|  | 82 | typedef long long int_8; | 
|---|
|  | 83 | typedef unsigned long long uint_8; | 
|---|
|  | 84 | #elif (SIZEOF_LONG == 9) | 
|---|
|  | 85 | typedef long int_8; | 
|---|
|  | 86 | typedef unsigned long uint_8; | 
|---|
|  | 87 | #else | 
|---|
|  | 88 | #error "no size 8 integer" | 
|---|
|  | 89 | #endif | 
|---|
|  | 90 |  | 
|---|
|  | 91 |  | 
|---|
|  | 92 | #if (SIZEOF_FLOAT == 4) | 
|---|
|  | 93 | typedef float r_4; | 
|---|
|  | 94 | #else | 
|---|
|  | 95 | #error "no size 4 float" | 
|---|
|  | 96 | #endif | 
|---|
|  | 97 |  | 
|---|
|  | 98 | #if (SIZEOF_DOUBLE == 8) | 
|---|
|  | 99 | typedef double r_8; | 
|---|
|  | 100 | #else | 
|---|
|  | 101 | #error "no size 8 float" | 
|---|
|  | 102 | #endif | 
|---|
|  | 103 |  | 
|---|
|  | 104 | #ifdef WORDS_BIGENDIAN | 
|---|
|  | 105 | #define  SWAP 0 | 
|---|
|  | 106 | #define  SWAPDEFAUT 0 | 
|---|
|  | 107 | #define  IS_BIG_ENDIAN 1 | 
|---|
|  | 108 | #else | 
|---|
|  | 109 | #define  SWAP 1 | 
|---|
|  | 110 | #define  SWAPDEFAUT 1 | 
|---|
|  | 111 | #define  IS_BIG_ENDIAN 0 | 
|---|
|  | 112 | #endif | 
|---|
|  | 113 |  | 
|---|
|  | 114 |  | 
|---|
|  | 115 |  | 
|---|
|  | 116 |  | 
|---|
|  | 117 | /***********************************************************************/ | 
|---|
|  | 118 | /* Find Compiler                                                       */ | 
|---|
|  | 119 | /***********************************************************************/ | 
|---|
|  | 120 |  | 
|---|
|  | 121 | /*    __MWERKS__   : Metrowerks Codewarrior (>= PRO 4)                 */ | 
|---|
|  | 122 | /*    __DECCXX     : DEC CXX, version >= 6 is required                 */ | 
|---|
|  | 123 | /*    __GNUG__     : GNU C++ 2.8.1, egcs ??                            */ | 
|---|
|  | 124 | /*    __aCC__      : aCC on HP                                         */ | 
|---|
|  | 125 | /*    __KCC__      : KCC, version >= 3.3 is required                   */ | 
|---|
|  | 126 | /*    __SGICC__    : SGI (IRIX64) CC compiler                          */ | 
|---|
|  | 127 |  | 
|---|
|  | 128 | /***********************************************************************/ | 
|---|
|  | 129 | /* Compiler-specific stuff                                             */ | 
|---|
|  | 130 | /***********************************************************************/ | 
|---|
|  | 131 |  | 
|---|
|  | 132 | /* Some features will be *required* for Planck. Which ones ?               */ | 
|---|
|  | 133 |  | 
|---|
|  | 134 | /*   ANSI_TEMPLATES        : use ANSI syntax for explicit templates        */ | 
|---|
|  | 135 | /*   GNUG_TEMPLATES        : use GNU syntax for explicit templates         */ | 
|---|
|  | 136 | /*   PRAGMA_TEMPLATES      : use pragma template, a la cxx                 */ | 
|---|
|  | 137 | /*   COMPILER_EXCEPTIONS   : knows about exceptions  --- required ?        */ | 
|---|
|  | 138 | /*   STREAMPOS_IS_CLASS    : streampos is a real class                     */ | 
|---|
|  | 139 | /*   ITER_TAG              : use iter_tag for iterator qualifiers in STL   */ | 
|---|
|  | 140 | /*   NO_STRSTREAM          : does not have strstream                       */ | 
|---|
| [1889] | 141 | /*   NO_EXPLICIT           : does not know about explicit keyword          */ | 
|---|
| [1253] | 142 | /*   HAS_IOS_BIN                                                           */ | 
|---|
|  | 143 | /*   HAS_IOS_NOCREATE                                                      */ | 
|---|
|  | 144 | /*   HAS_VEC_NEW           : operator new[]                                */ | 
|---|
|  | 145 | /*   CC_HAS_RTTI_SUPPORT     has Run Time Type Identification support      */ | 
|---|
|  | 146 | /*   ANSI_IO               : rdbuf()->pubseekoff rather than seekg         */ | 
|---|
|  | 147 | /*   HAS_STR_NPOS          : has string::npos and not a global NPOS        */ | 
|---|
|  | 148 | /*   NO_IOS_COMPLEX        : does not have operator << defined for complex */ | 
|---|
|  | 149 |  | 
|---|
|  | 150 |  | 
|---|
|  | 151 | /* The following is true for most compilers */ | 
|---|
|  | 152 |  | 
|---|
|  | 153 | #ifndef HAS_VEC_NEW | 
|---|
|  | 154 | #define HAS_VEC_NEW | 
|---|
|  | 155 | #endif | 
|---|
|  | 156 |  | 
|---|
|  | 157 | #ifndef COMPILER_EXCEPTIONS | 
|---|
|  | 158 | #define COMPILER_EXCEPTIONS | 
|---|
|  | 159 | #endif | 
|---|
|  | 160 |  | 
|---|
|  | 161 | #ifndef  CC_HAS_RTTI_SUPPORT | 
|---|
|  | 162 | #define  CC_HAS_RTTI_SUPPORT | 
|---|
|  | 163 | #endif | 
|---|
|  | 164 |  | 
|---|
|  | 165 | /* now the specific things */ | 
|---|
|  | 166 |  | 
|---|
|  | 167 | #ifdef __MWERKS__ | 
|---|
|  | 168 | #define ANSI_TEMPLATES | 
|---|
|  | 169 | #undef  HAS_VEC_NEW | 
|---|
|  | 170 | #define NO_STRSTREAM | 
|---|
|  | 171 | //#define STREAMPOS_IS_CLASS | 
|---|
|  | 172 | #define ITER_TAG | 
|---|
|  | 173 | #define HAS_IOS_BIN | 
|---|
|  | 174 | #define HAS_IOS_NOCREATE | 
|---|
|  | 175 | #define HAS_STR_NPOS | 
|---|
|  | 176 | #endif | 
|---|
|  | 177 |  | 
|---|
|  | 178 | #ifdef __GNUG__ | 
|---|
|  | 179 | #define ANSI_TEMPLATES | 
|---|
|  | 180 | // #define GNU_TEMPLATES | 
|---|
|  | 181 | #define HAS_STR_NPOS | 
|---|
|  | 182 | #define HAS_IOS_BIN | 
|---|
|  | 183 | #define HAS_IOS_NOCREATE | 
|---|
|  | 184 | #endif | 
|---|
|  | 185 |  | 
|---|
|  | 186 | #ifdef __DECCXX | 
|---|
|  | 187 | #define HAS_STR_NPOS | 
|---|
|  | 188 | #define ITER_TAG | 
|---|
|  | 189 | #define __CXX_PRAGMA_TEMPLATES__ | 
|---|
|  | 190 | #define PRAGMA_TEMPLATES | 
|---|
|  | 191 | #endif | 
|---|
|  | 192 |  | 
|---|
|  | 193 | #if defined (__aCC__) | 
|---|
|  | 194 | #ifndef ANSI_TEMPLATES | 
|---|
|  | 195 | #define ANSI_TEMPLATES | 
|---|
|  | 196 | #endif | 
|---|
|  | 197 | #endif | 
|---|
|  | 198 |  | 
|---|
|  | 199 | #if defined(__KCC__) | 
|---|
|  | 200 | /* KCC V 3.2 ne compile pas  i/ostream s ; long p = s.tellg();  OK en  V 3.3 */ | 
|---|
|  | 201 | #define HAS_STR_NPOS | 
|---|
|  | 202 | #ifndef ANSI_TEMPLATES | 
|---|
|  | 203 | #define ANSI_TEMPLATES | 
|---|
|  | 204 | #endif | 
|---|
|  | 205 | #endif | 
|---|
|  | 206 |  | 
|---|
|  | 207 | #if defined(__SGICC__) | 
|---|
|  | 208 | #define HAS_STR_NPOS | 
|---|
|  | 209 | #ifndef ANSI_TEMPLATES | 
|---|
|  | 210 | #define ANSI_TEMPLATES | 
|---|
|  | 211 | #endif | 
|---|
|  | 212 | #endif | 
|---|
|  | 213 |  | 
|---|
|  | 214 | /* Get things has homogeneous as possible between compilers */ | 
|---|
|  | 215 |  | 
|---|
|  | 216 | #ifdef HAS_STR_NPOS | 
|---|
|  | 217 | #define NPOS string::npos | 
|---|
|  | 218 | #else | 
|---|
|  | 219 | #define NPOS (size_t)-1 | 
|---|
|  | 220 | #endif | 
|---|
|  | 221 |  | 
|---|
|  | 222 | #ifndef __GNUG__ | 
|---|
|  | 223 | #define __PRETTY_FUNCTION__ __FILE__ " __LINE__ " | 
|---|
|  | 224 | #ifndef __FUNCTION__ | 
|---|
|  | 225 | #define __FUNCTION__ __FILE__ " __LINE__ " | 
|---|
|  | 226 | #endif | 
|---|
|  | 227 | #ifndef __KCC__ | 
|---|
|  | 228 | #define __attribute__(_x_) | 
|---|
|  | 229 | #endif | 
|---|
|  | 230 | #endif | 
|---|
|  | 231 |  | 
|---|
| [1889] | 232 | #ifdef NO_EXPLICIT | 
|---|
| [1253] | 233 | #define explicit | 
|---|
|  | 234 | #endif | 
|---|
|  | 235 |  | 
|---|
|  | 236 | #ifdef HAS_IOS_BIN | 
|---|
|  | 237 | #define IOS_BIN ios::binary | 
|---|
|  | 238 | #else | 
|---|
|  | 239 | #define IOS_BIN 0 | 
|---|
|  | 240 | #endif | 
|---|
|  | 241 |  | 
|---|
|  | 242 | #ifdef ANSI_IO | 
|---|
|  | 243 | #define seekg(p_, m_) rdbuf()->pubseekoff(p_,m_) | 
|---|
|  | 244 | #define seekp(p_, m_) rdbuf()->pubseekoff(p_,m_) | 
|---|
|  | 245 | #endif | 
|---|
|  | 246 |  | 
|---|
|  | 247 | #ifdef __MWERKS__ | 
|---|
|  | 248 | //#define hypot(_x_,_y_) sqrt((_x_)*(_x_) + (_y_)*(_y_)) | 
|---|
|  | 249 | #define random() (rand()*65538.0 + rand()*2. + rand()) | 
|---|
|  | 250 | #define srandom srand | 
|---|
|  | 251 | #define initstate(seed, tab, n) srand(seed) | 
|---|
|  | 252 | #define nice(_x) | 
|---|
|  | 253 |  | 
|---|
|  | 254 | #ifdef __cplusplus | 
|---|
|  | 255 | #include <string.h> | 
|---|
|  | 256 | #include <string> | 
|---|
|  | 257 | inline bool operator< (string const& s1, string const& s2) | 
|---|
|  | 258 | { return (strcmp(s1.c_str(), s2.c_str()) < 0); } | 
|---|
|  | 259 | #endif | 
|---|
|  | 260 | #endif | 
|---|
|  | 261 |  | 
|---|
|  | 262 |  | 
|---|
|  | 263 | /********************************************************/ | 
|---|
|  | 264 | /* Outil d'impressions pour debug */ | 
|---|
|  | 265 | #define PR(_data_)  {cout<<" "<<#_data_<<" "<<_data_;} | 
|---|
|  | 266 | #define CR {cout<<"\n"<<flush;} | 
|---|
|  | 267 | /* ********************************************************/ | 
|---|
|  | 268 |  | 
|---|
|  | 269 | /* ---- Activation des flags de debug/bound checking  ----- */ | 
|---|
|  | 270 | #ifdef SOPHYA_DEBUG | 
|---|
|  | 271 | #define SO_BOUNDCHECKING | 
|---|
|  | 272 | #endif | 
|---|
|  | 273 |  | 
|---|
|  | 274 | /* ---- La taille et les index des tableaux ---- */ | 
|---|
| [1396] | 275 | #ifdef SGI_ARCH64 | 
|---|
|  | 276 | typedef int_8 sa_size_t ; | 
|---|
|  | 277 | #else | 
|---|
| [1253] | 278 | typedef int_4 sa_size_t ; | 
|---|
| [1396] | 279 | #endif | 
|---|
| [1253] | 280 |  | 
|---|
|  | 281 |  | 
|---|
|  | 282 | /* Compatibilite, avant de migrer tout le code en "PLANCK" */ | 
|---|
|  | 283 |  | 
|---|
|  | 284 | #ifdef __cplusplus | 
|---|
| [1870] | 285 | /* Standard C++ library classes are in the namespace std  */ | 
|---|
|  | 286 | namespace std { } | 
|---|
|  | 287 | using namespace std; | 
|---|
|  | 288 | /*  SOPHYA classes are in namespace SOPHYA  */ | 
|---|
| [1253] | 289 | namespace SOPHYA {} | 
|---|
|  | 290 | using namespace SOPHYA; | 
|---|
|  | 291 | #define EXPLICIT explicit | 
|---|
|  | 292 | #endif | 
|---|
|  | 293 |  | 
|---|
|  | 294 | #endif | 
|---|