* MAINTAINERS: Remove self from specific maintenance domains
[deliverable/binutils-gdb.git] / libiberty / aclocal.m4
CommitLineData
eb383413
L
1dnl See whether strncmp reads past the end of its string parameters.
2dnl On some versions of SunOS4 at least, strncmp reads a word at a time
3dnl but erroneously reads past the end of strings. This can cause
4dnl a SEGV in some cases.
5AC_DEFUN(libiberty_AC_FUNC_STRNCMP,
6[AC_REQUIRE([AC_FUNC_MMAP])
7AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works,
8[AC_TRY_RUN([
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>
12
13#ifdef HAVE_FCNTL_H
14#include <fcntl.h>
15#endif
16
17#ifdef HAVE_SYS_MMAN_H
18#include <sys/mman.h>
19#endif
20
21#ifndef MAP_ANON
22#ifdef MAP_ANONYMOUS
23#define MAP_ANON MAP_ANONYMOUS
24#else
25#define MAP_ANON MAP_FILE
26#endif
27#endif
28
29#ifndef MAP_FILE
30#define MAP_FILE 0
31#endif
32#ifndef O_RDONLY
33#define O_RDONLY 0
34#endif
35
36#define MAP_LEN 0x10000
37
38main ()
39{
40#if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE)
41 char *p;
42 int dev_zero;
43
44 dev_zero = open ("/dev/zero", O_RDONLY);
45 if (dev_zero < 0)
46 exit (1);
47
48 p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE,
49 MAP_ANON|MAP_PRIVATE, dev_zero, 0);
50 if (p == (char *)-1)
51 exit (2);
52 else
53 {
54 char *string = "__si_type_info";
55 char *q = (char *) p + MAP_LEN - strlen (string) - 2;
56 char *r = (char *) p + 0xe;
57
58 strcpy (q, string);
59 strcpy (r, string);
60 strncmp (r, q, 14);
61 }
62#endif /* HAVE_MMAP || HAVE_MMAP_ANYWHERE */
63 exit (0);
64}
65], ac_cv_func_strncmp_works=yes, ac_cv_func_strncmp_works=no,
66 ac_cv_func_strncmp_works=no)
67rm -f core core.* *.core])
68if test $ac_cv_func_strncmp_works = no ; then
69 LIBOBJS="$LIBOBJS strncmp.o"
70fi
71])
7d3ffcaf
JL
72
73dnl See if errno must be declared even when <errno.h> is included.
74AC_DEFUN(libiberty_AC_DECLARE_ERRNO,
75[AC_CACHE_CHECK(whether errno must be declared, libiberty_cv_declare_errno,
76[AC_TRY_COMPILE(
77[#include <errno.h>],
78[int x = errno;],
79libiberty_cv_declare_errno=no,
80libiberty_cv_declare_errno=yes)])
81if test $libiberty_cv_declare_errno = yes
82then AC_DEFINE(NEED_DECLARATION_ERRNO, 1,
83 [Define if errno must be declared even when <errno.h> is included.])
84fi
85])
2ea7befd
DD
86
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
91# itself.
92
93AC_DEFUN(LIB_AC_PROG_CC,
94[AC_BEFORE([$0], [AC_PROG_CPP])dnl
95AC_PROVIDE([AC_PROG_CC])
96AC_CHECK_PROG(CC, gcc, gcc)
97if 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])
100fi
101
102AC_PROG_CC_GNU
103
104if test $ac_cv_prog_gcc = yes; then
105 GCC=yes
106 ac_libiberty_warn_cflags='-W -Wall -Wtraditional -pedantic'
107dnl Check whether -g works, even if CFLAGS is set, in case the package
108dnl plays around with CFLAGS (such as to build both debugging and
109dnl normal versions of a library), tasteless as that idea is.
110 ac_test_CFLAGS="${CFLAGS+set}"
111 ac_save_CFLAGS="$CFLAGS"
112 CFLAGS=
113 AC_PROG_CC_G
114 if test "$ac_test_CFLAGS" = set; then
115 CFLAGS="$ac_save_CFLAGS"
116 elif test $ac_cv_prog_cc_g = yes; then
117 CFLAGS="-g -O2"
118 else
119 CFLAGS="-O2"
120 fi
121else
122 GCC=
123 ac_libiberty_warn_cflags=
124 test "${CFLAGS+set}" = set || CFLAGS="-g"
125fi
126AC_SUBST(ac_libiberty_warn_cflags)
127])
128
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
131# deliberate.
132define(AC_DEFINE_NOAUTOHEADER,
133[cat >> confdefs.h <<\EOF
134[#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1)
135EOF
136])
30673bf5
DD
137
138# We always want a C version of alloca() compiled into libiberty,
139# because native-compiler support for the real alloca is so !@#$%
140# unreliable that GCC has decided to use it only when being compiled
141# by GCC. This is the part of AC_FUNC_ALLOCA that calculates the
142# information alloca.c needs.
143AC_DEFUN(libiberty_AC_FUNC_C_ALLOCA,
144[AC_CACHE_CHECK(whether alloca needs Cray hooks, ac_cv_os_cray,
145[AC_EGREP_CPP(webecray,
146[#if defined(CRAY) && ! defined(CRAY2)
147webecray
148#else
149wenotbecray
150#endif
151], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
152if test $ac_cv_os_cray = yes; then
153 for ac_func in _getb67 GETB67 getb67; do
154 AC_CHECK_FUNC($ac_func,
155 [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
156 [Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP
157 systems. This function is required for alloca.c support on those
158 systems.]) break])
159 done
160fi
161
162AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction,
163[AC_TRY_RUN([find_stack_direction ()
164{
165 static char *addr = 0;
166 auto char dummy;
167 if (addr == 0)
168 {
169 addr = &dummy;
170 return find_stack_direction ();
171 }
172 else
173 return (&dummy > addr) ? 1 : -1;
174}
175main ()
176{
177 exit (find_stack_direction() < 0);
178}],
179 ac_cv_c_stack_direction=1,
180 ac_cv_c_stack_direction=-1,
181 ac_cv_c_stack_direction=0)])
182AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction,
183 [Define if you know the direction of stack growth for your system;
184 otherwise it will be automatically deduced at run-time.
185 STACK_DIRECTION > 0 => grows toward higher addresses
186 STACK_DIRECTION < 0 => grows toward lower addresses
187 STACK_DIRECTION = 0 => direction of growth unknown])
188])
This page took 0.047057 seconds and 4 git commands to generate.