1 sinclude(../config/acx.m4)
2 sinclude(../config/no-executables.m4)
4 dnl See whether strncmp reads past the end of its string parameters.
5 dnl On some versions of SunOS4 at least, strncmp reads a word at a time
6 dnl but erroneously reads past the end of strings. This can cause
7 dnl a SEGV in some cases.
8 AC_DEFUN(libiberty_AC_FUNC_STRNCMP,
9 [AC_REQUIRE([AC_FUNC_MMAP])
10 AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works,
12 /* Test by Jim Wilson and Kaveh Ghazi.
13 Check whether strncmp reads past the end of its string parameters. */
14 #include <sys/types.h>
20 #ifdef HAVE_SYS_MMAN_H
26 #define MAP_ANON MAP_ANONYMOUS
28 #define MAP_ANON MAP_FILE
39 #define MAP_LEN 0x10000
43 #if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE)
47 dev_zero = open ("/dev/zero", O_RDONLY);
51 p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE,
52 MAP_ANON|MAP_PRIVATE, dev_zero, 0);
54 p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE,
55 MAP_ANON|MAP_PRIVATE, -1, 0);
60 char *string = "__si_type_info";
61 char *q = (char *) p + MAP_LEN - strlen (string) - 2;
62 char *r = (char *) p + 0xe;
68 #endif /* HAVE_MMAP || HAVE_MMAP_ANYWHERE */
71 ], ac_cv_func_strncmp_works=yes, ac_cv_func_strncmp_works=no,
72 ac_cv_func_strncmp_works=no)
73 rm -f core core.* *.core])
74 if test $ac_cv_func_strncmp_works = no ; then
79 dnl See if errno must be declared even when <errno.h> is included.
80 AC_DEFUN(libiberty_AC_DECLARE_ERRNO,
81 [AC_CACHE_CHECK(whether errno must be declared, libiberty_cv_declare_errno,
85 libiberty_cv_declare_errno=no,
86 libiberty_cv_declare_errno=yes)])
87 if test $libiberty_cv_declare_errno = yes
88 then AC_DEFINE(NEED_DECLARATION_ERRNO, 1,
89 [Define if errno must be declared even when <errno.h> is included.])
93 dnl See whether we need a declaration for a function.
94 AC_DEFUN(libiberty_NEED_DECLARATION,
95 [AC_MSG_CHECKING([whether $1 must be declared])
96 AC_CACHE_VAL(libiberty_cv_decl_needed_$1,
103 #ifdef HAVE_STRINGS_H
113 [char *(*pfn) = (char *(*)) $1],
114 libiberty_cv_decl_needed_$1=no, libiberty_cv_decl_needed_$1=yes)])
115 AC_MSG_RESULT($libiberty_cv_decl_needed_$1)
116 if test $libiberty_cv_decl_needed_$1 = yes; then
117 AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1,
118 [Define if $1 is not declared in system header files.])
122 # Work around a bug in autoheader. This can go away when we switch to
123 # autoconf >2.50. The use of define instead of AC_DEFUN is
125 define(AC_DEFINE_NOAUTOHEADER,
126 [cat >> confdefs.h <<\EOF
127 [#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1)
131 # We always want a C version of alloca() compiled into libiberty,
132 # because native-compiler support for the real alloca is so !@#$%
133 # unreliable that GCC has decided to use it only when being compiled
134 # by GCC. This is the part of AC_FUNC_ALLOCA that calculates the
135 # information alloca.c needs.
136 AC_DEFUN(libiberty_AC_FUNC_C_ALLOCA,
137 [AC_CACHE_CHECK(whether alloca needs Cray hooks, ac_cv_os_cray,
138 [AC_EGREP_CPP(webecray,
139 [#if defined(CRAY) && ! defined(CRAY2)
144 ], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
145 if test $ac_cv_os_cray = yes; then
146 for ac_func in _getb67 GETB67 getb67; do
147 AC_CHECK_FUNC($ac_func,
148 [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
149 [Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP
150 systems. This function is required for alloca.c support on those
155 AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction,
156 [AC_TRY_RUN([find_stack_direction ()
158 static char *addr = 0;
163 return find_stack_direction ();
166 return (&dummy > addr) ? 1 : -1;
170 exit (find_stack_direction() < 0);
172 ac_cv_c_stack_direction=1,
173 ac_cv_c_stack_direction=-1,
174 ac_cv_c_stack_direction=0)])
175 AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction,
176 [Define if you know the direction of stack growth for your system;
177 otherwise it will be automatically deduced at run-time.
178 STACK_DIRECTION > 0 => grows toward higher addresses
179 STACK_DIRECTION < 0 => grows toward lower addresses
180 STACK_DIRECTION = 0 => direction of growth unknown])
183 # AC_LANG_FUNC_LINK_TRY(C)(FUNCTION)
184 # ----------------------------------
185 # Don't include <ctype.h> because on OSF/1 3.0 it includes
186 # <sys/types.h> which includes <sys/select.h> which contains a
187 # prototype for select. Similarly for bzero.
189 # This test used to merely assign f=$1 in main(), but that was
190 # optimized away by HP unbundled cc A.05.36 for ia64 under +O3,
191 # presumably on the basis that there's no need to do that store if the
192 # program is about to exit. Conversely, the AIX linker optimizes an
193 # unused external declaration that initializes f=$1. So this test
194 # program has both an external initialization of f, and a use of f in
195 # main that affects the exit status.
197 m4_define([AC_LANG_FUNC_LINK_TRY(C)],
199 [/* System header to define __stub macros and hopefully few prototypes,
200 which can conflict with char $1 (); below.
201 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
202 <limits.h> exists even on freestanding compilers. Under hpux,
203 including <limits.h> includes <sys/time.h> and causes problems
204 checking for functions defined therein. */
205 #if defined (__STDC__) && !defined (_HPUX_SOURCE)
210 /* Override any gcc2 internal prototype to avoid an error. */
215 /* We use char because int might match the return type of a gcc2
216 builtin and then its argument prototype would still apply. */
218 /* The GNU C library defines this for functions which it implements
219 to always fail with ENOSYS. Some functions are actually named
220 something starting with __ and the normal name is an alias. */
221 #if defined (__stub_$1) || defined (__stub___$1)
229 ], [return f != $1;])])