errno_h.m4 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. # errno_h.m4 serial 13
  2. dnl Copyright (C) 2004, 2006, 2008-2021 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_PREREQ([2.61])
  7. AC_DEFUN_ONCE([gl_HEADER_ERRNO_H],
  8. [
  9. AC_REQUIRE([AC_PROG_CC])
  10. AC_CACHE_CHECK([for complete errno.h], [gl_cv_header_errno_h_complete], [
  11. AC_EGREP_CPP([booboo],[
  12. #include <errno.h>
  13. #if !defined ETXTBSY
  14. booboo
  15. #endif
  16. #if !defined ENOMSG
  17. booboo
  18. #endif
  19. #if !defined EIDRM
  20. booboo
  21. #endif
  22. #if !defined ENOLINK
  23. booboo
  24. #endif
  25. #if !defined EPROTO
  26. booboo
  27. #endif
  28. #if !defined EMULTIHOP
  29. booboo
  30. #endif
  31. #if !defined EBADMSG
  32. booboo
  33. #endif
  34. #if !defined EOVERFLOW
  35. booboo
  36. #endif
  37. #if !defined ENOTSUP
  38. booboo
  39. #endif
  40. #if !defined ENETRESET
  41. booboo
  42. #endif
  43. #if !defined ECONNABORTED
  44. booboo
  45. #endif
  46. #if !defined ESTALE
  47. booboo
  48. #endif
  49. #if !defined EDQUOT
  50. booboo
  51. #endif
  52. #if !defined ECANCELED
  53. booboo
  54. #endif
  55. #if !defined EOWNERDEAD
  56. booboo
  57. #endif
  58. #if !defined ENOTRECOVERABLE
  59. booboo
  60. #endif
  61. #if !defined EILSEQ
  62. booboo
  63. #endif
  64. ],
  65. [gl_cv_header_errno_h_complete=no],
  66. [gl_cv_header_errno_h_complete=yes])
  67. ])
  68. if test $gl_cv_header_errno_h_complete = yes; then
  69. ERRNO_H=''
  70. else
  71. gl_NEXT_HEADERS([errno.h])
  72. ERRNO_H='errno.h'
  73. fi
  74. AC_SUBST([ERRNO_H])
  75. AM_CONDITIONAL([GL_GENERATE_ERRNO_H], [test -n "$ERRNO_H"])
  76. gl_REPLACE_ERRNO_VALUE([EMULTIHOP])
  77. gl_REPLACE_ERRNO_VALUE([ENOLINK])
  78. gl_REPLACE_ERRNO_VALUE([EOVERFLOW])
  79. ])
  80. # Assuming $1 = EOVERFLOW.
  81. # The EOVERFLOW errno value ought to be defined in <errno.h>, according to
  82. # POSIX. But some systems (like OpenBSD 4.0 or AIX 3) don't define it, and
  83. # some systems (like OSF/1) define it when _XOPEN_SOURCE_EXTENDED is defined.
  84. # Check for the value of EOVERFLOW.
  85. # Set the variables EOVERFLOW_HIDDEN and EOVERFLOW_VALUE.
  86. AC_DEFUN([gl_REPLACE_ERRNO_VALUE],
  87. [
  88. if test -n "$ERRNO_H"; then
  89. AC_CACHE_CHECK([for ]$1[ value], [gl_cv_header_errno_h_]$1, [
  90. AC_EGREP_CPP([yes],[
  91. #include <errno.h>
  92. #ifdef ]$1[
  93. yes
  94. #endif
  95. ],
  96. [gl_cv_header_errno_h_]$1[=yes],
  97. [gl_cv_header_errno_h_]$1[=no])
  98. if test $gl_cv_header_errno_h_]$1[ = no; then
  99. AC_EGREP_CPP([yes],[
  100. #define _XOPEN_SOURCE_EXTENDED 1
  101. #include <errno.h>
  102. #ifdef ]$1[
  103. yes
  104. #endif
  105. ], [gl_cv_header_errno_h_]$1[=hidden])
  106. if test $gl_cv_header_errno_h_]$1[ = hidden; then
  107. dnl The macro exists but is hidden.
  108. dnl Define it to the same value.
  109. AC_COMPUTE_INT([gl_cv_header_errno_h_]$1, $1, [
  110. #define _XOPEN_SOURCE_EXTENDED 1
  111. #include <errno.h>
  112. /* The following two lines are a workaround against an autoconf-2.52 bug. */
  113. #include <stdio.h>
  114. #include <stdlib.h>
  115. ])
  116. fi
  117. fi
  118. ])
  119. case $gl_cv_header_errno_h_]$1[ in
  120. yes | no)
  121. ]$1[_HIDDEN=0; ]$1[_VALUE=
  122. ;;
  123. *)
  124. ]$1[_HIDDEN=1; ]$1[_VALUE="$gl_cv_header_errno_h_]$1["
  125. ;;
  126. esac
  127. AC_SUBST($1[_HIDDEN])
  128. AC_SUBST($1[_VALUE])
  129. fi
  130. ])