Manticore  Version 2.0alpha
Physics of Molecular Clouds
platform.h
Go to the documentation of this file.
1 #ifndef MUTILS_PLATFORM_H
2 #define MUTILS_PLATFORM_H
3 
15 #ifdef __cplusplus
16 #include <climits>
17 
18 extern "C" {
19 namespace mutils {
20 #else
21 #include <limits.h>
22 #endif
23 
24 /* ISO C requires at least 8- and 16-bits for these */
25 typedef signed char int8;
26 typedef unsigned char uint8;
27 typedef signed short int int16;
28 typedef unsigned short int uint16;
29 
30 #ifndef INT_MAX
31 #define INT_MAX 2147483647L
32 #endif
33 #if INT_MAX >= 2147483647L
34 typedef signed int int32;
35 typedef unsigned int uint32;
36 #else
37 typedef signed long int int32;
38 typedef unsigned long int uint32;
39 #endif
40 
41 #ifndef LONG_MAX
42 #define LONG_MAX 2147483647L
43 #endif
44 #if LONG_MAX > 2147483647L
45 typedef signed long int int64;
46 typedef unsigned long int uint64;
47 #else
48 typedef signed long long int int64;
49 typedef unsigned long long int uint64;
50 #endif
51 
52 #ifdef __cplusplus
53 } // namespace mutils
54 } // extern "C" {
55 #endif
56 
57 
58 /*
59  Pure preprocessor work below here---CANNOT be confined to a namespace.
60 */
61 #define MU_MAKESTR(arg) #arg
62 #define MU_VERSTR(num) MU_MAKESTR(num)
63 
64 /* Standardized compiler name strings. */
65 #define mu_compiler_known
66 #if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
67 # define mu_compiler "sunpro"
68 # define mu_compiler_sunpro
69 #elif defined(__PGI)
70 # define mu_compiler "pgcc"
71 # define mu_compiler_pgcc
72 #elif defined(__ICC)
73 # define mu_compiler ("icc" MU_VERSTR(__ICC))
74 # define mu_compiler_icc
75 #elif defined(__DECC)
76 # define mu_compiler "decc"
77 # define mu_compiler_decc
78 #elif defined(__xlC__)
79 # define mu_compiler "xlc"
80 # define mu_compiler_xlc
81 #elif defined(__GNUC__)
82 # define mu_compiler ("gcc" MU_VERSTR(__GNUC__) "." MU_VERSTR(__GNUC_MINOR__))
83 # define mu_compiler_gcc
84 #else
85 # define mu_compiler "unknown"
86 # undef mu_compiler_known
87 #endif
88 
89 
90 /* OS defines. */
91 #define mu_os_known
92 #ifdef DJGPP
93 # define mu_os_djgpp
94 #elif defined(__UWIN__)
95 # define mu_os_uwin
96 #elif defined(__MINGW32__) || defined(__CYGWIN32__) || defined(_MSC_VER) || \
97  defined(__WIN32) || defined(_WIN32) || defined(WIN32)
98 # define mu_os_mswin
99 #elif defined(__APPLE__) && defined(__MACH__)
100 # define mu_os_macx
101 #elif defined(aix) || defined(__aix)
102 # define mu_os_aix
103 #elif defined(hpux) || defined(__hpux)
104 # define mu_os_hpux
105 #elif defined(irix) || defined(sgi) || defined(__sgi) || defined(__irix)
106 # define mu_os_irix
107 #elif defined(linx) || defined(linux) || defined(__linux__) || defined(__linx)
108 # define mu_os_linux
109 #elif defined(osf1) || defined (__osf__) || \
110  (defined(__digital__) && defined(__unix__)) || defined(__osf1)
111 # define mu_os_osf1
112 #elif defined(sun4) || defined(__sun4)
113 # define mu_os_sun4
114 #elif defined(sun5) || defined(__sun5) || (defined(__PGI) && defined(sun))
115 # define mu_os_sun5
116 #elif defined(sun) || defined(__sun) /* Make educated guesses... */
117 # if defined(__SVR4) || defined(__svr4__) || defined(__sun5)
118 # define mu_os_sun5
119 # elif (!defined(__SVR4) && !defined(__svr4__)) || defined(__sun4)
120 # define mu_os_sun4
121 # endif
122 #else
123 # undef mu_os_known /* OS unknown. */
124 #endif
125 
126 #ifndef mu_os_known
127 # error "OS not supported in platform.h."
128 #endif
129 
130 
131 /* CPU defines. */
132 #define mu_cpu_known
133 #if defined(alpha) || defined(__alpha__) || defined(__alpha)
134 # define mu_cpu_alpha
135 #elif defined(hppa) || defined(__hppa)
136 # define mu_cpu_hppa
137 #elif defined(__MIC__)
138 # define mu_cpu_x86_mic
139 #elif defined(i386) || defined(i486) || defined(i586) || \
140  defined(i686) || defined(i786) || defined(__i386) || defined(_X86_) || \
141  defined(__386__) || defined(__i386__) || defined(_M_IX86)
142 # define mu_cpu_x86
143 #elif defined(x86_64) || defined(__x86_64) || defined(__x86_64__) || \
144  defined(__amd64) || defined(__amd64__)
145 # define mu_cpu_amd64
146 #elif defined(mips) || defined(host_mips) || \
147  defined(__host_mips) || defined(__mips)
148 # define mu_cpu_mips
149 #elif defined(__bgq__) && defined(__PPC64__)
150 # define mu_cpu_bgq
151 #elif defined(__PPC64__) || defined(__ARCH_PPC64)
152 # define mu_cpu_ppc64
153 #elif defined(__ppc__) || defined(__PPC__) || defined(__ppc) || \
154  defined(__powerpc__) || defined(__powerpc)
155 # define mu_cpu_ppc
156 #elif defined(rs6000) || defined(__rs6000__) || defined(__rs6000)
157 # define mu_cpu_rs6000
158 #elif defined(sparc) || defined(__sparc__) || defined(__sparc)
159 # define mu_cpu_sparc
160 #else
161 # undef mu_cpu_known /* CPU unknown. */
162 #endif
163 
164 #ifndef mu_cpu_known
165 # error "CPU not supported in platform.h."
166 #endif
167 
168 
169 /* ASM defines. */
170 #define mu_asm_known
171 #if (defined(mu_compiler_icc) || defined(mu_compiler_gcc) || \
172  defined(mu_compiler_sunpro)) && \
173  defined(mu_cpu_x86) && !defined(mu_os_macx)
174 # define mu_asm_att_x86
175 #elif (defined(mu_compiler_icc) || defined(mu_compiler_gcc) || \
176  defined(mu_compiler_sunpro)) && \
177  defined(mu_cpu_amd64) && !defined(mu_os_macx)
178 # define mu_asm_att_amd64
179 #else
180 # undef mu_asm_known /* ASM variant unknown. */
181 #endif
182 
183 
184 /* Byte order defines. */
185 #if defined(mu_cpu_alpha) || defined(mu_cpu_x86) || defined(mu_cpu_amd64) || \
186  defined(mu_cpu_x86_mic) || defined(mu_cpu_rs6000) || \
187  (defined(mu_cpu_mips) && !defined(_MIPSEB) && !defined(MIPSEB)) || \
188  defined(L_ENDIAN)
189 # undef MU_BIGENDIAN
190 # define MU_ENDIAN 0
191 #elif defined(mu_cpu_bgq) || defined(mu_cpu_hppa) || defined(mu_cpu_mips) || \
192  defined(mu_cpu_ppc) || defined(mu_cpu_ppc64) || defined(mu_cpu_sparc) || \
193  defined(B_ENDIAN)
194 # define MU_BIGENDIAN
195 # define MU_ENDIAN 1
196 #else
197 # error "Byte order unknown in platform.h; CPU type supported??"
198 #endif
199 
200 
201 #if defined(DLL_EXPORT)
202 # define DLLSPEC __declspec(dllexport)
203 #elif defined(DLL_IMPORT)
204 # define DLLSPEC __declspec(dllimport)
205 #else
206 # define DLLSPEC
207 #endif
208 
209 #endif /* MUTILS_PLATFORM_H */
signed short int int16
Definition: platform.h:27
MathUtils package.
Definition: CommandLine.cc:10
unsigned short int uint16
Definition: platform.h:28
signed int int32
Definition: platform.h:34
unsigned long long int uint64
Definition: platform.h:49
unsigned int uint32
Definition: platform.h:35
unsigned char uint8
Definition: platform.h:26
signed long long int int64
Definition: platform.h:48
signed char int8
Definition: platform.h:25