aclocal.m4 revision 130561
1275970Scysinclude(../config/accross.m4) 2275970Scysinclude(../config/acx.m4) 3316722Sdelphijsinclude(../config/no-executables.m4) 4275970Scy 5275970Scydnl See whether strncmp reads past the end of its string parameters. 6275970Scydnl On some versions of SunOS4 at least, strncmp reads a word at a time 7275970Scydnl but erroneously reads past the end of strings. This can cause 8275970Scydnl a SEGV in some cases. 9275970ScyAC_DEFUN(libiberty_AC_FUNC_STRNCMP, 10275970Scy[AC_REQUIRE([AC_FUNC_MMAP]) 11316722SdelphijAC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works, 12316722Sdelphij[AC_TRY_RUN([ 13316722Sdelphij/* Test by Jim Wilson and Kaveh Ghazi. 14316722Sdelphij Check whether strncmp reads past the end of its string parameters. */ 15316722Sdelphij#include <sys/types.h> 16316722Sdelphij 17316722Sdelphij#ifdef HAVE_FCNTL_H 18316722Sdelphij#include <fcntl.h> 19275970Scy#endif 20316722Sdelphij 21316722Sdelphij#ifdef HAVE_SYS_MMAN_H 22316722Sdelphij#include <sys/mman.h> 23316722Sdelphij#endif 24275970Scy 25316722Sdelphij#ifndef MAP_ANON 26316722Sdelphij#ifdef MAP_ANONYMOUS 27275970Scy#define MAP_ANON MAP_ANONYMOUS 28275970Scy#else 29275970Scy#define MAP_ANON MAP_FILE 30275970Scy#endif 31316722Sdelphij#endif 32275970Scy 33275970Scy#ifndef MAP_FILE 34316722Sdelphij#define MAP_FILE 0 35275970Scy#endif 36275970Scy#ifndef O_RDONLY 37275970Scy#define O_RDONLY 0 38275970Scy#endif 39275970Scy 40275970Scy#define MAP_LEN 0x10000 41275970Scy 42275970Scymain () 43275970Scy{ 44275970Scy#if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE) 45275970Scy char *p; 46275970Scy int dev_zero; 47275970Scy 48275970Scy dev_zero = open ("/dev/zero", O_RDONLY); 49275970Scy if (dev_zero < 0) 50275970Scy exit (1); 51275970Scy 52275970Scy p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE, 53275970Scy MAP_ANON|MAP_PRIVATE, dev_zero, 0); 54275970Scy if (p == (char *)-1) 55275970Scy p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE, 56275970Scy MAP_ANON|MAP_PRIVATE, -1, 0); 57275970Scy if (p == (char *)-1) 58275970Scy exit (2); 59275970Scy else 60275970Scy { 61275970Scy char *string = "__si_type_info"; 62316722Sdelphij char *q = (char *) p + MAP_LEN - strlen (string) - 2; 63275970Scy char *r = (char *) p + 0xe; 64275970Scy 65275970Scy strcpy (q, string); 66275970Scy strcpy (r, string); 67275970Scy strncmp (r, q, 14); 68275970Scy } 69275970Scy#endif /* HAVE_MMAP || HAVE_MMAP_ANYWHERE */ 70275970Scy exit (0); 71275970Scy} 72275970Scy], ac_cv_func_strncmp_works=yes, ac_cv_func_strncmp_works=no, 73275970Scy ac_cv_func_strncmp_works=no) 74275970Scyrm -f core core.* *.core]) 75275970Scyif test $ac_cv_func_strncmp_works = no ; then 76275970Scy AC_LIBOBJ([strncmp]) 77275970Scyfi 78275970Scy]) 79275970Scy 80275970Scydnl See if errno must be declared even when <errno.h> is included. 81275970ScyAC_DEFUN(libiberty_AC_DECLARE_ERRNO, 82275970Scy[AC_CACHE_CHECK(whether errno must be declared, libiberty_cv_declare_errno, 83275970Scy[AC_TRY_COMPILE( 84275970Scy[#include <errno.h>], 85275970Scy[int x = errno;], 86316722Sdelphijlibiberty_cv_declare_errno=no, 87275970Scylibiberty_cv_declare_errno=yes)]) 88275970Scyif test $libiberty_cv_declare_errno = yes 89275970Scythen AC_DEFINE(NEED_DECLARATION_ERRNO, 1, 90275970Scy [Define if errno must be declared even when <errno.h> is included.]) 91275970Scyfi 92275970Scy]) 93275970Scy 94275970Scydnl See whether we need a declaration for a function. 95275970ScyAC_DEFUN(libiberty_NEED_DECLARATION, 96275970Scy[AC_MSG_CHECKING([whether $1 must be declared]) 97275970ScyAC_CACHE_VAL(libiberty_cv_decl_needed_$1, 98275970Scy[AC_TRY_COMPILE([ 99275970Scy#include "confdefs.h" 100275970Scy#include <stdio.h> 101275970Scy#ifdef HAVE_STRING_H 102275970Scy#include <string.h> 103275970Scy#else 104275970Scy#ifdef HAVE_STRINGS_H 105275970Scy#include <strings.h> 106316722Sdelphij#endif 107316722Sdelphij#endif 108316722Sdelphij#ifdef HAVE_STDLIB_H 109316722Sdelphij#include <stdlib.h> 110316722Sdelphij#endif 111316722Sdelphij#ifdef HAVE_UNISTD_H 112316722Sdelphij#include <unistd.h> 113316722Sdelphij#endif], 114316722Sdelphij[char *(*pfn) = (char *(*)) $1], 115316722Sdelphijlibiberty_cv_decl_needed_$1=no, libiberty_cv_decl_needed_$1=yes)]) 116316722SdelphijAC_MSG_RESULT($libiberty_cv_decl_needed_$1) 117316722Sdelphijif test $libiberty_cv_decl_needed_$1 = yes; then 118316722Sdelphij AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1, 119316722Sdelphij [Define if $1 is not declared in system header files.]) 120316722Sdelphijfi 121316722Sdelphij])dnl 122316722Sdelphij 123316722Sdelphij# Work around a bug in autoheader. This can go away when we switch to 124316722Sdelphij# autoconf >2.50. The use of define instead of AC_DEFUN is 125275970Scy# deliberate. 126275970Scydefine(AC_DEFINE_NOAUTOHEADER, 127316722Sdelphij[cat >> confdefs.h <<\EOF 128316722Sdelphij[#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1) 129316722SdelphijEOF 130275970Scy]) 131316722Sdelphij 132316722Sdelphij# We always want a C version of alloca() compiled into libiberty, 133316722Sdelphij# because native-compiler support for the real alloca is so !@#$% 134316722Sdelphij# unreliable that GCC has decided to use it only when being compiled 135316722Sdelphij# by GCC. This is the part of AC_FUNC_ALLOCA that calculates the 136275970Scy# information alloca.c needs. 137275970ScyAC_DEFUN(libiberty_AC_FUNC_C_ALLOCA, 138275970Scy[AC_CACHE_CHECK(whether alloca needs Cray hooks, ac_cv_os_cray, 139275970Scy[AC_EGREP_CPP(webecray, 140275970Scy[#if defined(CRAY) && ! defined(CRAY2) 141275970Scywebecray 142316722Sdelphij#else 143275970Scywenotbecray 144275970Scy#endif 145275970Scy], ac_cv_os_cray=yes, ac_cv_os_cray=no)]) 146275970Scyif test $ac_cv_os_cray = yes; then 147275970Scy for ac_func in _getb67 GETB67 getb67; do 148275970Scy AC_CHECK_FUNC($ac_func, 149275970Scy [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func, 150275970Scy [Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP 151275970Scy systems. This function is required for alloca.c support on those 152275970Scy systems.]) break]) 153275970Scy done 154275970Scyfi 155275970Scy 156275970ScyAC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction, 157275970Scy[AC_TRY_RUN([find_stack_direction () 158316722Sdelphij{ 159316722Sdelphij static char *addr = 0; 160275970Scy auto char dummy; 161275970Scy if (addr == 0) 162275970Scy { 163275970Scy addr = &dummy; 164275970Scy return find_stack_direction (); 165275970Scy } 166275970Scy else 167275970Scy return (&dummy > addr) ? 1 : -1; 168275970Scy} 169275970Scymain () 170275970Scy{ 171275970Scy exit (find_stack_direction() < 0); 172275970Scy}], 173275970Scy ac_cv_c_stack_direction=1, 174275970Scy ac_cv_c_stack_direction=-1, 175275970Scy ac_cv_c_stack_direction=0)]) 176275970ScyAC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction, 177275970Scy [Define if you know the direction of stack growth for your system; 178275970Scy otherwise it will be automatically deduced at run-time. 179275970Scy STACK_DIRECTION > 0 => grows toward higher addresses 180275970Scy STACK_DIRECTION < 0 => grows toward lower addresses 181275970Scy STACK_DIRECTION = 0 => direction of growth unknown]) 182275970Scy]) 183275970Scy 184275970Scy# AC_LANG_FUNC_LINK_TRY(C)(FUNCTION) 185275970Scy# ---------------------------------- 186275970Scy# Don't include <ctype.h> because on OSF/1 3.0 it includes 187275970Scy# <sys/types.h> which includes <sys/select.h> which contains a 188275970Scy# prototype for select. Similarly for bzero. 189316722Sdelphij# 190275970Scy# This test used to merely assign f=$1 in main(), but that was 191275970Scy# optimized away by HP unbundled cc A.05.36 for ia64 under +O3, 192316722Sdelphij# presumably on the basis that there's no need to do that store if the 193275970Scy# program is about to exit. Conversely, the AIX linker optimizes an 194316722Sdelphij# unused external declaration that initializes f=$1. So this test 195275970Scy# program has both an external initialization of f, and a use of f in 196275970Scy# main that affects the exit status. 197275970Scy# 198316722Sdelphijm4_define([AC_LANG_FUNC_LINK_TRY(C)], 199275970Scy[AC_LANG_PROGRAM( 200275970Scy[/* System header to define __stub macros and hopefully few prototypes, 201275970Scy which can conflict with char $1 (); below. 202275970Scy Prefer <limits.h> to <assert.h> if __STDC__ is defined, since 203275970Scy <limits.h> exists even on freestanding compilers. Under hpux, 204275970Scy including <limits.h> includes <sys/time.h> and causes problems 205275970Scy checking for functions defined therein. */ 206275970Scy#if defined (__STDC__) && !defined (_HPUX_SOURCE) 207275970Scy# include <limits.h> 208275970Scy#else 209275970Scy# include <assert.h> 210275970Scy#endif 211316722Sdelphij/* Override any gcc2 internal prototype to avoid an error. */ 212275970Scy#ifdef __cplusplus 213275970Scyextern "C" 214275970Scy{ 215275970Scy#endif 216275970Scy/* We use char because int might match the return type of a gcc2 217275970Scy builtin and then its argument prototype would still apply. */ 218275970Scychar $1 (); 219275970Scy/* The GNU C library defines this for functions which it implements 220275970Scy to always fail with ENOSYS. Some functions are actually named 221275970Scy something starting with __ and the normal name is an alias. */ 222316722Sdelphij#if defined (__stub_$1) || defined (__stub___$1) 223275970Scychoke me 224275970Scy#else 225275970Scychar (*f) () = $1; 226316722Sdelphij#endif 227275970Scy#ifdef __cplusplus 228316722Sdelphij} 229316722Sdelphij#endif 230275970Scy], [return f != $1;])]) 231275970Scy 232275970Scy