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 */
|
---|
141 | /* HAS_EXPLICIT : knows about explicit keyword - constructors */
|
---|
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_EXPLICIT
|
---|
183 | #define HAS_IOS_BIN
|
---|
184 | #define HAS_IOS_NOCREATE
|
---|
185 | #endif
|
---|
186 |
|
---|
187 | #ifdef __DECCXX
|
---|
188 | #define HAS_STR_NPOS
|
---|
189 | #define ITER_TAG
|
---|
190 | #define __CXX_PRAGMA_TEMPLATES__
|
---|
191 | #define PRAGMA_TEMPLATES
|
---|
192 | #endif
|
---|
193 |
|
---|
194 | #if defined (__aCC__)
|
---|
195 | #ifndef ANSI_TEMPLATES
|
---|
196 | #define ANSI_TEMPLATES
|
---|
197 | #endif
|
---|
198 | #endif
|
---|
199 |
|
---|
200 | #if defined(__KCC__)
|
---|
201 | /* KCC V 3.2 ne compile pas i/ostream s ; long p = s.tellg(); OK en V 3.3 */
|
---|
202 | #define HAS_STR_NPOS
|
---|
203 | #ifndef ANSI_TEMPLATES
|
---|
204 | #define ANSI_TEMPLATES
|
---|
205 | #endif
|
---|
206 | #endif
|
---|
207 |
|
---|
208 | #if defined(__SGICC__)
|
---|
209 | #define HAS_STR_NPOS
|
---|
210 | #ifndef ANSI_TEMPLATES
|
---|
211 | #define ANSI_TEMPLATES
|
---|
212 | #endif
|
---|
213 | #endif
|
---|
214 |
|
---|
215 | /* Get things has homogeneous as possible between compilers */
|
---|
216 |
|
---|
217 | #ifdef HAS_STR_NPOS
|
---|
218 | #define NPOS string::npos
|
---|
219 | #else
|
---|
220 | #define NPOS (size_t)-1
|
---|
221 | #endif
|
---|
222 |
|
---|
223 | #ifndef __GNUG__
|
---|
224 | #define __PRETTY_FUNCTION__ __FILE__ " __LINE__ "
|
---|
225 | #ifndef __FUNCTION__
|
---|
226 | #define __FUNCTION__ __FILE__ " __LINE__ "
|
---|
227 | #endif
|
---|
228 | #ifndef __KCC__
|
---|
229 | #define __attribute__(_x_)
|
---|
230 | #endif
|
---|
231 | #endif
|
---|
232 |
|
---|
233 | #ifndef HAS_EXPLICIT
|
---|
234 | #define explicit
|
---|
235 | #endif
|
---|
236 |
|
---|
237 | #ifdef HAS_IOS_BIN
|
---|
238 | #define IOS_BIN ios::binary
|
---|
239 | #else
|
---|
240 | #define IOS_BIN 0
|
---|
241 | #endif
|
---|
242 |
|
---|
243 | #ifdef ANSI_IO
|
---|
244 | #define seekg(p_, m_) rdbuf()->pubseekoff(p_,m_)
|
---|
245 | #define seekp(p_, m_) rdbuf()->pubseekoff(p_,m_)
|
---|
246 | #endif
|
---|
247 |
|
---|
248 | #ifdef __MWERKS__
|
---|
249 | //#define hypot(_x_,_y_) sqrt((_x_)*(_x_) + (_y_)*(_y_))
|
---|
250 | #define random() (rand()*65538.0 + rand()*2. + rand())
|
---|
251 | #define srandom srand
|
---|
252 | #define initstate(seed, tab, n) srand(seed)
|
---|
253 | #define nice(_x)
|
---|
254 |
|
---|
255 | #ifdef __cplusplus
|
---|
256 | #include <string.h>
|
---|
257 | #include <string>
|
---|
258 | inline bool operator< (string const& s1, string const& s2)
|
---|
259 | { return (strcmp(s1.c_str(), s2.c_str()) < 0); }
|
---|
260 | #endif
|
---|
261 | #endif
|
---|
262 |
|
---|
263 |
|
---|
264 | /********************************************************/
|
---|
265 | /* Outil d'impressions pour debug */
|
---|
266 | #define PR(_data_) {cout<<" "<<#_data_<<" "<<_data_;}
|
---|
267 | #define CR {cout<<"\n"<<flush;}
|
---|
268 | /* ********************************************************/
|
---|
269 |
|
---|
270 | /* ---- Activation des flags de debug/bound checking ----- */
|
---|
271 | #ifdef SOPHYA_DEBUG
|
---|
272 | #define SO_BOUNDCHECKING
|
---|
273 | #endif
|
---|
274 |
|
---|
275 | /* ---- La taille et les index des tableaux ---- */
|
---|
276 | #ifdef SGI_ARCH64
|
---|
277 | typedef int_8 sa_size_t ;
|
---|
278 | #else
|
---|
279 | typedef int_4 sa_size_t ;
|
---|
280 | #endif
|
---|
281 |
|
---|
282 |
|
---|
283 | /* Compatibilite, avant de migrer tout le code en "PLANCK" */
|
---|
284 |
|
---|
285 | #ifdef __cplusplus
|
---|
286 | /* Standard C++ library classes are in the namespace std */
|
---|
287 | namespace std { }
|
---|
288 | using namespace std;
|
---|
289 | /* SOPHYA classes are in namespace SOPHYA */
|
---|
290 | namespace SOPHYA {}
|
---|
291 | using namespace SOPHYA;
|
---|
292 | #define EXPLICIT explicit
|
---|
293 | #endif
|
---|
294 |
|
---|
295 | #endif
|
---|