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