do NOT assume that FP_* is defined, it can also be a typedef enum ... bug report...
[rrdtool.git] / src / rrd_config_bottom.h
1 #ifndef RRD_CONFIG_BOTTOM_H
2 #define RRD_CONFIG_BOTTOM_H
3
4 /* make sure that we pickup the correct stuff from all headers */
5 #ifdef HAVE_FEATURES_H
6 # ifdef _XOPEN_SOURCE
7 #   undef _XOPEN_SOURCE
8 # endif
9 # ifdef _BSD_SOURCE
10 #  undef _BSD_SOURCE
11 # endif
12 # define _XOPEN_SOURCE 600
13 # define _BSD_SOURCE 1
14 # include <features.h>
15 #endif
16
17 /* FreeBSD 4.8 wants this included BEFORE sys/types.h */
18 #ifdef HAVE_SYS_MMAN_H
19 # include <sys/mman.h>
20 #endif
21
22 #ifdef HAVE_SYS_TYPES_H
23 # include <sys/types.h>
24 #endif
25
26 #ifdef HAVE_SYS_PARAM_H
27 # include <sys/param.h>
28 #endif
29 #ifndef MAXPATH
30 # ifdef PATH_MAX
31 #  define MAXPATH PATH_MAX
32 # endif
33 #endif
34 #ifndef MAXPATH
35 /* else try the BSD variant */
36 # ifdef MAXPATHLEN
37 #  define MAXPATH MAXPATHLEN
38 # endif
39 #endif
40
41 #ifdef HAVE_ERRNO_H
42 # include <errno.h>
43 #endif
44
45 #if !defined HAVE_MADVISE && defined HAVE_POSIX_MADVISE
46 /* use posix_madvise family */
47 # define madvise posix_madvise
48 # define MADV_NORMAL POSIX_MADV_NORMAL
49 # define MADV_RANDOM POSIX_MADV_RANDOM
50 # define MADV_SEQUENTIAL POSIX_MADV_SEQUENTIAL
51 # define MADV_WILLNEED POSIX_MADV_WILLNEED
52 # define MADV_DONTNEED POSIX_MADV_DONTNEED
53 #endif
54 #if defined HAVE_MADVISE || defined HAVE_POSIX_MADVISE
55 # define USE_MADVISE 1
56 #endif
57
58 #ifdef HAVE_SYS_STAT_H
59 # include <sys/stat.h>
60 #endif
61
62 #ifdef HAVE_FCNTL_H
63 #include <fcntl.h>
64 #endif
65
66 #ifdef HAVE_UNISTD_H
67 # include <unistd.h>
68 #endif
69
70 #ifdef TIME_WITH_SYS_TIME
71 # include <sys/time.h>
72 # include <time.h>
73 #else
74 # ifdef HAVE_SYS_TIME_H
75 #  include <sys/time.h>
76 # else
77 #  include <time.h>
78 # endif
79 #endif
80
81 #ifdef HAVE_SYS_TIMES_H
82 # include <sys/times.h>
83 #endif
84
85 #ifdef HAVE_SYS_RESOURCE_H
86 # include <sys/resource.h>
87 #if (defined(__svr4__) && defined(__sun__))
88 /* Solaris headers (pre 2.6) do not have a getrusage prototype. 
89    Use this instead. */
90 extern int getrusage(int, struct rusage *);
91 #endif /* __svr4__ && __sun__ */
92 #endif
93
94
95 /* define strrchr, strchr and memcpy, memmove in terms of bsd funcs
96    make sure you are NOT using bcopy, index or rindex in the code */
97       
98 #ifdef STDC_HEADERS
99 # include <string.h>
100 #else
101 # ifndef HAVE_STRCHR
102 #  define strchr index
103 #  define strrchr rindex
104 # endif
105 char *strchr (), *strrchr ();
106 # ifndef HAVE_MEMMOVE
107 #  define memcpy(d, s, n) bcopy ((s), (d), (n))
108 #  define memmove(d, s, n) bcopy ((s), (d), (n))
109 # endif
110 #endif
111
112 #ifdef NO_NULL_REALLOC
113 # define rrd_realloc(a,b) ( (a) == NULL ? malloc( (b) ) : realloc( (a) , (b) ))
114 #else
115 # define rrd_realloc(a,b) realloc((a), (b))
116 #endif
117
118 #ifdef HAVE_STDIO_H
119 # include <stdio.h>
120 #endif
121
122 #ifdef HAVE_STDLIB_H
123 # include <stdlib.h>
124 #endif
125
126 #ifdef HAVE_CTYPE_H
127 # include <ctype.h>
128 #endif
129
130 #ifdef HAVE_DIRENT_H
131 # include <dirent.h>
132 # define NAMLEN(dirent) strlen((dirent)->d_name)
133 #else
134 # define dirent direct
135 # define NAMLEN(dirent) (dirent)->d_namlen
136 # ifdef HAVE_SYS_NDIR_H
137 #  include <sys/ndir.h>
138 # endif
139 # ifdef HAVE_SYS_DIR_H
140 #  include <sys/dir.h>
141 # endif
142 # ifdef HAVE_NDIR_H
143 #  include <ndir.h>
144 # endif
145 #endif
146
147 #ifdef MUST_DISABLE_SIGFPE
148 # include <signal.h>
149 #endif
150
151 #ifdef MUST_DISABLE_FPMASK
152 # include <floatingpoint.h>
153 #endif
154
155
156 #ifdef HAVE_MATH_H
157 # include <math.h>
158 #endif
159
160 #ifdef HAVE_FLOAT_H
161 # include <float.h>
162 #endif
163
164 #ifdef HAVE_IEEEFP_H
165 # include <ieeefp.h>
166 #endif
167
168 #ifdef HAVE_FP_CLASS_H
169 # include <fp_class.h>
170 #endif
171
172 /* for Solaris */
173 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASS)) 
174 # define HAVE_ISINF 1
175 # ifdef isinf
176 #  undef isinf
177 # endif
178 # define isinf(a) (fpclass(a) == FP_NINF || fpclass(a) == FP_PINF)
179 #endif
180
181 /* solaris 10 it defines isnan such that only forte can compile it ... bad bad  */
182 #if (defined(HAVE_ISNAN) && defined(isnan) && defined(HAVE_FPCLASS))
183 #  undef isnan
184 #  define isnan(a) (fpclass(a) == FP_SNAN || fpclass(a) == FP_QNAN)
185 #endif
186
187 /* for OSF1 Digital Unix */
188 #if (! defined(HAVE_ISINF) && defined(HAVE_FP_CLASS) && defined(HAVE_FP_CLASS_H))
189 #  define HAVE_ISINF 1
190 #  define isinf(a) (fp_class(a) == FP_NEG_INF || fp_class(a) == FP_POS_INF)
191 #endif
192
193 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY))
194 #  define HAVE_ISINF 1
195 #  define isinf(a) (fpclassify(a) == FP_MINUS_INF || fpclassify(a) == FP_PLUS_INF)
196 #endif
197
198 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY))
199 #  define HAVE_ISINF 1
200 #  define isinf(a) (fpclassify(a) == FP_INFINITE)
201 #endif
202
203 /* for AIX */
204 #if (! defined(HAVE_ISINF) && defined(HAVE_CLASS))
205 #  define HAVE_ISINF 1
206 #  define isinf(a) (class(a) == FP_MINUS_INF || class(a) == FP_PLUS_INF)
207 #endif
208
209 #if (! defined (HAVE_FINITE) && defined (HAVE_ISFINITE))
210 #  define HAVE_FINITE 1
211 #  define finite(a) isfinite(a)
212 #endif
213
214 #if (! defined(HAVE_FINITE) && defined(HAVE_ISNAN) && defined(HAVE_ISINF))
215 #  define HAVE_FINITE 1
216 #  define finite(a) (! isnan(a) && ! isinf(a))
217 #endif
218
219 #ifndef HAVE_FINITE
220 #error "Can't compile without finite function"
221 #endif
222
223 #ifndef HAVE_ISINF
224 #error "Can't compile without isinf function"
225 #endif
226
227 #if (! defined(HAVE_FDATASYNC) && defined(HAVE_FSYNC))
228 #define fdatasync fsync
229 #endif
230
231 #if (!defined(HAVE_FDATASYNC) && !defined(HAVE_FSYNC))
232 #error "Can't compile with without fsync and fdatasync"
233 #endif
234
235 #endif /* RRD_CONFIG_BOTTOM_H */
236