Add hppa*-*-hpux* to targets which do not support split DWARF
[official-gcc.git] / libiberty / acinclude.m4
blob9974dcd4ec54b56726ca25b147f37453fc1347b9
1 dnl Copyright (C) 2000-2024 Free Software Foundation, Inc.
2 dnl
3 dnl GCC is free software; you can redistribute it and/or modify
4 dnl it under the terms of the GNU General Public License as published by
5 dnl the Free Software Foundation; either version 3, or (at your option)
6 dnl any later version.
7 dnl
8 dnl GCC is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
10 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 dnl GNU General Public License for more details.
12 dnl
13 dnl You should have received a copy of the GNU General Public License
14 dnl along with GCC; see the file COPYING3.  If not see
15 dnl <http://www.gnu.org/licenses/>.
17 dnl See whether strncmp reads past the end of its string parameters.
18 dnl On some versions of SunOS4 at least, strncmp reads a word at a time
19 dnl but erroneously reads past the end of strings.  This can cause
20 dnl a SEGV in some cases.
21 AC_DEFUN([libiberty_AC_FUNC_STRNCMP],
22 [AC_REQUIRE([AC_FUNC_MMAP])
23 AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works,
24 [AC_TRY_RUN([
25 /* Test by Jim Wilson and Kaveh Ghazi.
26    Check whether strncmp reads past the end of its string parameters. */
27 #include <stdlib.h>
28 #include <string.h>
29 #include <sys/types.h>
31 #ifdef HAVE_FCNTL_H
32 #include <fcntl.h>
33 #endif
35 #ifdef HAVE_SYS_MMAN_H
36 #include <sys/mman.h>
37 #endif
39 #ifndef MAP_ANON
40 #ifdef MAP_ANONYMOUS
41 #define MAP_ANON MAP_ANONYMOUS
42 #else
43 #define MAP_ANON MAP_FILE
44 #endif
45 #endif
47 #ifndef MAP_FILE
48 #define MAP_FILE 0
49 #endif
50 #ifndef O_RDONLY
51 #define O_RDONLY 0
52 #endif
54 #define MAP_LEN 0x10000
56 int
57 main (void)
59 #if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE)
60   char *p;
61   int dev_zero;
63   dev_zero = open ("/dev/zero", O_RDONLY);
64   if (dev_zero < 0)
65     exit (1);
67   p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE,
68                      MAP_ANON|MAP_PRIVATE, dev_zero, 0);
69   if (p == (char *)-1)
70     p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE,
71                        MAP_ANON|MAP_PRIVATE, -1, 0);
72   if (p == (char *)-1)
73     exit (2);
74   else
75     {
76       char *string = "__si_type_info";
77       char *q = (char *) p + MAP_LEN - strlen (string) - 2;
78       char *r = (char *) p + 0xe;
80       strcpy (q, string);
81       strcpy (r, string);
82       strncmp (r, q, 14);
83     }
84 #endif /* HAVE_MMAP || HAVE_MMAP_ANYWHERE */
85   exit (0);
87 ], ac_cv_func_strncmp_works=yes, ac_cv_func_strncmp_works=no,
88   ac_cv_func_strncmp_works=yes)
89 rm -f core core.* *.core])
90 if test $ac_cv_func_strncmp_works = no ; then
91   AC_LIBOBJ([strncmp])
95 dnl See if errno must be declared even when <errno.h> is included.
96 AC_DEFUN([libiberty_AC_DECLARE_ERRNO],
97 [AC_CACHE_CHECK(whether errno must be declared, libiberty_cv_declare_errno,
98 [AC_TRY_COMPILE(
99 [#include <errno.h>],
100 [int x = errno;],
101 libiberty_cv_declare_errno=no,
102 libiberty_cv_declare_errno=yes)])
103 if test $libiberty_cv_declare_errno = yes
104 then AC_DEFINE(NEED_DECLARATION_ERRNO, 1,
105   [Define if errno must be declared even when <errno.h> is included.])
109 dnl See whether we need a declaration for a function.
110 AC_DEFUN([libiberty_NEED_DECLARATION],
111 [AC_MSG_CHECKING([whether $1 must be declared])
112 AC_CACHE_VAL(libiberty_cv_decl_needed_$1,
113 [AC_TRY_COMPILE([
114 #include "confdefs.h"
115 #include <stdio.h>
116 #ifdef HAVE_STRING_H
117 #include <string.h>
118 #else
119 #ifdef HAVE_STRINGS_H
120 #include <strings.h>
121 #endif
122 #endif
123 #ifdef HAVE_STDLIB_H
124 #include <stdlib.h>
125 #endif
126 #ifdef HAVE_UNISTD_H
127 #include <unistd.h>
128 #endif],
129 [char *(*pfn) = (char *(*)) $1],
130 libiberty_cv_decl_needed_$1=no, libiberty_cv_decl_needed_$1=yes)])
131 AC_MSG_RESULT($libiberty_cv_decl_needed_$1)
132 if test $libiberty_cv_decl_needed_$1 = yes; then
133   AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1,
134             [Define if $1 is not declared in system header files.])
136 ])dnl
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.
143 AC_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)
147 webecray
148 #else
149 wenotbecray
150 #endif
151 ], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
152 if 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
162 AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction,
163 [AC_TRY_RUN([#include <stdlib.h>
166 find_stack_direction (void)
168   static char *addr = 0;
169   auto char dummy;
170   if (addr == 0)
171     {
172       addr = &dummy;
173       return find_stack_direction ();
174     }
175   else
176     return (&dummy > addr) ? 1 : -1;
180 main (void)
182   exit (find_stack_direction() < 0);
184   ac_cv_c_stack_direction=1,
185   ac_cv_c_stack_direction=-1,
186   ac_cv_c_stack_direction=0)])
187 AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction,
188   [Define if you know the direction of stack growth for your system;
189    otherwise it will be automatically deduced at run-time.
190         STACK_DIRECTION > 0 => grows toward higher addresses
191         STACK_DIRECTION < 0 => grows toward lower addresses
192         STACK_DIRECTION = 0 => direction of growth unknown])