Commit | Line | Data |
---|---|---|
2299a76d | 1 | sinclude(../config/acx.m4) |
56b1e56d NC |
2 | sinclude(../config/cet.m4) |
3 | sinclude(../config/enable.m4) | |
50ad1254 | 4 | sinclude(../config/gcc-plugin.m4) |
2299a76d | 5 | sinclude(../config/no-executables.m4) |
5ae54241 | 6 | sinclude(../config/override.m4) |
601a99c6 | 7 | sinclude(../config/picflag.m4) |
a104c397 | 8 | sinclude(../config/warnings.m4) |
7108c5dc | 9 | |
eb383413 L |
10 | dnl See whether strncmp reads past the end of its string parameters. |
11 | dnl On some versions of SunOS4 at least, strncmp reads a word at a time | |
12 | dnl but erroneously reads past the end of strings. This can cause | |
13 | dnl a SEGV in some cases. | |
14 | AC_DEFUN(libiberty_AC_FUNC_STRNCMP, | |
15 | [AC_REQUIRE([AC_FUNC_MMAP]) | |
16 | AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works, | |
17 | [AC_TRY_RUN([ | |
18 | /* Test by Jim Wilson and Kaveh Ghazi. | |
19 | Check whether strncmp reads past the end of its string parameters. */ | |
20 | #include <sys/types.h> | |
21 | ||
22 | #ifdef HAVE_FCNTL_H | |
23 | #include <fcntl.h> | |
24 | #endif | |
25 | ||
26 | #ifdef HAVE_SYS_MMAN_H | |
27 | #include <sys/mman.h> | |
28 | #endif | |
29 | ||
30 | #ifndef MAP_ANON | |
31 | #ifdef MAP_ANONYMOUS | |
32 | #define MAP_ANON MAP_ANONYMOUS | |
33 | #else | |
34 | #define MAP_ANON MAP_FILE | |
35 | #endif | |
36 | #endif | |
37 | ||
38 | #ifndef MAP_FILE | |
39 | #define MAP_FILE 0 | |
40 | #endif | |
41 | #ifndef O_RDONLY | |
42 | #define O_RDONLY 0 | |
43 | #endif | |
44 | ||
45 | #define MAP_LEN 0x10000 | |
46 | ||
47 | main () | |
48 | { | |
49 | #if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE) | |
50 | char *p; | |
51 | int dev_zero; | |
52 | ||
53 | dev_zero = open ("/dev/zero", O_RDONLY); | |
54 | if (dev_zero < 0) | |
55 | exit (1); | |
56 | ||
57 | p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE, | |
58 | MAP_ANON|MAP_PRIVATE, dev_zero, 0); | |
f348a7b1 DD |
59 | if (p == (char *)-1) |
60 | p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE, | |
61 | MAP_ANON|MAP_PRIVATE, -1, 0); | |
eb383413 L |
62 | if (p == (char *)-1) |
63 | exit (2); | |
64 | else | |
65 | { | |
66 | char *string = "__si_type_info"; | |
67 | char *q = (char *) p + MAP_LEN - strlen (string) - 2; | |
68 | char *r = (char *) p + 0xe; | |
69 | ||
70 | strcpy (q, string); | |
71 | strcpy (r, string); | |
72 | strncmp (r, q, 14); | |
73 | } | |
74 | #endif /* HAVE_MMAP || HAVE_MMAP_ANYWHERE */ | |
75 | exit (0); | |
76 | } | |
77 | ], ac_cv_func_strncmp_works=yes, ac_cv_func_strncmp_works=no, | |
3fee530e | 78 | ac_cv_func_strncmp_works=yes) |
eb383413 L |
79 | rm -f core core.* *.core]) |
80 | if test $ac_cv_func_strncmp_works = no ; then | |
2299a76d | 81 | AC_LIBOBJ([strncmp]) |
eb383413 L |
82 | fi |
83 | ]) | |
7d3ffcaf JL |
84 | |
85 | dnl See if errno must be declared even when <errno.h> is included. | |
86 | AC_DEFUN(libiberty_AC_DECLARE_ERRNO, | |
87 | [AC_CACHE_CHECK(whether errno must be declared, libiberty_cv_declare_errno, | |
88 | [AC_TRY_COMPILE( | |
89 | [#include <errno.h>], | |
90 | [int x = errno;], | |
91 | libiberty_cv_declare_errno=no, | |
92 | libiberty_cv_declare_errno=yes)]) | |
93 | if test $libiberty_cv_declare_errno = yes | |
94 | then AC_DEFINE(NEED_DECLARATION_ERRNO, 1, | |
95 | [Define if errno must be declared even when <errno.h> is included.]) | |
96 | fi | |
97 | ]) | |
2ea7befd | 98 | |
ba61a412 DJ |
99 | dnl See whether we need a declaration for a function. |
100 | AC_DEFUN(libiberty_NEED_DECLARATION, | |
101 | [AC_MSG_CHECKING([whether $1 must be declared]) | |
102 | AC_CACHE_VAL(libiberty_cv_decl_needed_$1, | |
103 | [AC_TRY_COMPILE([ | |
104 | #include "confdefs.h" | |
105 | #include <stdio.h> | |
106 | #ifdef HAVE_STRING_H | |
107 | #include <string.h> | |
108 | #else | |
109 | #ifdef HAVE_STRINGS_H | |
110 | #include <strings.h> | |
111 | #endif | |
112 | #endif | |
113 | #ifdef HAVE_STDLIB_H | |
114 | #include <stdlib.h> | |
115 | #endif | |
116 | #ifdef HAVE_UNISTD_H | |
117 | #include <unistd.h> | |
118 | #endif], | |
119 | [char *(*pfn) = (char *(*)) $1], | |
120 | libiberty_cv_decl_needed_$1=no, libiberty_cv_decl_needed_$1=yes)]) | |
121 | AC_MSG_RESULT($libiberty_cv_decl_needed_$1) | |
122 | if test $libiberty_cv_decl_needed_$1 = yes; then | |
123 | AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1, | |
124 | [Define if $1 is not declared in system header files.]) | |
125 | fi | |
126 | ])dnl | |
127 | ||
30673bf5 DD |
128 | # We always want a C version of alloca() compiled into libiberty, |
129 | # because native-compiler support for the real alloca is so !@#$% | |
130 | # unreliable that GCC has decided to use it only when being compiled | |
131 | # by GCC. This is the part of AC_FUNC_ALLOCA that calculates the | |
132 | # information alloca.c needs. | |
133 | AC_DEFUN(libiberty_AC_FUNC_C_ALLOCA, | |
134 | [AC_CACHE_CHECK(whether alloca needs Cray hooks, ac_cv_os_cray, | |
135 | [AC_EGREP_CPP(webecray, | |
136 | [#if defined(CRAY) && ! defined(CRAY2) | |
137 | webecray | |
138 | #else | |
139 | wenotbecray | |
140 | #endif | |
141 | ], ac_cv_os_cray=yes, ac_cv_os_cray=no)]) | |
142 | if test $ac_cv_os_cray = yes; then | |
143 | for ac_func in _getb67 GETB67 getb67; do | |
144 | AC_CHECK_FUNC($ac_func, | |
145 | [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func, | |
146 | [Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP | |
147 | systems. This function is required for alloca.c support on those | |
148 | systems.]) break]) | |
149 | done | |
150 | fi | |
151 | ||
152 | AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction, | |
153 | [AC_TRY_RUN([find_stack_direction () | |
154 | { | |
155 | static char *addr = 0; | |
156 | auto char dummy; | |
157 | if (addr == 0) | |
158 | { | |
159 | addr = &dummy; | |
160 | return find_stack_direction (); | |
161 | } | |
162 | else | |
163 | return (&dummy > addr) ? 1 : -1; | |
164 | } | |
165 | main () | |
166 | { | |
167 | exit (find_stack_direction() < 0); | |
168 | }], | |
169 | ac_cv_c_stack_direction=1, | |
170 | ac_cv_c_stack_direction=-1, | |
171 | ac_cv_c_stack_direction=0)]) | |
172 | AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction, | |
173 | [Define if you know the direction of stack growth for your system; | |
174 | otherwise it will be automatically deduced at run-time. | |
175 | STACK_DIRECTION > 0 => grows toward higher addresses | |
176 | STACK_DIRECTION < 0 => grows toward lower addresses | |
177 | STACK_DIRECTION = 0 => direction of growth unknown]) | |
178 | ]) |