]> git.ipfire.org Git - thirdparty/squid.git/blob - include/config.h
Valgrind support. Mainly rearranging of cbdata to make malloc debugging
[thirdparty/squid.git] / include / config.h
1 /*
2 * $Id: config.h,v 1.23 2006/09/03 04:09:35 hno Exp $
3 *
4 * AUTHOR: Duane Wessels
5 *
6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
8 *
9 * Squid is the result of efforts by numerous individuals from
10 * the Internet community; see the CONTRIBUTORS file for full
11 * details. Many organizations have provided support for Squid's
12 * development; see the SPONSORS file for full details. Squid is
13 * Copyrighted (C) 2001 by the Regents of the University of
14 * California; see the COPYRIGHT file for full details. Squid
15 * incorporates software developed and/or copyrighted by other
16 * sources; see the CREDITS file for full details.
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
31 *
32 */
33
34 #ifndef SQUID_CONFIG_H
35 #define SQUID_CONFIG_H
36
37 #include "autoconf.h" /* For GNU autoconf variables */
38 #include "version.h"
39
40 /* To keep API definitions clear */
41 #ifdef __cplusplus
42 #define SQUIDCEXTERN extern "C"
43 #else
44 #define SQUIDCEXTERN extern
45 #endif
46
47 /****************************************************************************
48 *--------------------------------------------------------------------------*
49 * DO *NOT* MAKE ANY CHANGES below here unless you know what you're doing...*
50 *--------------------------------------------------------------------------*
51 ****************************************************************************/
52
53 #ifdef USE_POSIX_REGEX
54 #ifndef USE_RE_SYNTAX
55 #define USE_RE_SYNTAX REG_EXTENDED /* default Syntax */
56 #endif
57 #endif
58
59 /* define the _SQUID_TYPE_ based on a guess of the OS */
60 #if defined(__sun__) || defined(__sun) /* SUN */
61 #define _SQUID_SUN_
62 #if defined(__SVR4) /* SOLARIS */
63 #define _SQUID_SOLARIS_
64 #else /* SUNOS */
65 #define _SQUID_SUNOS_
66 #endif
67
68 #elif defined(__hpux) /* HP-UX - SysV-like? */
69 #define _SQUID_HPUX_
70 #define _SQUID_SYSV_
71
72 #elif defined(__osf__) /* OSF/1 */
73 #define _SQUID_OSF_
74
75 #elif defined(__ultrix) /* Ultrix */
76 #define _SQUID_ULTRIX_
77
78 #elif defined(_AIX) /* AIX */
79 #define _SQUID_AIX_
80
81 #elif defined(__linux__) /* Linux */
82 #define _SQUID_LINUX_
83 #if USE_ASYNC_IO
84 #define _SQUID_LINUX_THREADS_
85 #endif
86
87 #elif defined(__FreeBSD__) /* FreeBSD */
88 #define _SQUID_FREEBSD_
89 #if USE_ASYNC_IO && defined(LINUXTHREADS)
90 #define _SQUID_LINUX_THREADS_
91 #endif
92
93 #elif defined(__sgi__) || defined(sgi) || defined(__sgi) /* SGI */
94 #define _SQUID_SGI_
95 #if !defined(_SVR4_SOURCE)
96 #define _SVR4_SOURCE /* for tempnam(3) */
97 #endif
98 #if USE_ASYNC_IO
99 #define _ABI_SOURCE
100 #endif /* USE_ASYNC_IO */
101
102 #elif defined(__NeXT__)
103 #define _SQUID_NEXT_
104
105 #elif defined(__bsdi__)
106 #define _SQUID_BSDI_ /* BSD/OS */
107
108 #elif defined(__NetBSD__)
109 #define _SQUID_NETBSD_
110
111 #elif defined(__OpenBSD__)
112 #define _SQUID_OPENBSD_
113
114 #elif defined(__CYGWIN32__) || defined(__CYGWIN__)
115 #define _SQUID_CYGWIN_
116 #define _SQUID_WIN32_
117
118 #elif defined(WIN32) || defined(WINNT) || defined(__WIN32__) || defined(__WIN32)
119 #define _SQUID_MSWIN_
120 #define _SQUID_WIN32_
121 #include "squid_mswin.h"
122
123 #elif defined(__APPLE__)
124 #define _SQUID_APPLE_
125
126 #elif defined(sony_news) && defined(__svr4)
127 #define _SQUID_NEWSOS6_
128
129 #elif defined(__EMX__) || defined(OS2) || defined(__OS2__)
130 #define _SQUID_OS2_
131 /*
132 * FIXME: the os2 port of bash seems to have problems checking
133 * the return codes of programs in if statements. These options
134 * need to be overridden.
135 */
136 #endif
137
138 /* FD_SETSIZE must be redefined before including sys/types.h */
139
140 /*
141 * On some systems, FD_SETSIZE is set to something lower than the
142 * actual number of files which can be opened. IRIX is one case,
143 * NetBSD is another. So here we increase FD_SETSIZE to our
144 * configure-discovered maximum *before* any system includes.
145 */
146 #define CHANGE_FD_SETSIZE 1
147
148 /*
149 * Cannot increase FD_SETSIZE on Linux, but we can increase __FD_SETSIZE
150 * with glibc 2.2 (or later? remains to be seen). We do this by including
151 * bits/types.h which defines __FD_SETSIZE first, then we redefine
152 * __FD_SETSIZE. Ofcourse a user program may NEVER include bits/whatever.h
153 * directly, so this is a dirty hack!
154 */
155 #if defined(_SQUID_LINUX_)
156 #undef CHANGE_FD_SETSIZE
157 #define CHANGE_FD_SETSIZE 0
158 #include <features.h>
159 #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
160 #if SQUID_MAXFD > DEFAULT_FD_SETSIZE
161 #include <bits/types.h>
162 #undef __FD_SETSIZE
163 #define __FD_SETSIZE SQUID_MAXFD
164 #endif
165 #endif
166 #endif
167
168 /*
169 * Cannot increase FD_SETSIZE on FreeBSD before 2.2.0, causes select(2)
170 * to return EINVAL.
171 * --Marian Durkovic <marian@svf.stuba.sk>
172 * --Peter Wemm <peter@spinner.DIALix.COM>
173 */
174 #if defined(_SQUID_FREEBSD_)
175 #include <osreldate.h>
176 #if __FreeBSD_version < 220000
177 #undef CHANGE_FD_SETSIZE
178 #define CHANGE_FD_SETSIZE 0
179 #endif
180 #endif
181
182 /*
183 * Trying to redefine CHANGE_FD_SETSIZE causes a slew of warnings
184 * on Mac OS X Server.
185 */
186 #if defined(_SQUID_APPLE_)
187 #undef CHANGE_FD_SETSIZE
188 #define CHANGE_FD_SETSIZE 0
189 #endif
190
191 /* Increase FD_SETSIZE if SQUID_MAXFD is bigger */
192 #if CHANGE_FD_SETSIZE && SQUID_MAXFD > DEFAULT_FD_SETSIZE
193 #define FD_SETSIZE SQUID_MAXFD
194 #endif
195
196
197
198 /*
199 * This is hack to allow compiling IPv6-IPv4 version,
200 * not disturbing branches others than squid3-ipv6
201 */
202
203 #ifdef INET6
204 #define IN_ADDR in6_addr
205 #else
206 #define IN_ADDR in_addr
207 #endif
208
209 /* Typedefs for missing entries on a system */
210
211 #include "squid_types.h"
212
213 /* int8_t */
214 #ifndef HAVE_INT8_T
215 #if HAVE_CHAR && SIZEOF_CHAR == 1
216 typedef char int8_t;
217 #else
218 #error NO 8 bit signed type available
219 #endif
220 #endif
221
222 /* u_int8_t */
223 #ifndef HAVE_U_INT8_T
224 #if HAVE_UINT8_T
225 typedef uint8_t u_int8_t;
226 #else
227 typedef unsigned char u_int8_t;
228 #endif
229 #endif
230
231 /* int16_t */
232 #ifndef HAVE_INT16_T
233 #if HAVE_SHORT && SIZEOF_SHORT == 2
234 typedef short int16_t;
235 #elif HAVE_INT && SIZEOF_INT == 2
236 typedef int int16_t;
237 #else
238 #error NO 16 bit signed type available
239 #endif
240 #endif
241
242 /* u_int16_t */
243 #ifndef HAVE_U_INT16_T
244 #if HAVE_UINT16_T
245 typedef uint16_t u_int16_t;
246 #else
247 typedef unsigned int16_t u_int16_t;
248 #endif
249 #endif
250
251 /* int32_t */
252 #ifndef HAVE_INT32_T
253 #if HAVE_INT && SIZEOF_INT == 4
254 typedef int int32_t;
255 #elif HAVE_LONG && SIZEOF_LONG == 4
256 typedef long int32_t;
257 #else
258 #error NO 32 bit signed type available
259 #endif
260 #endif
261
262 /* u_int32_t */
263 #ifndef HAVE_U_INT32_T
264 #if HAVE_UINT32_T
265 typedef uint32_t u_int32_t;
266 #else
267 typedef unsigned int32_t u_int32_t;
268 #endif
269 #endif
270
271 /* int64_t */
272 #ifndef HAVE_INT64_T
273 #if HAVE___INT64
274 typedef __int64 int64_t;
275 #elif HAVE_LONG && SIZEOF_LONG == 8
276 typedef long int64_t;
277 #elif HAVE_LONG_LONG && SIZEOF_LONG_LONG == 8
278 typedef long long int64_t;
279 #else
280 #error NO 64 bit signed type available
281 #endif
282 #endif
283
284 /* u_int64_t */
285 #ifndef HAVE_U_INT64_T
286 #if HAVE_UINT64_T
287 typedef uint64_t u_int64_t;
288 #else
289 typedef unsigned int64_t u_int64_t;
290 #endif
291 #endif
292
293
294 #ifndef HAVE_PID_T
295 typedef int pid_t;
296 #endif
297
298 #ifndef HAVE_SIZE_T
299 typedef unsigned int size_t;
300 #endif
301
302 #ifndef HAVE_SSIZE_T
303 typedef int ssize_t;
304 #endif
305
306 #ifndef HAVE_OFF_T
307 typedef int off_t;
308 #endif
309
310 #ifndef HAVE_MODE_T
311 typedef unsigned short mode_t;
312 #endif
313
314 #ifndef HAVE_FD_MASK
315 typedef unsigned long fd_mask;
316 #endif
317
318 #ifndef HAVE_SOCKLEN_T
319 typedef int socklen_t;
320 #endif
321
322 #ifndef HAVE_MTYP_T
323 typedef long mtyp_t;
324 #endif
325
326 /*
327 * On Solaris 9 x86, gcc may includes a "fixed" set of old system include files
328 * that is incompatible with the updated Solaris header files.
329 */
330 #if defined(_SQUID_SOLARIS_) && (defined(i386) || defined(__i386))
331 #ifndef HAVE_PAD128_T
332 typedef union {
333 long double _q;
334 int32_t _l[4];
335 } pad128_t;
336 #endif
337 #ifndef HAVE_UPAD128_T
338 typedef union {
339 long double _q;
340 uint32_t _l[4];
341 } upad128_t;
342 #endif
343 #endif
344
345 /*
346 * Don't allow inclusion of malloc.h on FreeBSD, Next and OpenBSD
347 */
348 #if defined(HAVE_MALLOC_H) && (defined(_SQUID_FREEBSD_) || defined(_SQUID_NEXT_) || defined(_SQUID_OPENBSD_))
349 #undef HAVE_MALLOC_H
350 #endif
351
352 #if !defined(CACHEMGR_HOSTNAME)
353 #define CACHEMGR_HOSTNAME ""
354 #else
355 #define CACHEMGR_HOSTNAME_DEFINED 1
356 #endif
357
358 #if SQUID_DETECT_UDP_SO_SNDBUF > 16384
359 #define SQUID_UDP_SO_SNDBUF 16384
360 #else
361 #define SQUID_UDP_SO_SNDBUF SQUID_DETECT_UDP_SO_SNDBUF
362 #endif
363
364 #if SQUID_DETECT_UDP_SO_RCVBUF > 16384
365 #define SQUID_UDP_SO_RCVBUF 16384
366 #else
367 #define SQUID_UDP_SO_RCVBUF SQUID_DETECT_UDP_SO_RCVBUF
368 #endif
369
370 #ifdef HAVE_MEMCPY
371 #define xmemcpy(d,s,n) memcpy((d),(s),(n))
372 #elif HAVE_BCOPY
373 #define xmemcpy(d,s,n) bcopy((s),(d),(n))
374 #elif HAVE_MEMMOVE
375 #define xmemcpy(d,s,n) memmove((d),(s),(n))
376 #endif
377
378 #ifdef HAVE_MEMMOVE
379 #define xmemmove(d,s,n) memmove((d),(s),(n))
380 #elif HAVE_BCOPY
381 #define xmemmove(d,s,n) bcopy((s),(d),(n))
382 #endif
383
384 #define xisspace(x) isspace((unsigned char)x)
385 #define xtoupper(x) toupper((unsigned char)x)
386 #define xtolower(x) tolower((unsigned char)x)
387 #define xisdigit(x) isdigit((unsigned char)x)
388 #define xisascii(x) isascii((unsigned char)x)
389 #define xislower(x) islower((unsigned char)x)
390 #define xisalpha(x) isalpha((unsigned char)x)
391 #define xisprint(x) isprint((unsigned char)x)
392 #define xisalnum(x) isalnum((unsigned char)x)
393 #define xiscntrl(x) iscntrl((unsigned char)x)
394 #define xispunct(x) ispunct((unsigned char)x)
395 #define xisupper(x) isupper((unsigned char)x)
396 #define xisxdigit(x) isxdigit((unsigned char)x)
397 #define xisgraph(x) isgraph((unsigned char)x)
398
399 #if HAVE_RANDOM
400 #define squid_random random
401 #define squid_srandom srandom
402 #elif HAVE_LRAND48
403 #define squid_random lrand48
404 #define squid_srandom srand48
405 #else
406 #define squid_random rand
407 #define squid_srandom srand
408 #endif
409
410 /* gcc doesn't recognize the Windows native 64 bit formatting tags causing
411 * the compile fail, so we must disable the check on native Windows.
412 */
413
414 #if __GNUC__ && !defined(_SQUID_MSWIN_)
415 #define PRINTF_FORMAT_ARG1 __attribute__ ((format (printf, 1, 2)))
416 #define PRINTF_FORMAT_ARG2 __attribute__ ((format (printf, 2, 3)))
417 #define PRINTF_FORMAT_ARG3 __attribute__ ((format (printf, 3, 4)))
418 #else
419 #define PRINTF_FORMAT_ARG1
420 #define PRINTF_FORMAT_ARG2
421 #define PRINTF_FORMAT_ARG3
422 #endif
423
424 /*
425 * Determine if this is a leak check build or standard
426 */
427 #if PURIFY
428 #define LEAK_CHECK_MODE 1
429 #elif WITH_VALGRIND
430 #define LEAK_CHECK_MODE 1
431 #elif XMALLOC_TRACE
432 #define LEAK_CHECK_MODE 1
433 #endif
434
435 /*
436 * valgrind debug support
437 */
438 #if WITH_VALGRIND
439 #include <valgrind/memcheck.h>
440 #else
441 #define VALGRIND_MAKE_NOACCESS(a,b) (0)
442 #define VALGRIND_MAKE_WRITABLE(a,b) (0)
443 #define VALGRIND_MAKE_READABLE(a,b) (0)
444 #define VALGRIND_CHECK_WRITABLE(a,b) (0)
445 #define VALGRIND_CHECK_READABLE(a,b) (0)
446 #define VALGRIND_MALLOCLIKE_BLOCK(a,b,c,d)
447 #define VALGRIND_FREELIKE_BLOCK(a,b)
448 #define RUNNING_ON_VALGRIND 0
449 #endif /* WITH_VALGRIND */
450
451 #endif /* SQUID_CONFIG_H */