aclocal.m4 4.7 KB

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