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