2 * collectd - src/collectd.h
3 * Copyright (C) 2005,2006 Florian octo Forster
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; only version 2 of the License is applicable.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Florian octo Forster <octo at verplant.org>
31 # include <sys/types.h>
34 # include <sys/stat.h>
45 # if !STDC_HEADERS && HAVE_MEMORY_H
54 # include <inttypes.h>
66 # define _Bool signed char
72 # define __bool_true_false_are_defined 1
78 # include <sys/wait.h>
81 # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8)
84 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
98 #if TIME_WITH_SYS_TIME
99 # include <sys/time.h>
103 # include <sys/time.h>
112 # define assert(...) /* nop */
115 #if NAN_STATIC_DEFAULT
117 /* #endif NAN_STATIC_DEFAULT*/
118 #elif NAN_STATIC_ISOC
119 # ifndef __USE_ISOC99
120 # define DISABLE_ISOC99 1
121 # define __USE_ISOC99 1
122 # endif /* !defined(__USE_ISOC99) */
125 # undef DISABLE_ISOC99
127 # endif /* DISABLE_ISOC99 */
128 /* #endif NAN_STATIC_ISOC */
134 # define NAN (0.0 / 0.0)
136 # define isnan(f) ((f) != (f))
137 # endif /* !defined(isnan) */
139 # define isfinite(f) (((f) - (f)) == 0.0)
142 # define isinf(f) (!isfinite(f) && !isnan(f))
144 #endif /* NAN_ZERO_ZERO */
146 /* Try really, really hard to determine endianess. Under NexentaStor 1.0.2 this
147 * information is in <sys/isa_defs.h>, possibly some other Solaris versions do
151 #elif HAVE_SYS_ISA_DEFS_H
152 # include <sys/isa_defs.h>
156 # if defined(_BYTE_ORDER)
157 # define BYTE_ORDER _BYTE_ORDER
158 # elif defined(__BYTE_ORDER)
159 # define BYTE_ORDER __BYTE_ORDER
160 # elif defined(__DARWIN_BYTE_ORDER)
161 # define BYTE_ORDER __DARWIN_BYTE_ORDER
165 # if defined(_BIG_ENDIAN)
166 # define BIG_ENDIAN _BIG_ENDIAN
167 # elif defined(__BIG_ENDIAN)
168 # define BIG_ENDIAN __BIG_ENDIAN
169 # elif defined(__DARWIN_BIG_ENDIAN)
170 # define BIG_ENDIAN __DARWIN_BIG_ENDIAN
173 #ifndef LITTLE_ENDIAN
174 # if defined(_LITTLE_ENDIAN)
175 # define LITTLE_ENDIAN _LITTLE_ENDIAN
176 # elif defined(__LITTLE_ENDIAN)
177 # define LITTLE_ENDIAN __LITTLE_ENDIAN
178 # elif defined(__DARWIN_LITTLE_ENDIAN)
179 # define LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN
183 # if defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN)
185 # define BIG_ENDIAN 4321
186 # define LITTLE_ENDIAN 1234
187 # define BYTE_ORDER BIG_ENDIAN
188 # elif !defined(BIG_ENDIAN) && defined(LITTLE_ENDIAN)
189 # undef LITTLE_ENDIAN
190 # define BIG_ENDIAN 4321
191 # define LITTLE_ENDIAN 1234
192 # define BYTE_ORDER LITTLE_ENDIAN
195 #if !defined(BYTE_ORDER) || !defined(BIG_ENDIAN)
196 # error "Cannot determine byte order"
201 # define NAMLEN(dirent) strlen((dirent)->d_name)
203 # define dirent direct
204 # define NAMLEN(dirent) (dirent)->d_namlen
206 # include <sys/ndir.h>
209 # include <sys/dir.h>
223 # include <sys/param.h>
230 #if HAVE_SENSORS_SENSORS_H
231 # include <sensors/sensors.h>
235 #define PACKAGE_NAME "collectd"
239 #define PREFIX "/opt/" PACKAGE_NAME
243 #define SYSCONFDIR PREFIX "/etc"
247 #define CONFIGFILE SYSCONFDIR"/collectd.conf"
250 #ifndef LOCALSTATEDIR
251 #define LOCALSTATEDIR PREFIX "/var"
254 #ifndef PKGLOCALSTATEDIR
255 #define PKGLOCALSTATEDIR PREFIX "/var/lib/" PACKAGE_NAME
259 #define PIDFILE PREFIX "/var/run/" PACKAGE_NAME ".pid"
263 #define PLUGINDIR PREFIX "/lib/" PACKAGE_NAME
267 #define PKGDATADIR PREFIX "/share/" PACKAGE_NAME
270 #ifndef COLLECTD_GRP_NAME
271 # define COLLECTD_GRP_NAME "collectd"
274 #define STATIC_ARRAY_LEN(array) (sizeof (array) / sizeof ((array)[0]))
276 /* Remove GNU specific __attribute__ settings when using another compiler */
278 # define __attribute__(x) /**/
281 #if defined(COLLECT_DEBUG) && COLLECT_DEBUG && defined(__GNUC__) && __GNUC__
285 # pragma GCC poison strcpy strcat strtok
289 * Special hack for the perl plugin: Because the later included perl.h defines
290 * a macro which is never used, but contains `sprintf', we cannot poison that
291 * identifies just yet. The parl plugin will do that itself once perl.h is
294 #ifndef DONT_POISON_SPRINTF_YET
295 # if defined(COLLECT_DEBUG) && COLLECT_DEBUG && defined(__GNUC__) && __GNUC__
297 # pragma GCC poison sprintf
301 extern char hostname_g[];
302 extern int interval_g;
304 #endif /* COLLECTD_H */