3 dnl Copyright (C) 2004, 2006, 2008-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
10 AC_DEFUN_ONCE([gl_HEADER_ERRNO_H],
12 AC_REQUIRE([AC_PROG_CC])
13 AC_CACHE_CHECK([for complete errno.h], [gl_cv_header_errno_h_complete], [
14 AC_EGREP_CPP([booboo],[
31 #if !defined EMULTIHOP
37 #if !defined EOVERFLOW
43 #if !defined ENETRESET
46 #if !defined ECONNABORTED
55 #if !defined ECANCELED
58 #if !defined EOWNERDEAD
61 #if !defined ENOTRECOVERABLE
68 [gl_cv_header_errno_h_complete=no],
69 [gl_cv_header_errno_h_complete=yes])
71 if test $gl_cv_header_errno_h_complete = yes; then
72 GL_GENERATE_ERRNO_H=false
74 gl_NEXT_HEADERS([errno.h])
75 GL_GENERATE_ERRNO_H=true
77 gl_REPLACE_ERRNO_VALUE([EMULTIHOP])
78 gl_REPLACE_ERRNO_VALUE([ENOLINK])
79 gl_REPLACE_ERRNO_VALUE([EOVERFLOW])
82 # Assuming $1 = EOVERFLOW.
83 # The EOVERFLOW errno value ought to be defined in <errno.h>, according to
84 # POSIX. But some systems (like OpenBSD 4.0 or AIX 3) don't define it, and
85 # some systems (like OSF/1) define it when _XOPEN_SOURCE_EXTENDED is defined.
86 # Check for the value of EOVERFLOW.
87 # Set the variables EOVERFLOW_HIDDEN and EOVERFLOW_VALUE.
88 AC_DEFUN([gl_REPLACE_ERRNO_VALUE],
90 if $GL_GENERATE_ERRNO_H; then
91 AC_CACHE_CHECK([for ]$1[ value], [gl_cv_header_errno_h_]$1, [
98 [gl_cv_header_errno_h_]$1[=yes],
99 [gl_cv_header_errno_h_]$1[=no])
100 if test $gl_cv_header_errno_h_]$1[ = no; then
102 #define _XOPEN_SOURCE_EXTENDED 1
107 ], [gl_cv_header_errno_h_]$1[=hidden])
108 if test $gl_cv_header_errno_h_]$1[ = hidden; then
109 dnl The macro exists but is hidden.
110 dnl Define it to the same value.
111 AC_COMPUTE_INT([gl_cv_header_errno_h_]$1, $1, [
112 #define _XOPEN_SOURCE_EXTENDED 1
114 /* The following two lines are a workaround against an autoconf-2.52 bug. */
121 case $gl_cv_header_errno_h_]$1[ in
123 ]$1[_HIDDEN=0; ]$1[_VALUE=
126 ]$1[_HIDDEN=1; ]$1[_VALUE="$gl_cv_header_errno_h_]$1["
129 AC_SUBST($1[_HIDDEN])