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