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 # We always want a C version of alloca() compiled into libiberty,
123 # because native-compiler support for the real alloca is so !@#$%
124 # unreliable that GCC has decided to use it only when being compiled
125 # by GCC. This is the part of AC_FUNC_ALLOCA that calculates the
126 # information alloca.c needs.
127 AC_DEFUN(libiberty_AC_FUNC_C_ALLOCA,
128 [AC_CACHE_CHECK(whether alloca needs Cray hooks, ac_cv_os_cray,
129 [AC_EGREP_CPP(webecray,
130 [#if defined(CRAY) && ! defined(CRAY2)
135 ], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
136 if test $ac_cv_os_cray = yes; then
137 for ac_func in _getb67 GETB67 getb67; do
138 AC_CHECK_FUNC($ac_func,
139 [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
140 [Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP
141 systems. This function is required for alloca.c support on those
146 AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction,
147 [AC_TRY_RUN([find_stack_direction ()
149 static char *addr = 0;
154 return find_stack_direction ();
157 return (&dummy > addr) ? 1 : -1;
161 exit (find_stack_direction() < 0);
163 ac_cv_c_stack_direction=1,
164 ac_cv_c_stack_direction=-1,
165 ac_cv_c_stack_direction=0)])
166 AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction,
167 [Define if you know the direction of stack growth for your system;
168 otherwise it will be automatically deduced at run-time.
169 STACK_DIRECTION > 0 => grows toward higher addresses
170 STACK_DIRECTION < 0 => grows toward lower addresses
171 STACK_DIRECTION = 0 => direction of growth unknown])
174 # AC_LANG_FUNC_LINK_TRY(C)(FUNCTION)
175 # ----------------------------------
176 # Don't include <ctype.h> because on OSF/1 3.0 it includes
177 # <sys/types.h> which includes <sys/select.h> which contains a
178 # prototype for select. Similarly for bzero.
180 # This test used to merely assign f=$1 in main(), but that was
181 # optimized away by HP unbundled cc A.05.36 for ia64 under +O3,
182 # presumably on the basis that there's no need to do that store if the
183 # program is about to exit. Conversely, the AIX linker optimizes an
184 # unused external declaration that initializes f=$1. So this test
185 # program has both an external initialization of f, and a use of f in
186 # main that affects the exit status.
188 m4_define([AC_LANG_FUNC_LINK_TRY(C)],
190 [/* System header to define __stub macros and hopefully few prototypes,
191 which can conflict with char $1 (); below.
192 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
193 <limits.h> exists even on freestanding compilers. Under hpux,
194 including <limits.h> includes <sys/time.h> and causes problems
195 checking for functions defined therein. */
196 #if defined (__STDC__) && !defined (_HPUX_SOURCE)
201 /* Override any gcc2 internal prototype to avoid an error. */
206 /* We use char because int might match the return type of a gcc2
207 builtin and then its argument prototype would still apply. */
209 /* The GNU C library defines this for functions which it implements
210 to always fail with ENOSYS. Some functions are actually named
211 something starting with __ and the normal name is an alias. */
212 #if defined (__stub_$1) || defined (__stub___$1)
220 ], [return f != $1;])])