errno_h.m4 3.0 KB

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