]> git.ipfire.org Git - thirdparty/squid.git/blame - acinclude/os-deps.m4
Refactored some checks out of configure.in and into specific calls.
[thirdparty/squid.git] / acinclude / os-deps.m4
CommitLineData
0abb39dd
FC
1dnl
2dnl AUTHOR: Squid Web Cache team
3dnl
4dnl SQUID Web Proxy Cache http://www.squid-cache.org/
5dnl ----------------------------------------------------------
6dnl Squid is the result of efforts by numerous individuals from
7dnl the Internet community; see the CONTRIBUTORS file for full
8dnl details. Many organizations have provided support for Squid's
9dnl development; see the SPONSORS file for full details. Squid is
10dnl Copyrighted (C) 2001 by the Regents of the University of
11dnl California; see the COPYRIGHT file for full details. Squid
12dnl incorporates software developed and/or copyrighted by other
13dnl sources; see the CREDITS file for full details.
14dnl
15dnl This program is free software; you can redistribute it and/or modify
16dnl it under the terms of the GNU General Public License as published by
17dnl the Free Software Foundation; either version 2 of the License, or
18dnl (at your option) any later version.
19dnl
20dnl This program is distributed in the hope that it will be useful,
21dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
22dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23dnl GNU General Public License for more details.
24dnl
25dnl You should have received a copy of the GNU General Public License
26dnl along with this program; if not, write to the Free Software
27dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
28
29
30dnl check that strnstr() works fine. On Macos X it can cause a buffer overrun
31dnl sets squid_cv_func_strnstr to "yes" or "no", and defines HAVE_STRNSTR
32AC_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!
37AH_TEMPLATE(HAVE_STRNSTR,[MacOS brokenness: strnstr() can overrun on that system])
38AC_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.
45int 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)
55if test "$squid_cv_func_strnstr" = "yes" ; then
56 AC_DEFINE(HAVE_STRNSTR,1)
57fi
58
59]) dnl SQUID_CHECK_FUNC_STRNSTR
60
61dnl check that va_copy is implemented and works
62dnl sets squid_cv_func_va_copy and defines HAVE_VA_COPY
63AC_DEFUN([SQUID_CHECK_FUNC_VACOPY],[
64
65# check that the system provides a functional va_copy call
66
67AH_TEMPLATE(HAVE_VA_COPY, [The system implements a functional va_copy() ])
68AC_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)
84if test "$squid_cv_func_va_copy" = "yes" ; then
85 AC_DEFINE(HAVE_VA_COPY, 1)
86fi
87
88]) dnl SQUID_CHECK_FUNC_VACOPY
89
90dnl same sa SQUID_CHECK_FUNC_VACOPY, but checks __va_copy
91dnl sets squid_cv_func___va_copy, and defines HAVE___VA_COPY
92AC_DEFUN([SQUID_CHECK_FUNC___VACOPY],[
93
94AH_TEMPLATE(HAVE___VA_COPY,[Some systems have __va_copy instead of va_copy])
95AC_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)
111if test "$squid_cv_func___va_copy" = "yes" ; then
112 AC_DEFINE(HAVE___VA_COPY, 1)
113fi
114]) dnl SQUID_CHECK_FUNC___VACOPY