1 dnl See whether strncmp reads past the end of its string parameters.
2 dnl On some versions of SunOS4 at least, strncmp reads a word at a time
3 dnl but erroneously reads past the end of strings. This can cause
4 dnl a SEGV in some cases.
5 AC_DEFUN(libiberty_AC_FUNC_STRNCMP,
6 [AC_REQUIRE([AC_FUNC_MMAP])
7 AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works,
9 /* Test by Jim Wilson and Kaveh Ghazi.
10 Check whether strncmp reads past the end of its string parameters. */
11 #include <sys/types.h>
17 #ifdef HAVE_SYS_MMAN_H
23 #define MAP_ANON MAP_ANONYMOUS
25 #define MAP_ANON MAP_FILE
36 #define MAP_LEN 0x10000
40 #if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE)
44 dev_zero = open ("/dev/zero", O_RDONLY);
48 p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE,
49 MAP_ANON|MAP_PRIVATE, dev_zero, 0);
54 char *string = "__si_type_info";
55 char *q = (char *) p + MAP_LEN - strlen (string) - 2;
56 char *r = (char *) p + 0xe;
62 #endif /* HAVE_MMAP || HAVE_MMAP_ANYWHERE */
65 ], ac_cv_func_strncmp_works=yes, ac_cv_func_strncmp_works=no,
66 ac_cv_func_strncmp_works=no)
67 rm -f core core.* *.core])
68 if test $ac_cv_func_strncmp_works = no ; then
69 LIBOBJS="$LIBOBJS strncmp.o"
73 dnl See if errno must be declared even when <errno.h> is included.
74 AC_DEFUN(libiberty_AC_DECLARE_ERRNO,
75 [AC_CACHE_CHECK(whether errno must be declared, libiberty_cv_declare_errno,
79 libiberty_cv_declare_errno=no,
80 libiberty_cv_declare_errno=yes)])
81 if test $libiberty_cv_declare_errno = yes
82 then AC_DEFINE(NEED_DECLARATION_ERRNO, 1,
83 [Define if errno must be declared even when <errno.h> is included.])
87 # FIXME: We temporarily define our own version of AC_PROG_CC. This is
88 # copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS. We
89 # are probably using a cross compiler, which will not be able to fully
90 # link an executable. This should really be fixed in autoconf
93 AC_DEFUN(LIB_AC_PROG_CC,
94 [AC_BEFORE([$0], [AC_PROG_CPP])dnl
95 AC_PROVIDE([AC_PROG_CC])
96 AC_CHECK_PROG(CC, gcc, gcc)
97 if test -z "$CC"; then
98 AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
99 test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
104 if test $ac_cv_prog_gcc = yes; then
106 ac_libiberty_warn_cflags='-W -Wall -Wtraditional -pedantic'
107 dnl Check whether -g works, even if CFLAGS is set, in case the package
108 dnl plays around with CFLAGS (such as to build both debugging and
109 dnl normal versions of a library), tasteless as that idea is.
110 ac_test_CFLAGS="${CFLAGS+set}"
111 ac_save_CFLAGS="$CFLAGS"
114 if test "$ac_test_CFLAGS" = set; then
115 CFLAGS="$ac_save_CFLAGS"
116 elif test $ac_cv_prog_cc_g = yes; then
123 ac_libiberty_warn_cflags=
124 test "${CFLAGS+set}" = set || CFLAGS="-g"
126 AC_SUBST(ac_libiberty_warn_cflags)
129 # Work around a bug in autoheader. This can go away when we switch to
130 # autoconf >2.50. The use of define instead of AC_DEFUN is
132 define(AC_DEFINE_NOAUTOHEADER,
133 [cat >> confdefs.h <<\EOF
134 [#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1)