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