Replace gmx_large_int_t with gmx_int64_t
[alexxy/gromacs.git] / src / gromacs / legacyheaders / types / simple.h
1 /*
2  *
3  *                This source code is part of
4  *
5  *                 G   R   O   M   A   C   S
6  *
7  *          GROningen MAchine for Chemical Simulations
8  *
9  *                        VERSION 3.2.0
10  * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12  * Copyright (c) 2001-2004, The GROMACS development team,
13  * check out http://www.gromacs.org for more information.
14
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * as published by the Free Software Foundation; either version 2
18  * of the License, or (at your option) any later version.
19  *
20  * If you want to redistribute modifications, please consider that
21  * scientific software is very special. Version control is crucial -
22  * bugs must be traceable. We will be happy to consider code for
23  * inclusion in the official distribution, but derived work must not
24  * be called official GROMACS. Details are found in the README & COPYING
25  * files - if they are missing, get the official version at www.gromacs.org.
26  *
27  * To help us fund GROMACS development, we humbly ask that you cite
28  * the papers on the package - you can find them in the top README file.
29  *
30  * For more info, check our website at http://www.gromacs.org
31  *
32  * And Hey:
33  * GRoups of Organic Molecules in ACtion for Science
34  */
35
36 #ifndef _simple_h
37 #define _simple_h
38
39 /* Dont remove this instance of HAVE_CONFIG_H!!!
40  *
41  * We dont _require_ config.h here, but IF one is
42  * available it might contain valuable information about simple types
43  * that helps us automate things better and avoid bailing out.
44  *
45  * Note that this does not have to be the gromacs config.h - several
46  * package setups define these simple types.
47  */
48 #ifdef HAVE_CONFIG_H
49 #  include <config.h>
50 #endif
51
52 /* Information about integer data type sizes */
53 #include <limits.h>
54 #define __STDC_LIMIT_MACROS
55 #include <stdint.h>
56 #ifndef _MSC_VER
57 #define __STDC_FORMAT_MACROS
58 #include <inttypes.h>
59 #endif
60
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 #if 0
65 }
66 #endif
67
68
69 #define XX      0           /* Defines for indexing in  */
70 #define YY      1           /* vectors                  */
71 #define ZZ      2
72 #define DIM     3           /* Dimension of vectors             */
73 #define XXXX    0           /* defines to index matrices */
74 #define XXYY    1
75 #define XXZZ    2
76 #define YYXX    3
77 #define YYYY    4
78 #define YYZZ    5
79 #define ZZXX    6
80 #define ZZYY    7
81 #define ZZZZ    8
82
83 /* There is no standard size for 'bool' in C++, so when
84  * we previously defined it to int for C code the data types
85  * (and structs) would have different size depending on your compiler,
86  * both at gromacs build time and when you use the library.
87  * The only way around this is to NOT assume anything about the C++ type,
88  * so we cannot use the name 'bool' in our C code anymore.
89  */
90
91 typedef int gmx_bool;
92
93 #ifndef FALSE
94 #  define FALSE   0
95 #endif
96 #ifndef TRUE
97 #  define TRUE    1
98 #endif
99 #define BOOL_NR 2
100
101
102 typedef int         atom_id;      /* To indicate an atoms id         */
103 #define NO_ATID     (atom_id)(~0) /* Use this to indicate invalid atid */
104
105 /*! \brief Double precision accuracy */
106 #define GMX_DOUBLE_EPS   1.11022302E-16
107
108 /*! \brief Maximum double precision value - reduced 1 unit in last digit for MSVC */
109 #define GMX_DOUBLE_MAX   1.79769312E+308
110
111 /*! \brief Minimum double precision value */
112 #define GMX_DOUBLE_MIN   2.22507386E-308
113
114 /*! \brief Single precision accuracy */
115 #define GMX_FLOAT_EPS    5.96046448E-08
116
117 /*! \brief Maximum single precision value - reduced 1 unit in last digit for MSVC */
118 #define GMX_FLOAT_MAX    3.40282346E+38
119
120 /*! \brief Minimum single precision value */
121 #define GMX_FLOAT_MIN    1.17549435E-38
122
123
124 /* Check whether we already have a real type! */
125 #ifdef GMX_DOUBLE
126
127 #ifndef HAVE_REAL
128 typedef double      real;
129 #define HAVE_REAL
130 #endif
131
132 #define GMX_MPI_REAL    MPI_DOUBLE
133 #define GMX_REAL_EPS    GMX_DOUBLE_EPS
134 #define GMX_REAL_MIN    GMX_DOUBLE_MIN
135 #define GMX_REAL_MAX    GMX_DOUBLE_MAX
136 #define gmx_real_fullprecision_pfmt "%21.14e"
137 #else
138
139 #ifndef HAVE_REAL
140 typedef float           real;
141 #define HAVE_REAL
142 #endif
143
144 #define GMX_MPI_REAL    MPI_FLOAT
145 #define GMX_REAL_EPS    GMX_FLOAT_EPS
146 #define GMX_REAL_MIN    GMX_FLOAT_MIN
147 #define GMX_REAL_MAX    GMX_FLOAT_MAX
148 #define gmx_real_fullprecision_pfmt "%14.7e"
149 #endif
150
151 typedef real            rvec[DIM];
152
153 typedef double          dvec[DIM];
154
155 typedef real            matrix[DIM][DIM];
156
157 typedef real            tensor[DIM][DIM];
158
159 typedef int             ivec[DIM];
160
161 typedef int             imatrix[DIM][DIM];
162
163 #ifdef _MSC_VER
164 typedef __int32 gmx_int32_t;
165 #define GMX_PRId32 "I32d"
166 #define GMX_SCNd32 "I32d"
167
168 typedef __int64 gmx_int64_t;
169 #define GMX_PRId64 "I64d"
170 #define GMX_SCNd64 "I64d"
171
172 typedef unsigned __int32 gmx_uint32_t;
173 #define GMX_PRIu32 "U32d"
174 #define GMX_SCNu32 "U32d"
175
176 typedef unsigned __int64 gmx_uint64_t;
177 #define GMX_PRIu64 "U64d"
178 #define GMX_SCNu64 "U64d"
179 #else
180 typedef int32_t gmx_int32_t;
181 #define GMX_PRId32 PRId32
182 #define GMX_SCNd32 SCNd32
183
184 typedef int64_t gmx_int64_t;
185 #define GMX_PRId64 PRId64
186 #define GMX_SCNd64 SCNd64
187
188 typedef uint32_t gmx_uint32_t;
189 #define GMX_PRIu32 PRIu32
190 #define GMX_SCNu32 SCNu32
191
192 typedef uint64_t gmx_uint64_t;
193 #define GMX_PRIu64 PRIu64
194 #define GMX_SCNu64 SCNu64
195 #endif
196
197 #define GMX_INT32_MAX INT32_MAX
198 #define GMX_INT32_MIN INT32_MIN
199
200 #define GMX_INT64_MAX INT64_MAX
201 #define GMX_INT64_MIN INT64_MIN
202
203 #define GMX_UINT32_MAX UINT32_MAX
204 #define GMX_UINT32_MIN UINT32_MIN
205
206 #define GMX_UINT64_MAX UINT64_MAX
207 #define GMX_UINT64_MIN UINT64_MIN
208
209 #ifndef gmx_inline
210 /* config.h tests for inline definitions and should work on a much wider range
211  * of compilers, but does not work with installed headers. These compiler checks
212  * still enable a real inline keyword for the most common compilers.
213  */
214
215 /* Try to define suitable inline keyword for gmx_inline.
216  * Set it to empty if we cannot find one (and dont complain to the user)
217  */
218 #ifndef __cplusplus
219
220 #ifdef __GNUC__
221 /* GCC */
222 #  define gmx_inline   __inline__
223 #elif (defined(__INTEL_COMPILER) || defined(__ECC)) && defined(__ia64__)
224 /* ICC */
225 #  define gmx_inline __inline__
226 #elif defined(__PATHSCALE__)
227 /* Pathscale */
228 #  define gmx_inline __inline__
229 #elif defined(__PGIC__)
230 /* Portland */
231 #  define gmx_inline __inline
232 #elif defined _MSC_VER
233 /* MSVC */
234 #  define gmx_inline __inline
235 #elif defined(__xlC__)
236 /* IBM */
237 #  define gmx_inline __inline
238 #else
239 #  define gmx_inline
240 #endif
241
242 #else
243 /* C++ */
244 #  define gmx_inline inline
245 #endif
246
247 #endif /* ifndef gmx_inline */
248
249
250 /* Restrict keywords. Note that this has to be done for C++ too, unless
251  * it was set from the more general checks if we had config.h (gmx internal)
252  */
253 #ifndef gmx_restrict
254
255 #ifdef __GNUC__
256 /* GCC */
257 #  define gmx_restrict   __restrict__
258 #elif (defined(__INTEL_COMPILER) || defined(__ECC)) && defined(__ia64__)
259 /* ICC */
260 #  define gmx_restrict __restrict__
261 #elif defined(__PATHSCALE__)
262 /* Pathscale */
263 #  define gmx_restrict __restrict
264 #elif defined(__PGIC__)
265 /* Portland */
266 #  define gmx_restrict __restrict
267 #elif defined _MSC_VER
268 /* MSVC */
269 #  define gmx_restrict __restrict
270 #elif defined(__xlC__)
271 /* IBM */
272 #  define gmx_restrict __restrict
273 #else
274 #  define gmx_restrict
275 #endif
276
277 #endif
278
279 /*
280  * These attributes suppress compiler warnings about unused function arguments
281  * by marking them as possibly unused. Some arguments are unused but
282  * have to be retained to preserve a function signature
283  * that must match that of another function.
284  * Some arguments are only used in *some* code paths (e.g. MPI)
285  */
286
287 #ifndef gmx_unused
288 #ifdef __GNUC__
289 /* GCC, clang, and some ICC pretending to be GCC */
290 #  define gmx_unused __attribute__ ((unused))
291 #elif (defined(__INTEL_COMPILER) || defined(__ECC)) && !defined(_MSC_VER)
292 /* ICC on *nix */
293 #  define gmx_unused __attribute__ ((unused))
294 #elif defined _MSC_VER
295 /* MSVC */
296 #  define gmx_unused /*@unused@*/
297 #elif defined(__xlC__)
298 /* IBM */
299 #  define gmx_unused __attribute__ ((unused))
300 #else
301 #  define gmx_unused
302 #endif
303 #endif
304
305 /* Standard sizes for char* string buffers */
306 #define STRLEN 4096
307 #define BIG_STRLEN 1048576
308
309
310 #ifdef __cplusplus
311 }
312 #endif
313
314 #endif