1 sinclude(../config/acx.m4)
2 sinclude(../config/no-executables.m4)
3 sinclude(../config/override.m4)
4 sinclude(../config/warnings.m4)
6 dnl See whether strncmp reads past the end of its string parameters.
7 dnl On some versions of SunOS4 at least, strncmp reads a word at a time
8 dnl but erroneously reads past the end of strings. This can cause
9 dnl a SEGV in some cases.
10 AC_DEFUN(libiberty_AC_FUNC_STRNCMP,
11 [AC_REQUIRE([AC_FUNC_MMAP])
12 AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works,
14 /* Test by Jim Wilson and Kaveh Ghazi.
15 Check whether strncmp reads past the end of its string parameters. */
16 #include <sys/types.h>
22 #ifdef HAVE_SYS_MMAN_H
28 #define MAP_ANON MAP_ANONYMOUS
30 #define MAP_ANON MAP_FILE
41 #define MAP_LEN 0x10000
45 #if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE)
49 dev_zero = open ("/dev/zero", O_RDONLY);
53 p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE,
54 MAP_ANON|MAP_PRIVATE, dev_zero, 0);
56 p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE,
57 MAP_ANON|MAP_PRIVATE, -1, 0);
62 char *string = "__si_type_info";
63 char *q = (char *) p + MAP_LEN - strlen (string) - 2;
64 char *r = (char *) p + 0xe;
70 #endif /* HAVE_MMAP || HAVE_MMAP_ANYWHERE */
73 ], ac_cv_func_strncmp_works=yes, ac_cv_func_strncmp_works=no,
74 ac_cv_func_strncmp_works=no)
75 rm -f core core.* *.core])
76 if test $ac_cv_func_strncmp_works = no ; then
81 dnl See if errno must be declared even when <errno.h> is included.
82 AC_DEFUN(libiberty_AC_DECLARE_ERRNO,
83 [AC_CACHE_CHECK(whether errno must be declared, libiberty_cv_declare_errno,
87 libiberty_cv_declare_errno=no,
88 libiberty_cv_declare_errno=yes)])
89 if test $libiberty_cv_declare_errno = yes
90 then AC_DEFINE(NEED_DECLARATION_ERRNO, 1,
91 [Define if errno must be declared even when <errno.h> is included.])
95 dnl See whether we need a declaration for a function.
96 AC_DEFUN(libiberty_NEED_DECLARATION,
97 [AC_MSG_CHECKING([whether $1 must be declared])
98 AC_CACHE_VAL(libiberty_cv_decl_needed_$1,
100 #include "confdefs.h"
105 #ifdef HAVE_STRINGS_H
115 [char *(*pfn) = (char *(*)) $1],
116 libiberty_cv_decl_needed_$1=no, libiberty_cv_decl_needed_$1=yes)])
117 AC_MSG_RESULT($libiberty_cv_decl_needed_$1)
118 if test $libiberty_cv_decl_needed_$1 = yes; then
119 AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1,
120 [Define if $1 is not declared in system header files.])
124 # We always want a C version of alloca() compiled into libiberty,
125 # because native-compiler support for the real alloca is so !@#$%
126 # unreliable that GCC has decided to use it only when being compiled
127 # by GCC. This is the part of AC_FUNC_ALLOCA that calculates the
128 # information alloca.c needs.
129 AC_DEFUN(libiberty_AC_FUNC_C_ALLOCA,
130 [AC_CACHE_CHECK(whether alloca needs Cray hooks, ac_cv_os_cray,
131 [AC_EGREP_CPP(webecray,
132 [#if defined(CRAY) && ! defined(CRAY2)
137 ], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
138 if test $ac_cv_os_cray = yes; then
139 for ac_func in _getb67 GETB67 getb67; do
140 AC_CHECK_FUNC($ac_func,
141 [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
142 [Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP
143 systems. This function is required for alloca.c support on those
148 AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction,
149 [AC_TRY_RUN([find_stack_direction ()
151 static char *addr = 0;
156 return find_stack_direction ();
159 return (&dummy > addr) ? 1 : -1;
163 exit (find_stack_direction() < 0);
165 ac_cv_c_stack_direction=1,
166 ac_cv_c_stack_direction=-1,
167 ac_cv_c_stack_direction=0)])
168 AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction,
169 [Define if you know the direction of stack growth for your system;
170 otherwise it will be automatically deduced at run-time.
171 STACK_DIRECTION > 0 => grows toward higher addresses
172 STACK_DIRECTION < 0 => grows toward lower addresses
173 STACK_DIRECTION = 0 => direction of growth unknown])