]> git.ipfire.org Git - thirdparty/gcc.git/blob - libiberty/aclocal.m4
Makefile.in (top_builddir): Set to `.'.
[thirdparty/gcc.git] / libiberty / aclocal.m4
1 sinclude(../config/accross.m4)
2 sinclude(../config/acx.m4)
3 sinclude(../config/no-executables.m4)
4 sinclude(../libtool.m4)
5
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,
13 [AC_TRY_RUN([
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>
17
18 #ifdef HAVE_FCNTL_H
19 #include <fcntl.h>
20 #endif
21
22 #ifdef HAVE_SYS_MMAN_H
23 #include <sys/mman.h>
24 #endif
25
26 #ifndef MAP_ANON
27 #ifdef MAP_ANONYMOUS
28 #define MAP_ANON MAP_ANONYMOUS
29 #else
30 #define MAP_ANON MAP_FILE
31 #endif
32 #endif
33
34 #ifndef MAP_FILE
35 #define MAP_FILE 0
36 #endif
37 #ifndef O_RDONLY
38 #define O_RDONLY 0
39 #endif
40
41 #define MAP_LEN 0x10000
42
43 main ()
44 {
45 #if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE)
46 char *p;
47 int dev_zero;
48
49 dev_zero = open ("/dev/zero", O_RDONLY);
50 if (dev_zero < 0)
51 exit (1);
52
53 p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE,
54 MAP_ANON|MAP_PRIVATE, dev_zero, 0);
55 if (p == (char *)-1)
56 p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE,
57 MAP_ANON|MAP_PRIVATE, -1, 0);
58 if (p == (char *)-1)
59 exit (2);
60 else
61 {
62 char *string = "__si_type_info";
63 char *q = (char *) p + MAP_LEN - strlen (string) - 2;
64 char *r = (char *) p + 0xe;
65
66 strcpy (q, string);
67 strcpy (r, string);
68 strncmp (r, q, 14);
69 }
70 #endif /* HAVE_MMAP || HAVE_MMAP_ANYWHERE */
71 exit (0);
72 }
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
77 AC_LIBOBJ([strncmp])
78 fi
79 ])
80
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,
84 [AC_TRY_COMPILE(
85 [#include <errno.h>],
86 [int x = 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.])
92 fi
93 ])
94
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,
99 [AC_TRY_COMPILE([
100 #include "confdefs.h"
101 #include <stdio.h>
102 #ifdef HAVE_STRING_H
103 #include <string.h>
104 #else
105 #ifdef HAVE_STRINGS_H
106 #include <strings.h>
107 #endif
108 #endif
109 #ifdef HAVE_STDLIB_H
110 #include <stdlib.h>
111 #endif
112 #ifdef HAVE_UNISTD_H
113 #include <unistd.h>
114 #endif],
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.])
121 fi
122 ])dnl
123
124 # Work around a bug in autoheader. This can go away when we switch to
125 # autoconf >2.50. The use of define instead of AC_DEFUN is
126 # deliberate.
127 define(AC_DEFINE_NOAUTOHEADER,
128 [cat >> confdefs.h <<\EOF
129 [#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1)
130 EOF
131 ])
132
133 # We always want a C version of alloca() compiled into libiberty,
134 # because native-compiler support for the real alloca is so !@#$%
135 # unreliable that GCC has decided to use it only when being compiled
136 # by GCC. This is the part of AC_FUNC_ALLOCA that calculates the
137 # information alloca.c needs.
138 AC_DEFUN(libiberty_AC_FUNC_C_ALLOCA,
139 [AC_CACHE_CHECK(whether alloca needs Cray hooks, ac_cv_os_cray,
140 [AC_EGREP_CPP(webecray,
141 [#if defined(CRAY) && ! defined(CRAY2)
142 webecray
143 #else
144 wenotbecray
145 #endif
146 ], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
147 if test $ac_cv_os_cray = yes; then
148 for ac_func in _getb67 GETB67 getb67; do
149 AC_CHECK_FUNC($ac_func,
150 [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
151 [Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP
152 systems. This function is required for alloca.c support on those
153 systems.]) break])
154 done
155 fi
156
157 AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction,
158 [AC_TRY_RUN([find_stack_direction ()
159 {
160 static char *addr = 0;
161 auto char dummy;
162 if (addr == 0)
163 {
164 addr = &dummy;
165 return find_stack_direction ();
166 }
167 else
168 return (&dummy > addr) ? 1 : -1;
169 }
170 main ()
171 {
172 exit (find_stack_direction() < 0);
173 }],
174 ac_cv_c_stack_direction=1,
175 ac_cv_c_stack_direction=-1,
176 ac_cv_c_stack_direction=0)])
177 AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction,
178 [Define if you know the direction of stack growth for your system;
179 otherwise it will be automatically deduced at run-time.
180 STACK_DIRECTION > 0 => grows toward higher addresses
181 STACK_DIRECTION < 0 => grows toward lower addresses
182 STACK_DIRECTION = 0 => direction of growth unknown])
183 ])
184
185 # AC_LANG_FUNC_LINK_TRY(C)(FUNCTION)
186 # ----------------------------------
187 # Don't include <ctype.h> because on OSF/1 3.0 it includes
188 # <sys/types.h> which includes <sys/select.h> which contains a
189 # prototype for select. Similarly for bzero.
190 #
191 # This test used to merely assign f=$1 in main(), but that was
192 # optimized away by HP unbundled cc A.05.36 for ia64 under +O3,
193 # presumably on the basis that there's no need to do that store if the
194 # program is about to exit. Conversely, the AIX linker optimizes an
195 # unused external declaration that initializes f=$1. So this test
196 # program has both an external initialization of f, and a use of f in
197 # main that affects the exit status.
198 #
199 m4_define([AC_LANG_FUNC_LINK_TRY(C)],
200 [AC_LANG_PROGRAM(
201 [/* System header to define __stub macros and hopefully few prototypes,
202 which can conflict with char $1 (); below.
203 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
204 <limits.h> exists even on freestanding compilers. Under hpux,
205 including <limits.h> includes <sys/time.h> and causes problems
206 checking for functions defined therein. */
207 #if defined (__STDC__) && !defined (_HPUX_SOURCE)
208 # include <limits.h>
209 #else
210 # include <assert.h>
211 #endif
212 /* Override any gcc2 internal prototype to avoid an error. */
213 #ifdef __cplusplus
214 extern "C"
215 {
216 #endif
217 /* We use char because int might match the return type of a gcc2
218 builtin and then its argument prototype would still apply. */
219 char $1 ();
220 /* The GNU C library defines this for functions which it implements
221 to always fail with ENOSYS. Some functions are actually named
222 something starting with __ and the normal name is an alias. */
223 #if defined (__stub_$1) || defined (__stub___$1)
224 choke me
225 #else
226 char (*f) () = $1;
227 #endif
228 #ifdef __cplusplus
229 }
230 #endif
231 ], [return f != $1;])])
232