[1261] | 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 |
|
---|
[1783] | 38 | #ifdef __APPLE__
|
---|
| 39 | #ifdef __MACH__
|
---|
[3070] | 40 | #ifdef __POWERPC__
|
---|
[1783] | 41 | #define MACH_POWERPC
|
---|
[3070] | 42 | #else
|
---|
| 43 | #define MACH_INTEL
|
---|
| 44 | #endif
|
---|
[1783] | 45 | #define OS_MACOSX
|
---|
| 46 | #endif
|
---|
| 47 | #endif
|
---|
| 48 |
|
---|
[1261] | 49 | #if defined(Linux) || defined(linux)
|
---|
| 50 | #if defined(__alpha__)
|
---|
| 51 | #define MACH_ALPHA
|
---|
| 52 | #elif defined(powerpc)
|
---|
| 53 | #define MACH_POWERPC
|
---|
| 54 | #elif defined(__i386__)
|
---|
| 55 | #define MACH_INTEL
|
---|
| 56 | #else
|
---|
| 57 | #error Undefined Platform (machine) type with linux in machdefs.h
|
---|
| 58 | #endif
|
---|
| 59 | #define OS_LINUX
|
---|
| 60 | #endif
|
---|
| 61 |
|
---|
| 62 |
|
---|
| 63 | /***********************************************************************/
|
---|
| 64 | /* Hardware/OS dependent stuff */
|
---|
| 65 | /***********************************************************************/
|
---|
| 66 |
|
---|
| 67 | #if defined(OS_OSF1)
|
---|
| 68 |
|
---|
| 69 | typedef signed char int_1;
|
---|
| 70 | typedef unsigned char uint_1;
|
---|
| 71 | typedef int int_4;
|
---|
| 72 | typedef unsigned int uint_4;
|
---|
| 73 | typedef short int_2;
|
---|
| 74 | typedef unsigned short uint_2;
|
---|
| 75 | typedef float r_4;
|
---|
| 76 | typedef double r_8;
|
---|
| 77 | typedef long long int_8;
|
---|
| 78 | typedef unsigned long long uint_8;
|
---|
| 79 |
|
---|
| 80 | #define SWAP 1
|
---|
| 81 | #define SWAPDEFAUT 1
|
---|
| 82 |
|
---|
| 83 | #elif defined(OS_HPUX)
|
---|
| 84 |
|
---|
| 85 | typedef signed char int_1;
|
---|
| 86 | typedef unsigned char uint_1;
|
---|
| 87 | typedef int int_4 ;
|
---|
| 88 | typedef unsigned int uint_4;
|
---|
| 89 | typedef short int_2;
|
---|
| 90 | typedef unsigned short uint_2;
|
---|
| 91 | typedef float r_4;
|
---|
| 92 | typedef double r_8;
|
---|
| 93 | typedef long long int_8;
|
---|
| 94 | typedef unsigned long long uint_8;
|
---|
| 95 |
|
---|
| 96 | #define SWAP 0
|
---|
| 97 | #define SWAPDEFAUT 0
|
---|
| 98 |
|
---|
| 99 |
|
---|
| 100 | #elif defined( OS_AIX )
|
---|
| 101 |
|
---|
| 102 | typedef signed char int_1;
|
---|
| 103 | typedef unsigned char uint_1;
|
---|
| 104 | typedef int int_4;
|
---|
| 105 | typedef unsigned int uint_4;
|
---|
| 106 | typedef short int_2;
|
---|
| 107 | typedef unsigned short uint_2;
|
---|
| 108 | typedef float r_4;
|
---|
| 109 | typedef double r_8;
|
---|
| 110 | typedef long long int_8;
|
---|
| 111 | typedef unsigned long long uint_8;
|
---|
| 112 |
|
---|
| 113 | #define SWAP 0
|
---|
| 114 | #define SWAPDEFAUT 0
|
---|
| 115 |
|
---|
| 116 | /* Check for solaris on intel... */
|
---|
| 117 | #elif defined( OS_SOLARIS ) && defined( MACH_SUN )
|
---|
| 118 |
|
---|
| 119 | typedef signed char int_1;
|
---|
| 120 | typedef unsigned char uint_1;
|
---|
| 121 | typedef int int_4;
|
---|
| 122 | typedef unsigned int uint_4;
|
---|
| 123 | typedef short int_2;
|
---|
| 124 | typedef unsigned short uint_2;
|
---|
| 125 | typedef float r_4;
|
---|
| 126 | typedef double r_8;
|
---|
| 127 | typedef long long int_8;
|
---|
| 128 | typedef unsigned long long uint_8;
|
---|
| 129 |
|
---|
| 130 | #define SWAP 0
|
---|
| 131 | #define SWAPDEFAUT 0
|
---|
| 132 |
|
---|
| 133 | #elif defined( OS_IRIX64 )
|
---|
| 134 |
|
---|
| 135 | typedef signed char int_1;
|
---|
| 136 | typedef unsigned char uint_1;
|
---|
| 137 | typedef int int_4;
|
---|
| 138 | typedef unsigned int uint_4;
|
---|
| 139 | typedef short int_2;
|
---|
| 140 | typedef unsigned short uint_2;
|
---|
| 141 | typedef float r_4;
|
---|
| 142 | typedef double r_8;
|
---|
| 143 | typedef long long int_8;
|
---|
| 144 | typedef unsigned long long uint_8;
|
---|
| 145 |
|
---|
| 146 | #define SWAP 0
|
---|
| 147 | #define SWAPDEFAUT 0
|
---|
| 148 |
|
---|
| 149 | /* Check linux on other machines than Intel */
|
---|
| 150 | #elif defined(OS_LINUX)
|
---|
| 151 | /* Sizes OK for PowerPC, Alpha, Intel */
|
---|
| 152 | /* On Alpha, long is 8 bytes */
|
---|
| 153 | typedef signed char int_1;
|
---|
| 154 | typedef unsigned char uint_1;
|
---|
| 155 | typedef int int_4;
|
---|
| 156 | typedef unsigned int uint_4;
|
---|
| 157 | typedef short int_2;
|
---|
| 158 | typedef unsigned short uint_2;
|
---|
| 159 | typedef float r_4;
|
---|
| 160 | typedef double r_8;
|
---|
| 161 | typedef long long int_8;
|
---|
| 162 | typedef unsigned long long uint_8;
|
---|
| 163 |
|
---|
| 164 | #if defined(powerpc) || (__alpha__)
|
---|
| 165 | #define SWAP 0
|
---|
| 166 | #define SWAPDEFAUT 0
|
---|
| 167 | #else
|
---|
| 168 | #define SWAP 1
|
---|
| 169 | #define SWAPDEFAUT 1
|
---|
| 170 | #endif
|
---|
| 171 |
|
---|
| 172 | #elif defined(OS_MACOS)
|
---|
| 173 |
|
---|
| 174 | typedef signed char int_1;
|
---|
| 175 | typedef unsigned char uint_1;
|
---|
| 176 | typedef long int_4;
|
---|
| 177 | typedef unsigned long uint_4;
|
---|
| 178 | typedef short int_2;
|
---|
| 179 | typedef unsigned short uint_2;
|
---|
| 180 | typedef float r_4;
|
---|
| 181 | typedef double r_8;
|
---|
| 182 | typedef long long int_8;
|
---|
| 183 | typedef unsigned long long uint_8;
|
---|
| 184 |
|
---|
| 185 | #define SWAP 0
|
---|
| 186 | #define SWAPDEFAUT 0
|
---|
| 187 |
|
---|
[1783] | 188 | #elif defined(OS_MACOSX)
|
---|
| 189 |
|
---|
| 190 | typedef signed char int_1;
|
---|
| 191 | typedef unsigned char uint_1;
|
---|
| 192 | typedef int int_4;
|
---|
| 193 | typedef unsigned int uint_4;
|
---|
| 194 | typedef short int_2;
|
---|
| 195 | typedef unsigned short uint_2;
|
---|
| 196 | typedef float r_4;
|
---|
| 197 | typedef double r_8;
|
---|
| 198 | typedef long long int_8;
|
---|
| 199 | typedef unsigned long long uint_8;
|
---|
| 200 |
|
---|
[3070] | 201 | #ifdef MACH_POWERPC
|
---|
[1783] | 202 | #define SWAP 0
|
---|
| 203 | #define SWAPDEFAUT 0
|
---|
[3070] | 204 | #else
|
---|
| 205 | #define SWAP 1
|
---|
| 206 | #define SWAPDEFAUT 1
|
---|
| 207 | #endif
|
---|
[1783] | 208 |
|
---|
[1261] | 209 | #else
|
---|
| 210 | #error Undefined Machine/OS type in machdefs.h
|
---|
| 211 | #endif
|
---|
| 212 |
|
---|
| 213 |
|
---|
| 214 |
|
---|
| 215 | #if SWAP==1
|
---|
| 216 | #define IS_BIG_ENDIAN 0
|
---|
| 217 | #else
|
---|
| 218 | #define IS_BIG_ENDIAN 1
|
---|
| 219 | #endif
|
---|
| 220 |
|
---|
| 221 |
|
---|
| 222 | /***********************************************************************/
|
---|
| 223 | /* Find Compiler */
|
---|
| 224 | /***********************************************************************/
|
---|
| 225 |
|
---|
| 226 | /* __MWERKS__ : Metrowerks Codewarrior (>= PRO 4) */
|
---|
| 227 | /* __DECCXX : DEC CXX, version >= 6 is required */
|
---|
| 228 | /* __GNUG__ : GNU C++ 2.8.1, egcs ?? */
|
---|
| 229 | /* __aCC__ : aCC on HP */
|
---|
| 230 | /* __KCC__ : KCC, version >= 3.3 is required */
|
---|
| 231 | /* __SGICC__ : SGI (IRIX64) CC compiler */
|
---|
[2884] | 232 | /* __INTEL_COMPILER : : INTEL compiler */
|
---|
| 233 | /* __IBMCPP__ : AIX (IBM) xlC c++ compiler */
|
---|
[1261] | 234 |
|
---|
| 235 | /***********************************************************************/
|
---|
| 236 | /* Compiler-specific stuff */
|
---|
| 237 | /***********************************************************************/
|
---|
| 238 |
|
---|
| 239 | /* ANSI_TEMPLATES : use ANSI syntax for explicit templates */
|
---|
| 240 | /* GNUG_TEMPLATES : use GNU syntax for explicit templates */
|
---|
| 241 | /* PRAGMA_TEMPLATES : use pragma template, a la cxx */
|
---|
| 242 | /* COMPILER_EXCEPTIONS : knows about exceptions --- required ? */
|
---|
| 243 | /* STREAMPOS_IS_CLASS : streampos is a real class */
|
---|
| 244 | /* ITER_TAG : use iter_tag for iterator qualifiers in STL */
|
---|
| 245 | /* NO_STRSTREAM : does not have strstream */
|
---|
[1889] | 246 | /* NO_EXPLICIT : does not know about explicit keyword */
|
---|
[1261] | 247 | /* HAS_IOS_BIN */
|
---|
| 248 | /* HAS_IOS_NOCREATE */
|
---|
| 249 | /* HAS_VEC_NEW : operator new[] */
|
---|
| 250 | /* CC_HAS_RTTI_SUPPORT has Run Time Type Identification support */
|
---|
| 251 | /* ANSI_IO : rdbuf()->pubseekoff rather than seekg */
|
---|
| 252 | /* HAS_STR_NPOS : has string::npos and not a global NPOS */
|
---|
| 253 | /* NO_IOS_COMPLEX : does not have operator << defined for complex */
|
---|
[2339] | 254 | /* DECL_TEMP_SPEC : Template specialization declaration */
|
---|
[2884] | 255 | /* TSNMLUPG4 : Two stage name look-up scheme (g++>3.4) */
|
---|
[1261] | 256 |
|
---|
| 257 |
|
---|
[2322] | 258 | /* (STREAMPOS_IS_CLASS non-active: ca compile sans sur gcc3.2 et cxx)
|
---|
| 259 | rz+cmv 11/02/03 */
|
---|
| 260 |
|
---|
[1261] | 261 | /* The following is true for most compilers */
|
---|
| 262 |
|
---|
| 263 | #ifndef HAS_VEC_NEW
|
---|
| 264 | #define HAS_VEC_NEW
|
---|
| 265 | #endif
|
---|
| 266 |
|
---|
| 267 | #ifndef COMPILER_EXCEPTIONS
|
---|
| 268 | #define COMPILER_EXCEPTIONS
|
---|
| 269 | #endif
|
---|
| 270 |
|
---|
| 271 | #ifndef CC_HAS_RTTI_SUPPORT
|
---|
| 272 | #define CC_HAS_RTTI_SUPPORT
|
---|
| 273 | #endif
|
---|
| 274 |
|
---|
[2339] | 275 |
|
---|
| 276 | #ifndef DECL_TEMP_SPEC
|
---|
| 277 | #define DECL_TEMP_SPEC
|
---|
| 278 | #endif
|
---|
| 279 |
|
---|
[2884] | 280 | /* Most compilers dot not implement two level name lookup for templates
|
---|
| 281 | introduced by gcc >= 3.4
|
---|
| 282 | */
|
---|
| 283 | #ifdef TSNMLUPG4
|
---|
| 284 | #undef TSNMLUPG4
|
---|
| 285 | #endif
|
---|
[2339] | 286 |
|
---|
[1261] | 287 | /* now the specific things */
|
---|
| 288 |
|
---|
| 289 | #ifdef __MWERKS__
|
---|
| 290 | #define ANSI_TEMPLATES
|
---|
| 291 | #undef HAS_VEC_NEW
|
---|
| 292 | #define NO_STRSTREAM
|
---|
| 293 | //#define STREAMPOS_IS_CLASS
|
---|
| 294 | #define ITER_TAG
|
---|
| 295 | #define HAS_IOS_BIN
|
---|
| 296 | #define HAS_IOS_NOCREATE
|
---|
| 297 | #define HAS_STR_NPOS
|
---|
| 298 | #endif
|
---|
| 299 |
|
---|
| 300 | #ifdef __GNUG__
|
---|
[2884] | 301 | #define GCC_VERSION (__GNUC__ * 10000 \
|
---|
| 302 | + __GNUC_MINOR__ * 100 \
|
---|
| 303 | + __GNUC_PATCHLEVEL__)
|
---|
[1261] | 304 | #define ANSI_TEMPLATES
|
---|
[2322] | 305 | /*
|
---|
| 306 | if (__GNUC__ >= 3)
|
---|
| 307 | define STREAMPOS_IS_CLASS
|
---|
| 308 | endif
|
---|
| 309 | */
|
---|
| 310 | #define GNU_TEMPLATES
|
---|
[1261] | 311 | #define HAS_STR_NPOS
|
---|
| 312 | #define HAS_IOS_BIN
|
---|
| 313 | #define HAS_IOS_NOCREATE
|
---|
[2884] | 314 | #if ( GCC_VERSION >= 30000 )
|
---|
| 315 | #undef DECL_TEMP_SPEC
|
---|
| 316 | #define DECL_TEMP_SPEC template <>
|
---|
[1261] | 317 | #endif
|
---|
[2884] | 318 | #if ( GCC_VERSION >= 34000 )
|
---|
| 319 | /* Two level name look-up scheme for templates introduced from gcc 3.4 */
|
---|
| 320 | #define TSNMLUPG4
|
---|
| 321 | #endif
|
---|
[1261] | 322 |
|
---|
[2884] | 323 | #endif
|
---|
| 324 |
|
---|
[1261] | 325 | #ifdef __DECCXX
|
---|
| 326 | #define HAS_STR_NPOS
|
---|
| 327 | #define ITER_TAG
|
---|
| 328 | #define __CXX_PRAGMA_TEMPLATES__
|
---|
| 329 | #define PRAGMA_TEMPLATES
|
---|
| 330 | #endif
|
---|
| 331 |
|
---|
| 332 | #if defined (__aCC__)
|
---|
| 333 | #ifndef ANSI_TEMPLATES
|
---|
| 334 | #define ANSI_TEMPLATES
|
---|
| 335 | #endif
|
---|
| 336 | #endif
|
---|
| 337 |
|
---|
| 338 | #if defined(__KCC__)
|
---|
| 339 | /* KCC V 3.2 ne compile pas i/ostream s ; long p = s.tellg(); OK en V 3.3 */
|
---|
| 340 | #define HAS_STR_NPOS
|
---|
| 341 | #ifndef ANSI_TEMPLATES
|
---|
| 342 | #define ANSI_TEMPLATES
|
---|
| 343 | #endif
|
---|
| 344 | #endif
|
---|
| 345 |
|
---|
| 346 | #if defined(__SGICC__)
|
---|
| 347 | #define HAS_STR_NPOS
|
---|
| 348 | #ifndef ANSI_TEMPLATES
|
---|
| 349 | #define ANSI_TEMPLATES
|
---|
[2867] | 350 | #endif
|
---|
[2339] | 351 | #undef DECL_TEMP_SPEC
|
---|
| 352 | #define DECL_TEMP_SPEC template <>
|
---|
[1261] | 353 | #endif
|
---|
[2867] | 354 |
|
---|
| 355 | #if defined(__IBMCPP__)
|
---|
| 356 | /* IBM xlC compiler support Added : dec 2005 */
|
---|
| 357 | #ifndef ANSI_TEMPLATES
|
---|
| 358 | #define ANSI_TEMPLATES
|
---|
[1261] | 359 | #endif
|
---|
[2867] | 360 | #undef DECL_TEMP_SPEC
|
---|
| 361 | #define DECL_TEMP_SPEC template <>
|
---|
| 362 | #endif
|
---|
[1261] | 363 |
|
---|
| 364 | /* Get things has homogeneous as possible between compilers */
|
---|
| 365 |
|
---|
| 366 | #ifdef HAS_STR_NPOS
|
---|
| 367 | #define NPOS string::npos
|
---|
| 368 | #else
|
---|
| 369 | #define NPOS (size_t)-1
|
---|
| 370 | #endif
|
---|
| 371 |
|
---|
| 372 | #ifndef __GNUG__
|
---|
| 373 | #define __PRETTY_FUNCTION__ __FILE__ " __LINE__ "
|
---|
| 374 | #ifndef __FUNCTION__
|
---|
| 375 | #define __FUNCTION__ __FILE__ " __LINE__ "
|
---|
| 376 | #endif
|
---|
| 377 | #ifndef __KCC__
|
---|
| 378 | #define __attribute__(_x_)
|
---|
| 379 | #endif
|
---|
| 380 | #endif
|
---|
| 381 |
|
---|
[1889] | 382 | #ifdef NO_EXPLICIT
|
---|
[1261] | 383 | #define explicit
|
---|
| 384 | #endif
|
---|
| 385 |
|
---|
| 386 | #ifdef HAS_IOS_BIN
|
---|
| 387 | #define IOS_BIN ios::binary
|
---|
| 388 | #else
|
---|
| 389 | #define IOS_BIN 0
|
---|
| 390 | #endif
|
---|
| 391 |
|
---|
[2322] | 392 | /* Commente par Reza+CMV - Fev 2003
|
---|
| 393 | ifdef ANSI_IO
|
---|
| 394 | define seekg(p_, m_) rdbuf()->pubseekoff(p_,m_)
|
---|
| 395 | define seekp(p_, m_) rdbuf()->pubseekoff(p_,m_)
|
---|
| 396 | endif
|
---|
| 397 | */
|
---|
[1261] | 398 |
|
---|
| 399 | #ifdef __MWERKS__
|
---|
| 400 | //#define hypot(_x_,_y_) sqrt((_x_)*(_x_) + (_y_)*(_y_))
|
---|
| 401 | #define random() (rand()*65538.0 + rand()*2. + rand())
|
---|
| 402 | #define srandom srand
|
---|
| 403 | #define initstate(seed, tab, n) srand(seed)
|
---|
| 404 | #define nice(_x)
|
---|
| 405 |
|
---|
| 406 | #ifdef __cplusplus
|
---|
| 407 | #include <string.h>
|
---|
| 408 | #include <string>
|
---|
| 409 | inline bool operator< (string const& s1, string const& s2)
|
---|
| 410 | { return (strcmp(s1.c_str(), s2.c_str()) < 0); }
|
---|
| 411 | #endif
|
---|
| 412 | #endif
|
---|
| 413 |
|
---|
[1783] | 414 | #ifdef OS_MACOSX
|
---|
| 415 | #define NO_VALUES_H
|
---|
| 416 | #include "osx_values.h"
|
---|
| 417 | #endif
|
---|
[1261] | 418 |
|
---|
[1783] | 419 |
|
---|
[1261] | 420 | /********************************************************/
|
---|
| 421 | /* Outil d'impressions pour debug */
|
---|
| 422 | #define PR(_data_) {cout<<" "<<#_data_<<" "<<_data_;}
|
---|
| 423 | #define CR {cout<<"\n"<<flush;}
|
---|
| 424 | /* ********************************************************/
|
---|
| 425 |
|
---|
| 426 | /* ---- Activation des flags de debug/bound checking ----- */
|
---|
| 427 | #ifdef SOPHYA_DEBUG
|
---|
| 428 | #define SO_BOUNDCHECKING
|
---|
| 429 | #endif
|
---|
| 430 |
|
---|
| 431 | /* ---- La taille et les index des tableaux ---- */
|
---|
| 432 | #ifdef SGI_ARCH64
|
---|
| 433 | typedef int_8 sa_size_t ;
|
---|
| 434 | #else
|
---|
| 435 | typedef int_4 sa_size_t ;
|
---|
| 436 | #endif
|
---|
| 437 |
|
---|
| 438 | /* Compatibilite, avant de migrer tout le code en "PLANCK" */
|
---|
| 439 |
|
---|
| 440 | #ifdef __cplusplus
|
---|
[1870] | 441 | /* Standard C++ library classes are in the namespace std */
|
---|
| 442 | namespace std { }
|
---|
| 443 | using namespace std;
|
---|
[2615] | 444 | /*******************************************/
|
---|
| 445 | /* SOPHYA classes are in namespace SOPHYA */
|
---|
| 446 | /* namespace SOPHYA {} */
|
---|
| 447 | /* using namespace SOPHYA; */
|
---|
| 448 | /* Please use instead: sopnamsp.h */
|
---|
| 449 | /*******************************************/
|
---|
[1261] | 450 | #define EXPLICIT explicit
|
---|
| 451 | #endif
|
---|
| 452 |
|
---|
| 453 | #endif
|
---|