bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] fix errno for MinGW64


From: Paolo Bonzini
Subject: [PATCH] fix errno for MinGW64
Date: Mon, 21 May 2012 11:23:44 +0200

I noticed that errno doesn't work on Fedora 17's MinGW64 because it
defines some of MSVC10's new error codes, but not all.  This patch
fixes it, while avoiding that glibc gets the replacement only because
it lacks EOTHER (which is not even in POSIX).

Ok?

2012-05-21  Paolo Bonzini  <address@hidden>

        errno: Fixes for MinGW64.
        ETXTBSY, ENODATA, ENOSR, ENOSTR, ENOTRECOVERABLE, ETIME, EOTHER
        are not defined by MinGW64's errno.h.  Add fallbacks to gnulib's
        errno.h, taking into account that ETXTBSY is not missing under
        any known POSIX system, while EOTHER is only provided by MSVC.

        * lib/errno.h: Provide fallback definitions for ENOSR, ENOSTR,
        ENOTRECOVERABLE, ETIME, ENODATA.
        [native Windows]: Do not group ETXTBSY, ENODATA, ENOSR,
        ENOSTR, ENOTRECOVERABLE, ETIME, EOTHER under GNULIB_defined_ESOCK.
        MinGW64 does not define them, though it defines the other errors
        provided by MSVC10.
        * lib/strerror-override.c: Move fallback definitions for ENODATA,
        ENOSR, ENOSTR, ENOTRECOVERABLE, EOTHER, ETIME, ETXTBSY out of
        GNULIB_defined_ESOCK and into their own guard.
        * lib/strerror-override.h: Add guards for ENODATA, ENOSR, ENOSTR,
        ENOTRECOVERABLE, EOTHER, ETIME, ETXTBSY.
        * m4/errno_h.m4: Mark errno.h as incomplete if it lacks any of
        EINPROGRESS, ENOSR, ENOSTR, ENOTRECOVERABLE, ETIME, ETXTBSY.
---
 ChangeLog               |   22 ++++++++++++++++++
 lib/errno.in.h          |   58 +++++++++++++++++++++++++++++++++++++++++++++--
 lib/strerror-override.c |   52 +++++++++++++++++++++++++++++-------------
 lib/strerror-override.h |    9 +++++++-
 m4/errno_h.m4           |   21 +++++++++++++++++
 5 files changed, 143 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a7fcb3f..c01b4b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
 2012-05-21  Paolo Bonzini  <address@hidden>
 
+       errno: Fixes for MinGW64.
+       ETXTBSY, ENODATA, ENOSR, ENOSTR, ENOTRECOVERABLE, ETIME, EOTHER
+       are not defined by MinGW64's errno.h.  Add fallbacks to gnulib's
+       errno.h, taking into account that ETXTBSY is not missing under
+       any known POSIX system, while EOTHER is only provided by MSVC.
+
+       * lib/errno.h: Provide fallback definitions for ENOSR, ENOSTR,
+       ENOTRECOVERABLE, ETIME, ENODATA.
+       [native Windows]: Do not group ETXTBSY, ENODATA, ENOSR,
+       ENOSTR, ENOTRECOVERABLE, ETIME, EOTHER under GNULIB_defined_ESOCK.
+       MinGW64 does not define them, though it defines the other errors
+       provided by MSVC10.
+       * lib/strerror-override.c: Move fallback definitions for ENODATA,
+       ENOSR, ENOSTR, ENOTRECOVERABLE, EOTHER, ETIME, ETXTBSY out of
+       GNULIB_defined_ESOCK and into their own guard.
+       * lib/strerror-override.h: Add guards for ENODATA, ENOSR, ENOSTR,
+       ENOTRECOVERABLE, EOTHER, ETIME, ETXTBSY.
+       * m4/errno_h.m4: Mark errno.h as incomplete if it lacks any of
+       EINPROGRESS, ENOSR, ENOSTR, ENOTRECOVERABLE, ETIME, ETXTBSY.
+
+2012-05-21  Paolo Bonzini  <address@hidden>
+
        poll/select: prevent busy-waiting.  SwitchToThread() only gives away
        the rest of the current time slice to another thread in the current
        process. So if the thread that feeds the file decscriptor we're
diff --git a/lib/errno.in.h b/lib/errno.in.h
index 6ccccf3..d5b3cf4 100644
--- a/lib/errno.in.h
+++ b/lib/errno.in.h
@@ -108,15 +108,43 @@
 #   define ELOOP           114
 #   define EHOSTUNREACH    110
 #   define EWOULDBLOCK     140
+#   define EOWNERDEAD      133  /* not required by POSIX */
+#   define GNULIB_defined_ESOCK 1
+#  endif
+
+#  ifndef ETXTBSY
 #   define ETXTBSY         139
+#   define GNULIB_defined_ETXTBSY 1
+#  endif
+
+#  ifndef ENODATA
 #   define ENODATA         120  /* not required by POSIX */
+#   define GNULIB_defined_ENODATA 1
+#  endif
+
+#  ifndef ENOSR
 #   define ENOSR           124  /* not required by POSIX */
+#   define GNULIB_defined_ENOSR 1
+#  endif
+
+#  ifndef ENOSTR
 #   define ENOSTR          125  /* not required by POSIX */
+#   define GNULIB_defined_ENOSTR 1
+#  endif
+
+#  ifndef ENOTRECOVERABLE
 #   define ENOTRECOVERABLE 127  /* not required by POSIX */
-#   define EOWNERDEAD      133  /* not required by POSIX */
+#   define GNULIB_defined_ENOTRECOVERABLE 1
+#  endif
+
+#  ifndef ETIME
 #   define ETIME           137  /* not required by POSIX */
+#   define GNULIB_defined_ETIME 1
+#  endif
+
+#  ifndef EOTHER
 #   define EOTHER          131  /* not required by POSIX */
-#   define GNULIB_defined_ESOCK 1
+#   define GNULIB_defined_EOTHER 1
 #  endif
 
 /* These are intentionally the same values as the WSA* error numbers, defined
@@ -227,6 +255,32 @@
 #  define GNULIB_defined_ECANCELED 1
 # endif
 
+/* The following values are not required by POSIX.  */
+
+#  ifndef ENODATA
+#   define ENODATA 2013
+#   define GNULIB_defined_ENODATA 1
+#  endif
+
+#  ifndef ENOSR
+#   define ENOSR 2013
+#   define GNULIB_defined_ENOSR 1
+#  endif
+
+#  ifndef ENOSTR
+#   define ENOSTR 2014
+#   define GNULIB_defined_ENOSTR 1
+#  endif
+
+#  ifndef ENOTRECOVERABLE
+#   define ENOTRECOVERABLE 2015
+#   define GNULIB_defined_ENOTRECOVERABLE 1
+#  endif
+
+#  ifndef ETIME
+#   define ETIME 2016
+#   define GNULIB_defined_ETIME 1
+#  endif
 
 #endif /* address@hidden@_ERRNO_H */
 #endif /* address@hidden@_ERRNO_H */
diff --git a/lib/strerror-override.c b/lib/strerror-override.c
index 9ca6523..117486b 100644
--- a/lib/strerror-override.c
+++ b/lib/strerror-override.c
@@ -89,22 +89,6 @@ strerror_override (int errnum)
       return "No route to host";
     case EWOULDBLOCK:
       return "Operation would block";
-    case ETXTBSY:
-      return "Text file busy";
-    case ENODATA:
-      return "No data available";
-    case ENOSR:
-      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:
-      return "Other error";
 #endif
 #if GNULIB_defined_EWINSOCK /* native Windows platforms */
     case ESOCKTNOSUPPORT:
@@ -283,6 +267,42 @@ strerror_override (int errnum)
       return "Operation canceled";
 #endif
 
+#if GNULIB_defined_ENODATA
+    case ENODATA:
+      return "No data available";
+#endif
+
+#if GNULIB_defined_ENOSR
+    case ENOSR:
+      return "Out of streams resources";
+#endif
+
+#if GNULIB_defined_ENOSTR
+    case ENOSTR:
+      return "Device not a stream";
+#endif
+
+#if GNULIB_defined_ENOTRECOVERABLE
+    case ENOTRECOVERABLE:
+      return "State not recoverable";
+#endif
+
+#if GNULIB_defined_EOTHER
+    case EOTHER:
+      /* Only defined by MSVC.  */
+      return "Other error";
+#endif
+
+#if GNULIB_defined_ETIME
+    case ETIME:
+      return "Timer expired";
+#endif
+
+#if GNULIB_defined_ETXTBSY
+    case ETXTBSY:
+      return "Text file busy";
+#endif
+
     default:
       return NULL;
     }
diff --git a/lib/strerror-override.h b/lib/strerror-override.h
index 09526ea..f312f62 100644
--- a/lib/strerror-override.h
+++ b/lib/strerror-override.h
@@ -43,7 +43,14 @@
      || GNULIB_defined_ECONNABORTED \
      || GNULIB_defined_ESTALE \
      || GNULIB_defined_EDQUOT \
-     || GNULIB_defined_ECANCELED
+     || GNULIB_defined_ECANCELED \
+     || GNULIB_defined_ENODATA \
+     || GNULIB_defined_ENOSR \
+     || GNULIB_defined_ENOSTR \
+     || GNULIB_defined_ENOTRECOVERABLE \
+     || GNULIB_defined_EOTHER \
+     || GNULIB_defined_ETIME \
+     || GNULIB_defined_ETXTBSY
 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 4f0bb83..989a7df 100644
--- a/m4/errno_h.m4
+++ b/m4/errno_h.m4
@@ -49,6 +49,27 @@ booboo
 #if !defined ECANCELED
 booboo
 #endif
+#if !defined EINPROGRESS
+booboo
+#endif
+#if !defined ENODATA
+booboo
+#endif
+#if !defined ENOSR
+booboo
+#endif
+#if !defined ENOSTR
+booboo
+#endif
+#if !defined ENOTRECOVERABLE
+booboo
+#endif
+#if !defined ETIME
+booboo
+#endif
+#if !defined ETXTBSY
+booboo
+#endif
       ],
       [gl_cv_header_errno_h_complete=no],
       [gl_cv_header_errno_h_complete=yes])
-- 
1.7.10.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]