HNBody Version 1.2.1

- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

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