errno_h.m4 3.2 KB

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