source: proiecte/NBody/Tree codes/stdinc.h @ 170

Last change on this file since 170 was 170, checked in by (none), 14 years ago
File size: 3.4 KB
Line 
1/****************************************************************************/
2/* STDINC.H: standard include file for Zeno C programs.                     */
3/* Copyright (c) 1999 by Joshua E. Barnes, Tokyo, JAPAN.                    */
4/****************************************************************************/
5
6#ifndef _stdinc_h
7#define _stdinc_h
8
9/*
10 * Always include stdio.h and stdlib.h.
11 */
12
13#include <stdio.h>
14#include <stdlib.h>
15
16/*
17 * NULL: value for null pointers, normally defined by stdio.h.
18 */
19
20#if !defined(NULL)
21#define NULL 0L
22#endif
23
24/*
25 * LOCAL: synonym for static declares an object as local to a source file.
26 */
27
28#define local     static
29
30/*
31 * BOOL, TRUE, FALSE: standard names for logical values.
32 */
33
34typedef short int bool;
35
36#if !defined(TRUE)
37#define TRUE  ((bool) 1)
38#define FALSE ((bool) 0)
39#endif
40
41/*
42 * BYTE: name a handy chunk of bits.
43 */
44
45typedef unsigned char byte;
46
47/*
48 * STRING: null-terminated char array.
49 */
50
51typedef char *string;
52
53/*
54 * STREAM: more elegant synonym for FILE *.
55 */
56
57typedef FILE *stream;                   /* note: stdio.h is included above  */
58
59/*
60 * REAL, REALPTR: Compile-time precision specification.  Options are:
61 *      DOUBLEPREC:     everything (variables & functions) is double.
62 *      MIXEDPREC:      user values are float, -lm functions are double.
63 *      SINGLEPREC:     everything (variables & functions) is float.
64 * See mathfns.h for a list of real-valued functions.  If single
65 * precision library functions are not availible then use MIXEDPREC
66 * instead of SINGLEPREC.
67 */
68
69/*
70 * Default precision: use SINGLEPREC on SGI and MIXEDPREC on IBM.
71 */
72
73#if !defined(MIXEDPREC) && !defined(SINGLEPREC) && !defined(DOUBLEPREC)
74#define SINGLEPREC
75#endif
76
77#if defined(DOUBLEPREC)
78#undef SINGLEPREC
79#undef MIXEDPREC
80typedef double real, *realptr;
81#define Precision "DOUBLEPREC"
82#endif
83
84#if defined(MIXEDPREC)
85#undef DOUBLEPREC
86#undef SINGLEPREC
87typedef float *realptr, real;
88#define Precision "MIXEDPREC"
89#endif
90
91#if defined(SINGLEPREC)
92#undef DOUBLEPREC
93#undef MIXEDPREC
94typedef float real, *realptr;
95#define Precision "SINGLEPREC"
96#endif
97
98/*
99 * PI, etc.  --  mathematical constants.
100 */
101
102#define PI         3.14159265358979323846
103#define TWO_PI     6.28318530717958647693
104#define FOUR_PI   12.56637061435917295385
105#define HALF_PI    1.57079632679489661923
106#define FRTHRD_PI  4.18879020478639098462
107
108/*
109 * STREQ: string-equality macro. STRNULL: test for empty string.
110 * Note that string.h should be included if these are used.
111 */
112
113#define streq(x,y) (strcmp((x), (y)) == 0)
114#define strnull(x) (strcmp((x), "") == 0)
115
116/*
117 * ABS: returns the absolute value of its argument.
118 * MAX: returns the argument with the highest value.
119 * MIN: returns the argument with the lowest value.
120 */
121
122#define ABS(x)   (((x)<0)?-(x):(x))
123#define MAX(a,b) (((a)>(b))?(a):(b))
124#define MIN(a,b) (((a)<(b))?(a):(b))
125
126/*
127 * Prototypes for misc. functions in libZeno.a.
128 */
129
130void *allocate(int);                    /* alloc, check for errors, zero    */
131
132double cputime(void);                   /* returns CPU time in minutes      */
133
134void error(string, ...);                /* complain about error and exit    */
135
136void eprintf(string, ...);              /* print message to stderr          */
137
138bool scanopt(string, string);           /* scan options for keyword         */
139
140stream stropen(string, string);         /* arguments are much like fopen    */
141
142#endif  /* ! _stdinc_h */
Note: See TracBrowser for help on using the repository browser.