CORSIKA add-on package IACT/ATMO:  Version 1.63 (November 2020)
initial.h
Go to the documentation of this file.
1 /* ============================================================================
2 
3  Copyright (C) 1991, 2001, 2008, 2009, 2010 Konrad Bernloehr
4 
5  This file is part of the eventio/hessio library.
6 
7  The eventio/hessio library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 2.1 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with this library. If not, see <http://www.gnu.org/licenses/>.
19 
20 ============================================================================ */
21 
22 /* ------------------------------------------------------------------ */
72 /* ------------------------------------------------------------------ */
73 
74 #ifndef INITIAL_H__LOADED
75 
76 #define INITIAL_H__LOADED 1
77 
78 #ifdef __cplusplus
79 extern "C" {
80 #endif
81 
82 #ifndef NO_IEEE_FLOAT_FORMAT
83 #define IEEE_FLOAT_FORMAT 1
84 #endif
85 
86 #if ( defined(__x86_64__) || defined(__amd64__) )
87 # define CPU_X86_64 1
88 # define SIXTY_FOUR_BITS 1
89 #endif
90 #if ( defined(__i386__) || defined(__i386) )
91 # define CPU_I86
92 #endif
93 #if ( defined(__alpha) )
94 # define CPU_ALPHA 1
95 # define SIXTY_FOUR_BITS 1
96 #endif
97 #if ( defined(__powerpc__) )
98 # define CPU_PowerPC 1
99 #endif
100 
101 #if ( defined(__WORDSIZE) )
102 # if ( __WORDSIZE == 64 )
103 # define SIXTY_FOUR_BITS 1
104 # endif
105 #endif
106 
107 #if ( defined(MSDOS) || defined(__MSDOS__) ) /* MS C or Turbo C */
108 # define OS_MSDOS 1
109 # define CPU_I86 1
110 #elif ( defined(vax) && defined(vms) ) /* VAX/VMS (what about OpenVMS?) */
111 # define OS_VAXVMS 1
112 # define VAX_FLOAT_FORMAT 1
113 # undef IEEE_FLOAT_FORMAT
114 # define CPU_VAX 1
115 # define MISSING_SNPRINTF 1
116 #elif ( defined(linux) || defined(__linux__) ) /* Linux OS */
117 # define OS_UNIX 1
118 # define OS_LINUX 1
119 #elif ( defined(ultrix) ) /* Ultrix (MIPS or VAX) */
120 # define OS_UNIX 1
121 # define OS_ULTRIX 1
122 # ifndef ULTRIX
123 # define ULTRIX 1
124 # endif
125 # ifndef vax
126 # define CPU_MIPS 1
127 # else
128 # define VAX_FLOAT_FORMAT 1
129 # undef IEEE_FLOAT_FORMAT
130 # define CPU_VAX 1
131 # endif
132 # define MISSING_SNPRINTF 1
133 #elif ( defined(lynx) || defined(__lynx__) ) /* Lynx-OS */
134 # define OS_UNIX 1
135 # define OS_LYNX 1
136 # if ( defined(_ARCH_PPC) || defined(__powerpc__) ) /* Lynx-OS on PowerPC */
137 # define CPU_PowerPC 1
138 # elif ( defined(M68K) ) /* Lynx-OS on Motorola 68K */
139 # define CPU_68K 1
140 # endif
141 # define MISSING_SNPRINTF 1
142 #elif ( defined(AIX) ) /* IBM RS/6000 or PowerPC under AIX */
143 # define OS_UNIX 1
144 # define OS_AIX 1
145 # define CPU_RS6000 1
146 # define CPU_PowerPC 1
147 #elif ( defined(__osf__) && ( defined(__alpha) || defined(__alpha__) ) ) /* DEC Unix */
148 # define OS_UNIX 1
149 # define OS_DECUNIX 1
150 # define CPU_ALPHA 1
151 # define SIXTY_FOUR_BITS 1
152 # define MISSING_SNPRINTF 1
153 #elif ( defined(__APPLE__) && defined(__MACH__) ) /* Mac OS X (at least) */
154 # define OS_UNIX 1
155 # define OS_DARWIN 1
156 #elif ( defined(OSK) ) /* OS-9 68k */
157 # define OS_OS9 1
158 # define CPU_68K 1
159 # define FSTAT_NOT_AVAILABLE 1
160 #elif ( defined(M68K) ) /* seems to be LynxOS on a 68k */
161 # define OS_UNIX 1
162 # define OS_LYNX 1
163 # define CPU_68K 1
164 #elif ( defined(__hpux) ) /* HP-UX */
165 # define OS_HPUX 1
166 # define OS_UNIX 1
167 # ifdef __hppa
168 # define CPU_HPPA 1
169 # endif
170 #else
171 # if defined(unix) || defined(__unix)
172 # define OS_UNIX 1 /* UNIX variant and CPU type are unknown */
173 # endif
174 #endif
175 
176 /* On UNIX the version of files extracted from SCCS are available for 'what' */
177 #ifdef OS_UNIX
178 # ifndef _DEFAULT_SOURCE
179 # define _DEFAULT_SOURCE
180 # endif
181 # ifndef _XOPEN_SOURCE
182 # define _XOPEN_SOURCE 700
183 # define _XOPEN_SOURCE_EXTENDED
184 # endif
185 # ifndef lint
186 # define USING_SCCS 1
187 # define USING_SCCS_ID 1
188 # endif
189 #endif
190 
191 /* The identifier 'ANSI_C' tells that a compiler supporting ANSI C is used */
192 #if defined(__STDC__) /* Usually means 'ANSI C and nothing more than ANSI C' */
193 # ifndef ANSI_C
194 # define ANSI_C 1
195 # endif
196 #endif
197 
198 /* On the following systems all known C compilers (should) support ANSI C: */
199 #if ( defined(OS_MSDOS) || defined(OS_VAXVMS) || defined(OS_UNIX) )
200 # ifndef ANSI_C
201 # define ANSI_C 1
202 # endif
203 #endif
204 
205 /* To test the code the 'ANSI_C' identifier may be reset */
206 #ifdef SIMPLE_C
207 # ifdef ANSI_C
208 # undef ANSI_C
209 # endif
210 #endif
211 
212 /* Which types of systems have a VME bus? */
213 #if ( defined(OS_OS9) || defined(OS_LYNX) )
214 # define VME_BUS 1
215 #endif
216 
217 /* -------------------------------------------------- */
218 
219 #ifndef NO_INITIAL_INCLUDES
220 
221 /* Include standard OS-dependent include files */
222 #if ( defined(OS_OS9) || defined(BSD) )
223 # include <strings.h>
224 #else
225 # include <string.h>
226 /* ROOT 'cint' interpreter claims to be POSIX.1 compatible but isn't */
227 # ifndef __CINT__
228 # ifdef _POSIX_C_SOURCE
229 /* For actual POSIX systems we also include strings.h (for strcasecmp etc.) */
230 # include <strings.h>
231 # endif
232 # endif
233 #endif
234 
235 #include <stdio.h>
236 #include <math.h>
237 #ifndef M_PI
238 # define M_PI 3.14159265358979323846
239 #endif
240 #include <time.h>
241 #if defined(ANSI_C) || defined(__STDC__)
242 # include <stdlib.h>
243 #endif
244 #ifdef OS_UNIX
245 # include <unistd.h>
246 #endif
247 #ifdef OS_MSDOS
248 # include <io.h>
249 #endif
250 #endif
251 /* ^-- end of '#ifndef NO_INITIAL_INCLUDES' */
252 
253 /* -------------------------------------------------- */
254 
255 #if ANSI_C
256 # define ARGLIST(a) a
257 #else
258 # define ARGLIST(a) ()
259 #endif
260 
261 /* -------------------------------------------------- */
262 
263 #ifndef NO_INITIAL_MACROS
264 
265 #ifndef ANSI_C
266 # ifndef NULL
267 # define NULL (void *) 0
268 # endif
269 # ifdef OS_OS9
270  typedef unsigned size_t;
271 # endif
272 # define ARGLIST(a) ()
273 #endif
274 
275 /* Definitions normally found in include files: */
276 /* OS-9 include files don't define SEEK_CUR */
277 #ifndef SEEK_CUR
278 # define SEEK_CUR 1
279 #endif
280 /* OS-9 does not provide a isatty() function */
281 #ifdef OS_OS9
282 # define ISATTY_NOT_AVAILABLE 1
283 # define strchr(arg1,arg2) index(arg1,arg2)
284 char *getenv ARGLIST((char *));
285 #endif
286 #ifdef OS_LYNX
287 #ifdef CPU_PowerPC
288  int bcopy ARGLIST((char *b, char *a, int n));
289 #else
290 # define memmove(a,b,n) bcopy(b,a,n)
291  void bcopy ARGLIST((char *b, char *a, int n));
292 #endif
293 # define tsleep(t) usleep(10000*t)
294 #endif
295 
296 /* fopen() options needed for portability to MS-DOS */
297 #ifdef OS_MSDOS
298 # define WRITE_TEXT "wt"
299 # define WRITE_BINARY "wb"
300 # define READ_TEXT "rt"
301 # define READ_BINARY "rb"
302 # define APPEND_TEXT "at"
303 # define APPEND_BINARY "ab"
304 #else
305 # define WRITE_TEXT "w"
306 # define WRITE_BINARY "w"
307 # define READ_TEXT "r"
308 # define READ_BINARY "r"
309 # define APPEND_TEXT "a"
310 # define APPEND_BINARY "a"
311 #endif
312 
313 #ifndef __cplusplus
314 
315 /* Nearest integer macro */
316 #define Nint(a) (((a)>=0.)?((long)(a+0.5)):((long)(a-0.5)))
317 /* Absolute value independent of data type */
318 #define Abs(a) (((a)>=0)?(a):(-1*(a)))
319 #define Min(a,b) ((a)<(b)?(a):(b))
320 #define Max(a,b) ((a)>(b)?(a):(b))
321 #ifdef CRT
322 /* Old names for the above macros as used in CRT code */
323 # define NINT(a) Nint(a)
324 # define ABS(a) Abs(a)
325 #endif
326 /* Minimum and maximum macros (same definition as in X11) */
327 #ifndef min
328 # define min(a,b) ((a)<(b)?(a):(b))
329 #endif
330 #ifndef max
331 # define max(a,b) ((a)>(b)?(a):(b))
332 #endif
333 
334 #define REGISTER register
335 #else
336 inline long int Nint(double a) { return (((a)>=0.)?((long)(a+0.5)):((long)(a-0.5))); }
337 #define REGISTER
338 #endif
339 /* ^-- end of '#ifndef __cplusplus' */
340 #endif
341 /* ^-- end of '#ifndef NO_INITIAL_MACROS' */
342 
343 /* -------------------------------------------------- */
344 
345 #define CONST_QUAL
346 
347 /* =========== Integer data types ============ */
348 
349 #ifdef __STDC__
350 # ifdef __STDC_VERSION__
351 # if ( __STDC_VERSION__ >= 199901L )
352 # define ANSI_C_99 1
353 # endif
354 # elif ( !defined(__STRICT_ANSI__) && defined(__GNUC__) )
355 /* GCC version 3 and up should be ANSI C 99 capable unless */
356 /* -ansi or -traditional or -std=c89 flags have been used. */
357 # if ( __GNUC__ >= 3 )
358 # define ANSI_C_99 1
359 # endif
360 # endif
361 #endif
362 
363 #ifdef ANSI_C_99
364 # undef CONST_QUAL
365 # define CONST_QUAL const /* Qualifier for constant data */
366 #endif
367 
368 #ifdef __cplusplus
369 #ifndef __STDC_LIMIT_MACROS
370 #define __STDC_LIMIT_MACROS 1
371 #endif
372 #endif
373 
374 #if defined(ANSI_C) || defined(__STDC__) || defined(__cplusplus)
375 # include <sys/types.h>
376 #endif
377 
378 #if defined(ANSI_C_99) || defined(__int8_t_defined) || defined(__cplusplus)
379 /* ANSI C99 (C9x) has the following types specified in stdint.h */
380 /* Fairly recent gcc implementations have them as well (in sys/types.h) */
381 /* but stdint.h is provided as well and duplication does no harm. */
382 # include <stdint.h>
383 /* Older (2.7.x) gcc versions have some of them defined in */
384 /* <sys/bitypes.h> (which is included from <sys/types.h>) and the rest */
385 /* is slightly different but we have no stdint.h. */
386 #elif defined(__BIT_TYPES_DEFINED__)
387  typedef u_int8_t uint8_t;
388  typedef u_int16_t uint16_t;
389  typedef u_int32_t uint32_t;
390 #else
391 /* Only for the older compilers we have to declare all the types here. */
392 # if !defined(__GNUC__) && !defined(OS_UNIX)
393  typedef /*signed*/ char int8_t;
394 # else
395  typedef signed char int8_t;
396 # endif
397  typedef unsigned char uint8_t;
398 
399  typedef short int16_t;
400  typedef unsigned short uint16_t;
401 
402 # ifdef OS_MSDOS
403  typedef long int32_t;
404  typedef unsigned long uint32_t;
405 # else
406  typedef int int32_t;
407  typedef unsigned int uint32_t;
408 # endif
409 # if defined(SIXTY_FOUR_BITS)
410  typedef long int64_t;
411  typedef unsigned long uint64_t;
412 # endif
413 # if defined(__INTMAX_TYPE__)
414  typedef __INTMAX_TYPE__ intmax_t;
415 # else
416  typedef long intmax_t;
417 # endif
418 # if defined(__UINTMAX_TYPE__)
419  typedef __UINTMAX_TYPE__ uintmax_t;
420 # else
421  typedef unsigned long uintmax_t;
422 # endif
423 #endif
424 
425 /* This should do it for most other 64 bit systems than DEC Unix */
426 #ifndef SIXTY_FOUR_BITS
427 # ifdef __WORDSIZE
428 # if __WORDSIZE == 64
429 # define SIXTY_FOUR_BITS 1
430 # endif
431 # endif
432 #endif
433 
434 /* Many 32 bit systems have long long int as 64 bit integer */
435 #if defined(SIXTY_FOUR_BITS) || ( defined(INT64_MAX) && defined(__GNUC__) )
436 # define HAVE_64BIT_INT 1
437 #endif
438 
439 #ifdef MISSING_SNPRINTF
440  extern int snprintf ARGLIST((char *s, size_t l, CONST_QUAL char *fmt, ...));
441 #endif
442 
443 #ifdef __cplusplus
444 }
445 #endif
446 
447 /* Optional memory debugging includes. */
448 #ifdef DMALLOC
449 # include <dmalloc.h>
450 #endif
451 
452 #ifdef USE_MPATROL
453 # include <mpatrol.h>
454 #endif
455 
456 #if defined(INTMAX_MAX) || defined(__cplusplus)
457 # define WITH_INTMAX_T 1
458 #endif
459 #if defined(UINTMAX_MAX) || defined(__cplusplus)
460 # define WITH_UINTMAX_T 1
461 #endif
462 
463 #endif