2 * collectd - src/collectd.h
3 * Copyright (C) 2005,2006 Florian octo Forster
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 * Florian octo Forster <octo at collectd.org>
36 # include <sys/types.h>
39 # include <sys/stat.h>
50 # if !STDC_HEADERS && HAVE_MEMORY_H
59 # include <inttypes.h>
68 # include <sys/wait.h>
71 # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8)
74 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
88 #if TIME_WITH_SYS_TIME
89 # include <sys/time.h>
93 # include <sys/time.h>
99 # include <sys/socket.h>
105 # define assert(...) /* nop */
108 #if !defined(HAVE__BOOL) || !HAVE__BOOL
111 # define HAVE__BOOL 1
114 #if NAN_STATIC_DEFAULT
116 /* #endif NAN_STATIC_DEFAULT*/
117 #elif NAN_STATIC_ISOC
118 # ifndef __USE_ISOC99
119 # define DISABLE_ISOC99 1
120 # define __USE_ISOC99 1
121 # endif /* !defined(__USE_ISOC99) */
124 # undef DISABLE_ISOC99
126 # endif /* DISABLE_ISOC99 */
127 /* #endif NAN_STATIC_ISOC */
133 # define NAN (0.0 / 0.0)
135 # define isnan(f) ((f) != (f))
136 # endif /* !defined(isnan) */
138 # define isfinite(f) (((f) - (f)) == 0.0)
141 # define isinf(f) (!isfinite(f) && !isnan(f))
143 #endif /* NAN_ZERO_ZERO */
145 /* Try really, really hard to determine endianess. Under NexentaStor 1.0.2 this
146 * information is in <sys/isa_defs.h>, possibly some other Solaris versions do
150 #elif HAVE_SYS_ISA_DEFS_H
151 # include <sys/isa_defs.h>
155 # if defined(_BYTE_ORDER)
156 # define BYTE_ORDER _BYTE_ORDER
157 # elif defined(__BYTE_ORDER)
158 # define BYTE_ORDER __BYTE_ORDER
159 # elif defined(__DARWIN_BYTE_ORDER)
160 # define BYTE_ORDER __DARWIN_BYTE_ORDER
164 # if defined(_BIG_ENDIAN)
165 # define BIG_ENDIAN _BIG_ENDIAN
166 # elif defined(__BIG_ENDIAN)
167 # define BIG_ENDIAN __BIG_ENDIAN
168 # elif defined(__DARWIN_BIG_ENDIAN)
169 # define BIG_ENDIAN __DARWIN_BIG_ENDIAN
172 #ifndef LITTLE_ENDIAN
173 # if defined(_LITTLE_ENDIAN)
174 # define LITTLE_ENDIAN _LITTLE_ENDIAN
175 # elif defined(__LITTLE_ENDIAN)
176 # define LITTLE_ENDIAN __LITTLE_ENDIAN
177 # elif defined(__DARWIN_LITTLE_ENDIAN)
178 # define LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN
182 # if defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN)
184 # define BIG_ENDIAN 4321
185 # define LITTLE_ENDIAN 1234
186 # define BYTE_ORDER BIG_ENDIAN
187 # elif !defined(BIG_ENDIAN) && defined(LITTLE_ENDIAN)
188 # undef LITTLE_ENDIAN
189 # define BIG_ENDIAN 4321
190 # define LITTLE_ENDIAN 1234
191 # define BYTE_ORDER LITTLE_ENDIAN
194 #if !defined(BYTE_ORDER) || !defined(BIG_ENDIAN)
195 # error "Cannot determine byte order"
200 # define NAMLEN(dirent) strlen((dirent)->d_name)
202 # define dirent direct
203 # define NAMLEN(dirent) (dirent)->d_namlen
205 # include <sys/ndir.h>
208 # include <sys/dir.h>
222 # include <sys/param.h>
230 # define PACKAGE_NAME "collectd"
234 # define PREFIX "/opt/" PACKAGE_NAME
238 # define SYSCONFDIR PREFIX "/etc"
242 # define CONFIGFILE SYSCONFDIR"/collectd.conf"
245 #ifndef LOCALSTATEDIR
246 # define LOCALSTATEDIR PREFIX "/var"
249 #ifndef PKGLOCALSTATEDIR
250 # define PKGLOCALSTATEDIR PREFIX "/var/lib/" PACKAGE_NAME
254 # define PIDFILE PREFIX "/var/run/" PACKAGE_NAME ".pid"
258 # define PLUGINDIR PREFIX "/lib/" PACKAGE_NAME
262 # define PKGDATADIR PREFIX "/share/" PACKAGE_NAME
265 #ifndef COLLECTD_GRP_NAME
266 # define COLLECTD_GRP_NAME "collectd"
269 #ifndef COLLECTD_DEFAULT_INTERVAL
270 # define COLLECTD_DEFAULT_INTERVAL 10.0
273 #ifndef COLLECTD_USERAGENT
274 # define COLLECTD_USERAGENT PACKAGE_NAME "/" PACKAGE_VERSION
277 /* Only enable __attribute__() for compilers known to support it. */
278 #if !defined(__clang__) && !defined(__GNUC__)
279 # if !defined(__attribute__)
280 # define __attribute__(x) /**/
284 #if defined(COLLECT_DEBUG) && COLLECT_DEBUG && defined(__GNUC__) && __GNUC__
288 # pragma GCC poison strcpy strcat strtok
292 * Special hack for the perl plugin: Because the later included perl.h defines
293 * a macro which is never used, but contains `sprintf', we cannot poison that
294 * identifies just yet. The parl plugin will do that itself once perl.h is
297 #ifndef DONT_POISON_SPRINTF_YET
298 # if defined(COLLECT_DEBUG) && COLLECT_DEBUG && defined(__GNUC__) && __GNUC__
300 # pragma GCC poison sprintf
305 # define GAUGE_FORMAT "%.15g"
308 /* Type for time as used by "utils_time.h" */
309 typedef uint64_t cdtime_t;
311 extern char hostname_g[];
312 extern cdtime_t interval_g;
313 extern int timeout_g;
315 #endif /* COLLECTD_H */