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>
102 # define assert(...) /* nop */
105 #if !defined(HAVE__BOOL) || !HAVE__BOOL
108 # define HAVE__BOOL 1
111 #if NAN_STATIC_DEFAULT
113 /* #endif NAN_STATIC_DEFAULT*/
114 #elif NAN_STATIC_ISOC
115 # ifndef __USE_ISOC99
116 # define DISABLE_ISOC99 1
117 # define __USE_ISOC99 1
118 # endif /* !defined(__USE_ISOC99) */
121 # undef DISABLE_ISOC99
123 # endif /* DISABLE_ISOC99 */
124 /* #endif NAN_STATIC_ISOC */
130 # define NAN (0.0 / 0.0)
132 # define isnan(f) ((f) != (f))
133 # endif /* !defined(isnan) */
135 # define isfinite(f) (((f) - (f)) == 0.0)
138 # define isinf(f) (!isfinite(f) && !isnan(f))
140 #endif /* NAN_ZERO_ZERO */
142 /* Try really, really hard to determine endianess. Under NexentaStor 1.0.2 this
143 * information is in <sys/isa_defs.h>, possibly some other Solaris versions do
147 #elif HAVE_SYS_ISA_DEFS_H
148 # include <sys/isa_defs.h>
152 # if defined(_BYTE_ORDER)
153 # define BYTE_ORDER _BYTE_ORDER
154 # elif defined(__BYTE_ORDER)
155 # define BYTE_ORDER __BYTE_ORDER
156 # elif defined(__DARWIN_BYTE_ORDER)
157 # define BYTE_ORDER __DARWIN_BYTE_ORDER
161 # if defined(_BIG_ENDIAN)
162 # define BIG_ENDIAN _BIG_ENDIAN
163 # elif defined(__BIG_ENDIAN)
164 # define BIG_ENDIAN __BIG_ENDIAN
165 # elif defined(__DARWIN_BIG_ENDIAN)
166 # define BIG_ENDIAN __DARWIN_BIG_ENDIAN
169 #ifndef LITTLE_ENDIAN
170 # if defined(_LITTLE_ENDIAN)
171 # define LITTLE_ENDIAN _LITTLE_ENDIAN
172 # elif defined(__LITTLE_ENDIAN)
173 # define LITTLE_ENDIAN __LITTLE_ENDIAN
174 # elif defined(__DARWIN_LITTLE_ENDIAN)
175 # define LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN
179 # if defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN)
181 # define BIG_ENDIAN 4321
182 # define LITTLE_ENDIAN 1234
183 # define BYTE_ORDER BIG_ENDIAN
184 # elif !defined(BIG_ENDIAN) && defined(LITTLE_ENDIAN)
185 # undef LITTLE_ENDIAN
186 # define BIG_ENDIAN 4321
187 # define LITTLE_ENDIAN 1234
188 # define BYTE_ORDER LITTLE_ENDIAN
191 #if !defined(BYTE_ORDER) || !defined(BIG_ENDIAN)
192 # error "Cannot determine byte order"
197 # define NAMLEN(dirent) strlen((dirent)->d_name)
199 # define dirent direct
200 # define NAMLEN(dirent) (dirent)->d_namlen
202 # include <sys/ndir.h>
205 # include <sys/dir.h>
219 # include <sys/param.h>
227 #define PACKAGE_NAME "collectd"
231 #define PREFIX "/opt/" PACKAGE_NAME
235 #define SYSCONFDIR PREFIX "/etc"
239 #define CONFIGFILE SYSCONFDIR"/collectd.conf"
242 #ifndef LOCALSTATEDIR
243 #define LOCALSTATEDIR PREFIX "/var"
246 #ifndef PKGLOCALSTATEDIR
247 #define PKGLOCALSTATEDIR PREFIX "/var/lib/" PACKAGE_NAME
251 #define PIDFILE PREFIX "/var/run/" PACKAGE_NAME ".pid"
255 #define PLUGINDIR PREFIX "/lib/" PACKAGE_NAME
259 #define PKGDATADIR PREFIX "/share/" PACKAGE_NAME
262 #ifndef COLLECTD_GRP_NAME
263 # define COLLECTD_GRP_NAME "collectd"
266 #ifndef COLLECTD_DEFAULT_INTERVAL
267 # define COLLECTD_DEFAULT_INTERVAL 10.0
270 #ifndef COLLECTD_USERAGENT
271 # define COLLECTD_USERAGENT PACKAGE_NAME"/"PACKAGE_VERSION
274 /* Only enable __attribute__() for compilers known to support it. */
275 #if defined(__clang__)
276 # define clang_attr(x) __attribute__(x)
277 # define gcc_attr(x) /**/
279 # define clang_attr(x) /**/
280 # define gcc_attr(x) __attribute__(x)
282 # define clang_attr(x) /**/
283 # define gcc_attr(x) /**/
284 # define __attribute__(x) /**/
287 #if defined(COLLECT_DEBUG) && COLLECT_DEBUG && defined(__GNUC__) && __GNUC__
291 # pragma GCC poison strcpy strcat strtok
295 * Special hack for the perl plugin: Because the later included perl.h defines
296 * a macro which is never used, but contains `sprintf', we cannot poison that
297 * identifies just yet. The parl plugin will do that itself once perl.h is
300 #ifndef DONT_POISON_SPRINTF_YET
301 # if defined(COLLECT_DEBUG) && COLLECT_DEBUG && defined(__GNUC__) && __GNUC__
303 # pragma GCC poison sprintf
307 /* Type for time as used by "utils_time.h" */
308 typedef uint64_t cdtime_t;
310 extern char hostname_g[];
311 extern cdtime_t interval_g;
312 extern int pidfile_from_cli;
313 extern int timeout_g;
315 #endif /* COLLECTD_H */