[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
new module 'errno'
From: |
Bruno Haible |
Subject: |
new module 'errno' |
Date: |
Sun, 14 Sep 2008 00:41:04 +0200 |
User-agent: |
KMail/1.5.4 |
Hi Paolo and others,
Here's the module 'errno'. It provides a complete POSIX <errno.h>.
With this, the conversion function from a WSAGetLastError() value to an
errno value is
e -> (e < 10025 ? e - 10000 :
e == WSAENAMETOOLONG ? ENAMETOOLONG :
e == WSAENOTEMPTY ; ENOTEMPTY :
e);
The two special cases are needed for WSAENAMETOOLONG and WSAENOTEMPTY
because they already exist as errno values in the system's <errno.h>.
2008-09-13 Bruno Haible <address@hidden>
* lib/errno.in.h: New file.
* m4/errno_h.m4: New file, borrowing from m4/eoverflow.m4.
* modules/errno: New file.
* doc/posix-headers/errno.texi: Update documentation.
* MODULES.html.sh (Support for systems lacking POSIX:2001): Add errno.
============================= lib/errno.in.h ================================
/* A POSIX-like <errno.h>.
Copyright (C) 2008 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef _GL_ERRNO_H
@PRAGMA_SYSTEM_HEADER@
/* The include_next requires a split double-inclusion guard. */
address@hidden@ @NEXT_ERRNO_H@
#ifndef _GL_ERRNO_H
#define _GL_ERRNO_H
/* On native Windows platforms, many macros are not defined. */
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
/* Values >= 100 seem safe to use. */
# define ETXTBSY 100
# define GNULIB_defined_ETXTBSY 1
/* These are intentionally the same values as the WSA* error numbers, defined
in <winsock2.h>. */
# define EWOULDBLOCK 10035
# define EINPROGRESS 10036
# define EALREADY 10037
# define ENOTSOCK 10038
# define EDESTADDRREQ 10039
# define EMSGSIZE 10040
# define EPROTOTYPE 10041
# define ENOPROTOOPT 10042
# define EPROTONOSUPPORT 10043
# define ESOCKTNOSUPPORT 10044 /* not required by POSIX */
# define EOPNOTSUPP 10045
# define EPFNOSUPPORT 10046 /* not required by POSIX */
# define EAFNOSUPPORT 10047
# define EADDRINUSE 10048
# define EADDRNOTAVAIL 10049
# define ENETDOWN 10050
# define ENETUNREACH 10051
# define ENETRESET 10052
# define ECONNABORTED 10053
# define ECONNRESET 10054
# define ENOBUFS 10055
# define EISCONN 10056
# define ENOTCONN 10057
# define ESHUTDOWN 10058 /* not required by POSIX */
# define ETOOMANYREFS 10059 /* not required by POSIX */
# define ETIMEDOUT 10060
# define ECONNREFUSED 10061
# define ELOOP 10062
# define EHOSTDOWN 10064 /* not required by POSIX */
# define EHOSTUNREACH 10065
# define EPROCLIM 10067 /* not required by POSIX */
# define EUSERS 10068 /* not required by POSIX */
# define EDQUOT 10069
# define ESTALE 10070
# define EREMOTE 10071 /* not required by POSIX */
# define GNULIB_defined_ESOCK 1
# endif
/* On OSF/1 5.1, when _XOPEN_SOURCE_EXTENDED is not defined, the macros
EMULTIHOP, ENOLINK, EOVERFLOW are not defined. */
# if @EMULTIHOP_HIDDEN@
# define EMULTIHOP @EMULTIHOP_VALUE@
# define GNULIB_defined_EMULTIHOP 1
# endif
# if @ENOLINK_HIDDEN@
# define ENOLINK @ENOLINK_VALUE@
# define GNULIB_defined_ENOLINK 1
# endif
# if @EOVERFLOW_HIDDEN@
# define EOVERFLOW @EOVERFLOW_VALUE@
# define GNULIB_defined_EOVERFLOW 1
# endif
/* On OpenBSD 4.0 and on native Windows, the macros ENOMSG, EIDRM, ENOLINK,
EPROTO, EMULTIHOP, EBADMSG, EOVERFLOW, ENOTSUP, ECANCELED are not defined.
Define them here. Values >= 128 seem safe to use.
Note: When one of these systems defines some of these macros some day,
binaries will have to be recompiled so that they recognizes the new
errno values from the system. */
# ifndef ENOMSG
# define ENOMSG 128
# define GNULIB_defined_ENOMSG 1
# endif
# ifndef EIDRM
# define EIDRM 129
# define GNULIB_defined_EIDRM 1
# endif
# ifndef ENOLINK
# define ENOLINK 130
# define GNULIB_defined_ENOLINK 1
# endif
# ifndef EPROTO
# define EPROTO 131
# define GNULIB_defined_EPROTO 1
# endif
# ifndef EMULTIHOP
# define EMULTIHOP 132
# define GNULIB_defined_EMULTIHOP 1
# endif
# ifndef EBADMSG
# define EBADMSG 133
# define GNULIB_defined_EBADMSG 1
# endif
# ifndef EOVERFLOW
# define EOVERFLOW 134
# define GNULIB_defined_EOVERFLOW 1
# endif
# ifndef ENOTSUP
# define ENOTSUP 135
# define GNULIB_defined_ENOTSUP 1
# endif
# ifndef ECANCELED
# define ECANCELED 136
# define GNULIB_defined_ECANCELED 1
# endif
#endif /* _GL_ERRNO_H */
#endif /* _GL_ERRNO_H */
============================= m4/errno_h.m4 =================================
# errno_h.m4 serial 1
dnl Copyright (C) 2004, 2006, 2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_HEADER_ERRNO_H],
[
dnl Use AC_REQUIRE here, so that the default behavior below is expanded
dnl once only, before all statements that occur in other macros.
AC_REQUIRE([gl_HEADER_ERRNO_H_BODY])
])
AC_DEFUN([gl_HEADER_ERRNO_H_BODY],
[
AC_REQUIRE([AC_PROG_CC])
AC_CACHE_CHECK([for complete errno.h], gl_cv_header_errno_h_complete, [
AC_EGREP_CPP(booboo,[
#include <errno.h>
#ifndef EOVERFLOW
booboo
#endif
],
[gl_cv_header_errno_h_complete=no],
[gl_cv_header_errno_h_complete=yes])
])
if test $gl_cv_header_errno_h_complete = yes; then
ERRNO_H=''
else
gl_CHECK_NEXT_HEADERS([errno.h])
ERRNO_H='errno.h'
fi
AC_SUBST([ERRNO_H])
gl_REPLACE_ERRNO_VALUE([EMULTIHOP])
gl_REPLACE_ERRNO_VALUE([ENOLINK])
gl_REPLACE_ERRNO_VALUE([EOVERFLOW])
])
# Assuming $1 = EOVERFLOW.
# The EOVERFLOW errno value ought to be defined in <errno.h>, according to
# POSIX. But some systems (like OpenBSD 4.0 or AIX 3) don't define it, and
# some systems (like OSF/1) define it when _XOPEN_SOURCE_EXTENDED is defined.
# Check for the value of EOVERFLOW.
# Set the variables EOVERFLOW_HIDDEN and EOVERFLOW_VALUE.
AC_DEFUN([gl_REPLACE_ERRNO_VALUE],
[
if test -n "$ERRNO_H"; then
AC_CACHE_CHECK([for ]$1[ value], [gl_cv_header_errno_h_]$1, [
AC_EGREP_CPP(yes,[
#include <errno.h>
#ifdef ]$1[
yes
#endif
],
[gl_cv_header_errno_h_]$1[=yes],
[gl_cv_header_errno_h_]$1[=no])
if test $gl_cv_header_errno_h_]$1[ = no; then
AC_EGREP_CPP(yes,[
#define _XOPEN_SOURCE_EXTENDED 1
#include <errno.h>
#ifdef ]$1[
yes
#endif
], [gl_cv_header_errno_h_]$1[=hidden])
if test $gl_cv_header_errno_h_]$1[ = hidden; then
dnl The macro exists but is hidden.
dnl Define it to the same value.
AC_COMPUTE_INT([gl_cv_header_errno_h_]$1, $1, [
#define _XOPEN_SOURCE_EXTENDED 1
#include <errno.h>
/* The following two lines are a workaround against an autoconf-2.52 bug. */
#include <stdio.h>
#include <stdlib.h>
])
fi
fi
])
case $gl_cv_header_errno_h_]$1[ in
yes | no)
]$1[_HIDDEN=0; ]$1[_VALUE=
;;
*)
]$1[_HIDDEN=1; ]$1[_VALUE="$gl_cv_header_errno_h_]$1["
;;
esac
AC_SUBST($1[_HIDDEN])
AC_SUBST($1[_VALUE])
fi
])
============================= modules/errno =================================
Description:
A POSIX-like <errno.h>.
Files:
lib/errno.in.h
m4/errno_h.m4
Depends-on:
include_next
configure.ac:
gl_HEADER_ERRNO_H
Makefile.am:
BUILT_SOURCES += $(ERRNO_H)
# We need the following in order to create <errno.h> when the system
# doesn't have one that is POSIX compliant.
errno.h: errno.in.h
rm -f address@hidden $@
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''NEXT_ERRNO_H''@|$(NEXT_ERRNO_H)|g' \
-e 's|@''EMULTIHOP_HIDDEN''@|$(EMULTIHOP_HIDDEN)|g' \
-e 's|@''EMULTIHOP_VALUE''@|$(EMULTIHOP_VALUE)|g' \
-e 's|@''ENOLINK_HIDDEN''@|$(ENOLINK_HIDDEN)|g' \
-e 's|@''ENOLINK_VALUE''@|$(ENOLINK_VALUE)|g' \
-e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \
-e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \
< $(srcdir)/errno.in.h; \
} > address@hidden
mv address@hidden $@
MOSTLYCLEANFILES += errno.h errno.h-t
Include:
<errno.h>
License:
LGPLv2+
Maintainer:
Bruno Haible
=============================================================================
*** MODULES.html.sh.orig 2008-09-14 00:34:24.000000000 +0200
--- MODULES.html.sh 2008-09-14 00:32:50.000000000 +0200
***************
*** 2082,2087 ****
--- 2082,2088 ----
func_module chown
func_module dup2
func_module environ
+ func_module errno
func_module EOVERFLOW
func_module fchdir
func_module fcntl
*** doc/posix-headers/errno.texi.orig 2008-09-14 00:34:24.000000000 +0200
--- doc/posix-headers/errno.texi 2008-09-13 19:45:18.000000000 +0200
***************
*** 3,15 ****
POSIX specification: @url{http://www.opengroup.org/susv3xbd/errno.h.html}
! Gnulib module: EOVERFLOW
Portability problems fixed by Gnulib:
@itemize
@item
! The macro @code{EOVERFLOW} is not defined on some platforms:
! OSF/1 4.0, mingw.
@end itemize
Portability problems not fixed by Gnulib:
--- 3,30 ----
POSIX specification: @url{http://www.opengroup.org/susv3xbd/errno.h.html}
! Gnulib module: errno, EOVERFLOW
Portability problems fixed by Gnulib:
@itemize
@item
! The macros @code{EOVERFLOW}, @code{ENOLINK}, @code{EMULTIHOP} are not defined
! on some platforms:
! OpenBSD 4.0, OSF/1 4.0, mingw.
! @item
! The macros @code{ENOMSG}, @code{EIDRM}, @code{EPROTO}, @code{EBADMSG},
! @code{ENOTSUP}, @code{ECANCELED} are not defined on some platforms:
! OpenBSD 4.0, mingw.
! @item
! The macros @code{EWOULDBLOCK}, @code{ETXTBSY}, @code{ELOOP}, @code{ENOTSOCK},
! @code{EDESTADDRREQ}, @code{EMSGSIZE}, @code{EPROTOTYPE}, @code{ENOPROTOOPT},
! @code{EPROTONOSUPPORT}, @code{EOPNOTSUPP}, @code{EAFNOSUPPORT},
! @code{EADDRINUSE}, @code{EADDRNOTAVAIL}, @code{ENETDOWN}, @code{ENETUNREACH},
! @code{ENETRESET}, @code{ECONNABORTED}, @code{ECONNRESET}, @code{ENOBUFS},
! @code{EISCONN}, @code{ENOTCONN}, @code{ETIMEDOUT}, @code{ECONNREFUSED},
! @code{EHOSTUNREACH}, @code{EALREADY}, @code{EINPROGRESS}, @code{ESTALE},
! @code{EDQUOT} are not defined on some platforms:
! mingw.
@end itemize
Portability problems not fixed by Gnulib:
- new module 'errno',
Bruno Haible <=
- Re: new module 'errno', Bruno Haible, 2008/09/13
- Re: new module 'errno', Bruno Haible, 2008/09/13
- new module 'perror', Bruno Haible, 2008/09/14
- Re: new module 'errno', Paolo Bonzini, 2008/09/14
- Re: new module 'errno', Eric Blake, 2008/09/14
Re: new module 'errno', Eric Blake, 2008/09/15