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