From: Bruno Haible Date: Sun, 3 Jun 2012 13:47:14 +0000 (+0200) Subject: error, strerror-override: Support new errno values from POSIX:2008. X-Git-Tag: v0.1~635 X-Git-Url: http://erislabs.net/gitweb/?p=gnulib.git;a=commitdiff_plain;h=04a037691da648c27dd81b362e25d9a18c1485f5 error, strerror-override: Support new errno values from POSIX:2008. * m4/errno_h.m4 (gl_HEADER_ERRNO_H): Test also EOWNERDEAD and ENOTRECOVERABLE. * lib/errno.in.h (EOWNERDEAD, ENOTRECOVERABLE): Define on all platforms. * lib/strerror-override.c (strerror_override): Conditionalize the EOWNERDEAD, ENOTRECOVERABLE handling on GNULIB_defined_EOWNERDEAD. * lib/strerror-override.h (strerror_override): Declare also if GNULIB_defined_EOWNERDEAD is defined. * tests/test-errno.c (e130, e131): New variables. * doc/posix-headers/errno.texi: Mention the status for EOWNERDEAD, ENOTRECOVERABLE. Reported by Paolo Bonzini. --- diff --git a/ChangeLog b/ChangeLog index fa5159110..559f45567 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2012-06-03 Bruno Haible + + error, strerror-override: Support new errno values from POSIX:2008. + * m4/errno_h.m4 (gl_HEADER_ERRNO_H): Test also EOWNERDEAD and + ENOTRECOVERABLE. + * lib/errno.in.h (EOWNERDEAD, ENOTRECOVERABLE): Define on all + platforms. + * lib/strerror-override.c (strerror_override): Conditionalize the + EOWNERDEAD, ENOTRECOVERABLE handling on GNULIB_defined_EOWNERDEAD. + * lib/strerror-override.h (strerror_override): Declare also if + GNULIB_defined_EOWNERDEAD is defined. + * tests/test-errno.c (e130, e131): New variables. + * doc/posix-headers/errno.texi: Mention the status for EOWNERDEAD, + ENOTRECOVERABLE. + Reported by Paolo Bonzini. + 2012-05-31 Jim Meyering savewd: add missing dependency on sys_wait module diff --git a/doc/posix-headers/errno.texi b/doc/posix-headers/errno.texi index 799b42ec2..58ee8b348 100644 --- a/doc/posix-headers/errno.texi +++ b/doc/posix-headers/errno.texi @@ -37,6 +37,11 @@ The macros @code{EWOULDBLOCK}, @code{ETXTBSY}, @code{ELOOP}, @code{ENOTSOCK}, @code{ETIMEDOUT}, @code{ECONNREFUSED}, @code{EHOSTUNREACH}, @code{EALREADY}, @code{EINPROGRESS} are not defined on some platforms: mingw, MSVC 9. +@item +The macros @code{EOWNERDEAD}, @code{ENOTRECOVERABLE} are not defined on +some platforms: +glibc/Linux 2.3.6, glibc/Hurd 2.15, glibc/kFreeBSD 2.15, +MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Cygwin, mingw without pthreads-win32, MSVC 9, Interix 3.5, BeOS. @end itemize Portability problems not fixed by Gnulib: diff --git a/lib/errno.in.h b/lib/errno.in.h index 6ccccf3fe..84d79ac31 100644 --- a/lib/errno.in.h +++ b/lib/errno.in.h @@ -84,6 +84,12 @@ # define GNULIB_defined_ECANCELED 1 # endif +# ifndef EOWNERDEAD +# define EOWNERDEAD 133 +# define ENOTRECOVERABLE 127 +# define GNULIB_defined_EOWNERDEAD 1 +# endif + # ifndef EINPROGRESS # define EINPROGRESS 112 # define EALREADY 103 @@ -112,8 +118,6 @@ # define ENODATA 120 /* not required by POSIX */ # define ENOSR 124 /* not required by POSIX */ # define ENOSTR 125 /* not required by POSIX */ -# define ENOTRECOVERABLE 127 /* not required by POSIX */ -# define EOWNERDEAD 133 /* not required by POSIX */ # define ETIME 137 /* not required by POSIX */ # define EOTHER 131 /* not required by POSIX */ # define GNULIB_defined_ESOCK 1 @@ -227,6 +231,35 @@ # define GNULIB_defined_ECANCELED 1 # endif +/* On many platforms, the macros EOWNERDEAD and ENOTRECOVERABLE are not + defined. */ + +# ifndef EOWNERDEAD +# if defined __sun + /* Use the same values as defined for Solaris >= 8, for + interoperability. */ +# define EOWNERDEAD 58 +# define ENOTRECOVERABLE 59 +# elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ + /* We have a conflict here: pthreads-win32 defines these values + differently than MSVC 10. It's hairy to decide which one to use. */ +# if defined __MINGW32__ && !defined USE_WINDOWS_THREADS + /* Use the same values as defined by pthreads-win32, for + interoperability. */ +# define EOWNERDEAD 43 +# define ENOTRECOVERABLE 44 +# else + /* Use the same values as defined by MSVC 10, for + interoperability. */ +# define EOWNERDEAD 133 +# define ENOTRECOVERABLE 127 +# endif +# else +# define EOWNERDEAD 2013 +# define ENOTRECOVERABLE 2014 +# endif +# define GNULIB_defined_EOWNERDEAD 1 +# endif #endif /* _@GUARD_PREFIX@_ERRNO_H */ #endif /* _@GUARD_PREFIX@_ERRNO_H */ diff --git a/lib/strerror-override.c b/lib/strerror-override.c index 9ca652349..b47238cb8 100644 --- a/lib/strerror-override.c +++ b/lib/strerror-override.c @@ -97,10 +97,6 @@ strerror_override (int errnum) return "Out of streams resources"; case ENOSTR: return "Device not a stream"; - case ENOTRECOVERABLE: - return "State not recoverable"; - case EOWNERDEAD: - return "Owner died"; case ETIME: return "Timer expired"; case EOTHER: @@ -283,6 +279,13 @@ strerror_override (int errnum) return "Operation canceled"; #endif +#if GNULIB_defined_EOWNERDEAD + case EOWNERDEAD: + return "Owner died"; + case ENOTRECOVERABLE: + return "State not recoverable"; +#endif + default: return NULL; } diff --git a/lib/strerror-override.h b/lib/strerror-override.h index 09526ea91..a41afa769 100644 --- a/lib/strerror-override.h +++ b/lib/strerror-override.h @@ -43,7 +43,8 @@ || GNULIB_defined_ECONNABORTED \ || GNULIB_defined_ESTALE \ || GNULIB_defined_EDQUOT \ - || GNULIB_defined_ECANCELED + || GNULIB_defined_ECANCELED \ + || GNULIB_defined_EOWNERDEAD extern const char *strerror_override (int errnum); # else # define strerror_override(ignored) NULL diff --git a/m4/errno_h.m4 b/m4/errno_h.m4 index 4f0bb8359..521e76e47 100644 --- a/m4/errno_h.m4 +++ b/m4/errno_h.m4 @@ -1,4 +1,4 @@ -# errno_h.m4 serial 10 +# errno_h.m4 serial 11 dnl Copyright (C) 2004, 2006, 2008-2012 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -49,6 +49,12 @@ booboo #if !defined ECANCELED booboo #endif +#if !defined EOWNERDEAD +booboo +#endif +#if !defined ENOTRECOVERABLE +booboo +#endif ], [gl_cv_header_errno_h_complete=no], [gl_cv_header_errno_h_complete=yes]) diff --git a/tests/test-errno.c b/tests/test-errno.c index d9a030f44..8d0071741 100644 --- a/tests/test-errno.c +++ b/tests/test-errno.c @@ -98,6 +98,8 @@ int e115 = EINPROGRESS; int e116 = ESTALE; int e122 = EDQUOT; int e125 = ECANCELED; +int e130 = EOWNERDEAD; +int e131 = ENOTRECOVERABLE; /* Don't verify that these errno values are all different, except for possibly EWOULDBLOCK == EAGAIN. Even Linux/x86 does not pass this check: it has