]> git.ipfire.org Git - thirdparty/squid.git/blob - acinclude/os-deps.m4
Factored epoll() checks out.
[thirdparty/squid.git] / acinclude / os-deps.m4
1 dnl
2 dnl AUTHOR: Squid Web Cache team
3 dnl
4 dnl SQUID Web Proxy Cache http://www.squid-cache.org/
5 dnl ----------------------------------------------------------
6 dnl Squid is the result of efforts by numerous individuals from
7 dnl the Internet community; see the CONTRIBUTORS file for full
8 dnl details. Many organizations have provided support for Squid's
9 dnl development; see the SPONSORS file for full details. Squid is
10 dnl Copyrighted (C) 2001 by the Regents of the University of
11 dnl California; see the COPYRIGHT file for full details. Squid
12 dnl incorporates software developed and/or copyrighted by other
13 dnl sources; see the CREDITS file for full details.
14 dnl
15 dnl This program is free software; you can redistribute it and/or modify
16 dnl it under the terms of the GNU General Public License as published by
17 dnl the Free Software Foundation; either version 2 of the License, or
18 dnl (at your option) any later version.
19 dnl
20 dnl This program is distributed in the hope that it will be useful,
21 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
22 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 dnl GNU General Public License for more details.
24 dnl
25 dnl You should have received a copy of the GNU General Public License
26 dnl along with this program; if not, write to the Free Software
27 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
28
29
30 dnl check that strnstr() works fine. On Macos X it can cause a buffer overrun
31 dnl sets squid_cv_func_strnstr to "yes" or "no", and defines HAVE_STRNSTR
32 AC_DEFUN([SQUID_CHECK_FUNC_STRNSTR],[
33
34 # Yay! This one is a MacOSX brokenness. Its not good enough
35 # to know that strnstr() exists, because MacOSX 10.4 have a bad
36 # copy that crashes with a buffer over-run!
37 AH_TEMPLATE(HAVE_STRNSTR,[MacOS brokenness: strnstr() can overrun on that system])
38 AC_CACHE_CHECK([if strnstr is well implemented], squid_cv_func_strnstr,
39 AC_RUN_IFELSE([AC_LANG_SOURCE([[
40 #include <stdlib.h>
41 #include <stdio.h>
42 #include <string.h>
43 // we expect this to succeed, or crash on over-run.
44 // if it passes otherwise we may need a better check.
45 int main(int argc, char **argv)
46 {
47 int size = 20;
48 char *str = malloc(size);
49 memset(str, 'x', size);
50 strnstr(str, "fubar", size);
51 return 0;
52 }
53 ]])],[squid_cv_func_strnstr="yes"],[squid_cv_func_strnstr="no"],[])
54 )
55 if test "$squid_cv_func_strnstr" = "yes" ; then
56 AC_DEFINE(HAVE_STRNSTR,1)
57 fi
58
59 ]) dnl SQUID_CHECK_FUNC_STRNSTR
60
61 dnl check that va_copy is implemented and works
62 dnl sets squid_cv_func_va_copy and defines HAVE_VA_COPY
63 AC_DEFUN([SQUID_CHECK_FUNC_VACOPY],[
64
65 # check that the system provides a functional va_copy call
66
67 AH_TEMPLATE(HAVE_VA_COPY, [The system implements a functional va_copy() ])
68 AC_CACHE_CHECK(if va_copy is implemented, squid_cv_func_va_copy,
69 AC_RUN_IFELSE([AC_LANG_SOURCE([[
70 #include <stdarg.h>
71 #include <stdlib.h>
72 int f (int i, ...) {
73 va_list args1, args2;
74 va_start (args1, i);
75 va_copy (args2, args1);
76 if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
77 return 1;
78 va_end (args1); va_end (args2);
79 return 0;
80 }
81 int main(int argc, char **argv) { return f (0, 42); }
82 ]])],[squid_cv_func_va_copy="yes"],[squid_cv_func_va_copy="no"],[])
83 )
84 if test "$squid_cv_func_va_copy" = "yes" ; then
85 AC_DEFINE(HAVE_VA_COPY, 1)
86 fi
87
88 ]) dnl SQUID_CHECK_FUNC_VACOPY
89
90 dnl same sa SQUID_CHECK_FUNC_VACOPY, but checks __va_copy
91 dnl sets squid_cv_func___va_copy, and defines HAVE___VA_COPY
92 AC_DEFUN([SQUID_CHECK_FUNC___VACOPY],[
93
94 AH_TEMPLATE(HAVE___VA_COPY,[Some systems have __va_copy instead of va_copy])
95 AC_CACHE_CHECK(if __va_copy is implemented, squid_cv_func___va_copy,
96 AC_RUN_IFELSE([AC_LANG_SOURCE([[
97 #include <stdarg.h>
98 #include <stdlib.h>
99 int f (int i, ...) {
100 va_list args1, args2;
101 va_start (args1, i);
102 __va_copy (args2, args1);
103 if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
104 return 1;
105 va_end (args1); va_end (args2);
106 return 0;
107 }
108 int main(int argc, char **argv) { return f (0, 42); }
109 ]])],[squid_cv_func___va_copy="yes"],[squid_cv_func___va_copy="no"],[])
110 )
111 if test "$squid_cv_func___va_copy" = "yes" ; then
112 AC_DEFINE(HAVE___VA_COPY, 1)
113 fi
114 ]) dnl SQUID_CHECK_FUNC___VACOPY
115
116
117 dnl check that epoll actually works
118 dnl sets squid_cv_epoll_works to "yes" or "no"
119 AC_DEFUN([SQUID_CHECK_EPOLL],[
120
121 AC_CACHE_CHECK(if epoll works, squid_cv_epoll_works,
122 AC_RUN_IFELSE([AC_LANG_SOURCE([[
123 #include <sys/epoll.h>
124 #include <stdlib.h>
125 #include <stdio.h>
126 int main(int argc, char **argv)
127 {
128 int fd = epoll_create(256);
129 if (fd < 0) {
130 perror("epoll_create:");
131 return 1;
132 }
133 return 0;
134 }
135 ]])],[squid_cv_epoll_works=yes],[squid_cv_epoll_works=no],[]))
136
137 ]) dnl SQUID_CHECK_EPOLL