stdlib_h.m4 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. # stdlib_h.m4 serial 66
  2. dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. AC_DEFUN_ONCE([gl_STDLIB_H],
  7. [
  8. AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
  9. gl_NEXT_HEADERS([stdlib.h])
  10. dnl Check for declarations of anything we want to poison if the
  11. dnl corresponding gnulib module is not in use, and which is not
  12. dnl guaranteed by C89.
  13. gl_WARN_ON_USE_PREPARE([[#include <stdlib.h>
  14. #if HAVE_SYS_LOADAVG_H
  15. /* OpenIndiana has a bug: <sys/time.h> must be included before
  16. <sys/loadavg.h>. */
  17. # include <sys/time.h>
  18. # include <sys/loadavg.h>
  19. #endif
  20. #if HAVE_RANDOM_H
  21. # include <random.h>
  22. #endif
  23. ]], [_Exit aligned_alloc atoll canonicalize_file_name free
  24. getloadavg getsubopt grantpt
  25. initstate initstate_r mbtowc mkdtemp mkostemp mkostemps mkstemp mkstemps
  26. posix_memalign posix_openpt ptsname ptsname_r qsort_r
  27. random random_r reallocarray realpath rpmatch secure_getenv setenv
  28. setstate setstate_r srandom srandom_r
  29. strtod strtol strtold strtoll strtoul strtoull unlockpt unsetenv])
  30. AC_REQUIRE([AC_C_RESTRICT])
  31. AC_CHECK_DECLS_ONCE([ecvt])
  32. if test $ac_cv_have_decl_ecvt = no; then
  33. HAVE_DECL_ECVT=0
  34. fi
  35. AC_CHECK_DECLS_ONCE([fcvt])
  36. if test $ac_cv_have_decl_fcvt = no; then
  37. HAVE_DECL_FCVT=0
  38. fi
  39. AC_CHECK_DECLS_ONCE([gcvt])
  40. if test $ac_cv_have_decl_gcvt = no; then
  41. HAVE_DECL_GCVT=0
  42. fi
  43. ])
  44. # gl_STDLIB_MODULE_INDICATOR([modulename])
  45. # sets the shell variable that indicates the presence of the given module
  46. # to a C preprocessor expression that will evaluate to 1.
  47. # This macro invocation must not occur in macros that are AC_REQUIREd.
  48. AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
  49. [
  50. dnl Ensure to expand the default settings once only.
  51. gl_STDLIB_H_REQUIRE_DEFAULTS
  52. gl_MODULE_INDICATOR_SET_VARIABLE([$1])
  53. dnl Define it also as a C macro, for the benefit of the unit tests.
  54. gl_MODULE_INDICATOR_FOR_TESTS([$1])
  55. ])
  56. # Initializes the default values for AC_SUBSTed shell variables.
  57. # This macro must not be AC_REQUIREd. It must only be invoked, and only
  58. # outside of macros or in macros that are not AC_REQUIREd.
  59. AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS],
  60. [
  61. m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDLIB_H_MODULE_INDICATOR_DEFAULTS], [
  62. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB__EXIT])
  63. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ALIGNED_ALLOC])
  64. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATOLL])
  65. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CALLOC_GNU])
  66. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CALLOC_POSIX])
  67. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CANONICALIZE_FILE_NAME])
  68. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREE_POSIX])
  69. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOADAVG])
  70. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSUBOPT])
  71. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GRANTPT])
  72. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_GNU])
  73. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_POSIX])
  74. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBTOWC])
  75. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDTEMP])
  76. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKOSTEMP])
  77. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKOSTEMPS])
  78. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKSTEMP])
  79. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKSTEMPS])
  80. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_MEMALIGN])
  81. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_OPENPT])
  82. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTSNAME])
  83. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTSNAME_R])
  84. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTENV])
  85. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_QSORT_R])
  86. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM])
  87. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM_R])
  88. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOCARRAY])
  89. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_GNU])
  90. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_POSIX])
  91. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALPATH])
  92. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RPMATCH])
  93. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SECURE_GETENV])
  94. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETENV])
  95. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOD])
  96. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOL])
  97. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOLD])
  98. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOLL])
  99. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOUL])
  100. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOULL])
  101. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SYSTEM_POSIX])
  102. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNLOCKPT])
  103. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNSETENV])
  104. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTOMB])
  105. dnl Support Microsoft deprecated alias function names by default.
  106. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_ECVT], [1])
  107. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FCVT], [1])
  108. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GCVT], [1])
  109. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_MKTEMP], [1])
  110. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_PUTENV], [1])
  111. ])
  112. m4_require(GL_MODULE_INDICATOR_PREFIX[_STDLIB_H_MODULE_INDICATOR_DEFAULTS])
  113. AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
  114. ])
  115. AC_DEFUN([gl_STDLIB_H_DEFAULTS],
  116. [
  117. dnl Assume proper GNU behavior unless another module says otherwise.
  118. HAVE__EXIT=1; AC_SUBST([HAVE__EXIT])
  119. HAVE_ALIGNED_ALLOC=1; AC_SUBST([HAVE_ALIGNED_ALLOC])
  120. HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL])
  121. HAVE_CANONICALIZE_FILE_NAME=1; AC_SUBST([HAVE_CANONICALIZE_FILE_NAME])
  122. HAVE_DECL_ECVT=1; AC_SUBST([HAVE_DECL_ECVT])
  123. HAVE_DECL_FCVT=1; AC_SUBST([HAVE_DECL_FCVT])
  124. HAVE_DECL_GCVT=1; AC_SUBST([HAVE_DECL_GCVT])
  125. HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG])
  126. HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT])
  127. HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT])
  128. HAVE_INITSTATE=1; AC_SUBST([HAVE_INITSTATE])
  129. HAVE_DECL_INITSTATE=1; AC_SUBST([HAVE_DECL_INITSTATE])
  130. HAVE_MBTOWC=1; AC_SUBST([HAVE_MBTOWC])
  131. HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP])
  132. HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP])
  133. HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS])
  134. HAVE_MKSTEMP=1; AC_SUBST([HAVE_MKSTEMP])
  135. HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS])
  136. HAVE_POSIX_MEMALIGN=1; AC_SUBST([HAVE_POSIX_MEMALIGN])
  137. HAVE_POSIX_OPENPT=1; AC_SUBST([HAVE_POSIX_OPENPT])
  138. HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME])
  139. HAVE_PTSNAME_R=1; AC_SUBST([HAVE_PTSNAME_R])
  140. HAVE_QSORT_R=1; AC_SUBST([HAVE_QSORT_R])
  141. HAVE_RANDOM=1; AC_SUBST([HAVE_RANDOM])
  142. HAVE_RANDOM_H=1; AC_SUBST([HAVE_RANDOM_H])
  143. HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R])
  144. HAVE_REALLOCARRAY=1; AC_SUBST([HAVE_REALLOCARRAY])
  145. HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH])
  146. HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH])
  147. HAVE_SECURE_GETENV=1; AC_SUBST([HAVE_SECURE_GETENV])
  148. HAVE_SETENV=1; AC_SUBST([HAVE_SETENV])
  149. HAVE_DECL_SETENV=1; AC_SUBST([HAVE_DECL_SETENV])
  150. HAVE_SETSTATE=1; AC_SUBST([HAVE_SETSTATE])
  151. HAVE_DECL_SETSTATE=1; AC_SUBST([HAVE_DECL_SETSTATE])
  152. HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD])
  153. HAVE_STRTOL=1; AC_SUBST([HAVE_STRTOL])
  154. HAVE_STRTOLD=1; AC_SUBST([HAVE_STRTOLD])
  155. HAVE_STRTOLL=1; AC_SUBST([HAVE_STRTOLL])
  156. HAVE_STRTOUL=1; AC_SUBST([HAVE_STRTOUL])
  157. HAVE_STRTOULL=1; AC_SUBST([HAVE_STRTOULL])
  158. HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA])
  159. HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H])
  160. HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT])
  161. HAVE_DECL_UNSETENV=1; AC_SUBST([HAVE_DECL_UNSETENV])
  162. REPLACE_ALIGNED_ALLOC=0; AC_SUBST([REPLACE_ALIGNED_ALLOC])
  163. REPLACE_CALLOC_FOR_CALLOC_GNU=0; AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_GNU])
  164. REPLACE_CALLOC_FOR_CALLOC_POSIX=0; AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_POSIX])
  165. REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME])
  166. REPLACE_FREE=0; AC_SUBST([REPLACE_FREE])
  167. REPLACE_INITSTATE=0; AC_SUBST([REPLACE_INITSTATE])
  168. REPLACE_MALLOC_FOR_MALLOC_GNU=0; AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_GNU])
  169. REPLACE_MALLOC_FOR_MALLOC_POSIX=0; AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_POSIX])
  170. REPLACE_MBTOWC=0; AC_SUBST([REPLACE_MBTOWC])
  171. REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP])
  172. REPLACE_POSIX_MEMALIGN=0; AC_SUBST([REPLACE_POSIX_MEMALIGN])
  173. REPLACE_PTSNAME=0; AC_SUBST([REPLACE_PTSNAME])
  174. REPLACE_PTSNAME_R=0; AC_SUBST([REPLACE_PTSNAME_R])
  175. REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV])
  176. REPLACE_QSORT_R=0; AC_SUBST([REPLACE_QSORT_R])
  177. REPLACE_RANDOM=0; AC_SUBST([REPLACE_RANDOM])
  178. REPLACE_RANDOM_R=0; AC_SUBST([REPLACE_RANDOM_R])
  179. REPLACE_REALLOC_FOR_REALLOC_GNU=0; AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_GNU])
  180. REPLACE_REALLOC_FOR_REALLOC_POSIX=0; AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_POSIX])
  181. REPLACE_REALLOCARRAY=0; AC_SUBST([REPLACE_REALLOCARRAY])
  182. REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH])
  183. REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV])
  184. REPLACE_SETSTATE=0; AC_SUBST([REPLACE_SETSTATE])
  185. REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD])
  186. REPLACE_STRTOL=0; AC_SUBST([REPLACE_STRTOL])
  187. REPLACE_STRTOLD=0; AC_SUBST([REPLACE_STRTOLD])
  188. REPLACE_STRTOLL=0; AC_SUBST([REPLACE_STRTOLL])
  189. REPLACE_STRTOUL=0; AC_SUBST([REPLACE_STRTOUL])
  190. REPLACE_STRTOULL=0; AC_SUBST([REPLACE_STRTOULL])
  191. REPLACE_UNSETENV=0; AC_SUBST([REPLACE_UNSETENV])
  192. REPLACE_WCTOMB=0; AC_SUBST([REPLACE_WCTOMB])
  193. ])