OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [libiberty/] [aclocal.m4] - Blame information for rev 818

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.