]> git.ipfire.org Git - thirdparty/squid.git/blob - compat/fdsetsize.h
Renamed squid.h to squid-old.h and config.h to squid.h
[thirdparty/squid.git] / compat / fdsetsize.h
1 #ifndef SQUID_FDSETSIZE_H
2 #define SQUID_FDSETSIZE_H
3
4 /****************************************************************************
5 *--------------------------------------------------------------------------*
6 * DO *NOT* MAKE ANY CHANGES below here unless you know what you're doing...*
7 *--------------------------------------------------------------------------*
8 ****************************************************************************/
9
10 /* FD_SETSIZE must be redefined before including sys/types.h */
11 #if 0
12 /* AYJ: would dearly like to use this to enforce include order
13 but at present some helpers don't follow the squid include methodology.
14 that will need fixing later.
15 */
16 #ifdef _SYS_TYPES_H
17 #error squid_fdsetsize.h for FDSETSIZE must be included before sys/types.h
18 #error Make sure that squid.h or squid-old.h is the first file included by your .cc
19 #endif
20 #endif /* 0 */
21 /*
22 * On some systems, FD_SETSIZE is set to something lower than the
23 * actual number of files which can be opened. IRIX is one case,
24 * NetBSD is another. So here we increase FD_SETSIZE to our
25 * configure-discovered maximum *before* any system includes.
26 */
27 #define CHANGE_FD_SETSIZE 1
28
29 /*
30 * Cannot increase FD_SETSIZE on Linux, but we can increase __FD_SETSIZE
31 * with glibc 2.2 (or later? remains to be seen). We do this by including
32 * bits/types.h which defines __FD_SETSIZE first, then we redefine
33 * __FD_SETSIZE. Ofcourse a user program may NEVER include bits/whatever.h
34 * directly, so this is a dirty hack!
35 */
36 #if _SQUID_LINUX_ || _SQUID_KFREEBSD_
37 #undef CHANGE_FD_SETSIZE
38 #define CHANGE_FD_SETSIZE 0
39 #include <features.h>
40 #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
41 #if SQUID_MAXFD > DEFAULT_FD_SETSIZE
42 #include <bits/types.h>
43 #if HAVE_LINUX_POSIX_TYPES_H
44 #include <linux/posix_types.h>
45 #endif
46 #undef __FD_SETSIZE
47 #define __FD_SETSIZE SQUID_MAXFD
48 #endif
49 #endif
50 #endif
51
52 /*
53 * Cannot increase FD_SETSIZE on FreeBSD before 2.2.0, causes select(2)
54 * to return EINVAL.
55 * --Marian Durkovic <marian@svf.stuba.sk>
56 * --Peter Wemm <peter@spinner.DIALix.COM>
57 */
58 #if _SQUID_FREEBSD_
59 #include <osreldate.h>
60 #if __FreeBSD_version < 220000
61 #undef CHANGE_FD_SETSIZE
62 #define CHANGE_FD_SETSIZE 0
63 #endif
64 #endif
65
66 /*
67 * Trying to redefine CHANGE_FD_SETSIZE causes a slew of warnings
68 * on Mac OS X Server.
69 */
70 #if _SQUID_APPLE_
71 #undef CHANGE_FD_SETSIZE
72 #define CHANGE_FD_SETSIZE 0
73 #endif
74
75 /* Increase FD_SETSIZE if SQUID_MAXFD is bigger */
76 #if CHANGE_FD_SETSIZE && SQUID_MAXFD > DEFAULT_FD_SETSIZE
77 #define FD_SETSIZE SQUID_MAXFD
78 #endif
79
80
81 /*
82 * Trap unintentional use of fd_set. Must not be used outside the
83 * select code as it only supports FD_SETSIZE number of filedescriptors
84 * and Squid may be running with a lot more..
85 * But only for code linked into Squid, not the helpers.. (unlinkd, pinger)
86 */
87 #ifdef SQUID_FDSET_NOUSE
88 # ifndef SQUID_HELPER
89 # define fd_set ERROR_FD_SET_USED
90 # endif
91 #endif
92
93 #endif /* SQUID_FDSETSIZE_H */