changeset 14766:3618a75b519d

strerror_r: fix on newer cygwin * lib/strerror_r.c (rpl_strerror_r): Cygwin now has __xpg_strerror_r, use it. Signed-off-by: Eric Blake <eblake@redhat.com>
author Eric Blake <eblake@redhat.com>
date Thu, 19 May 2011 12:51:36 -0600
parents 8e23facf1d9e
children ff7953936223
files ChangeLog lib/strerror_r.c
diffstat 2 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-05-19  Eric Blake  <eblake@redhat.com>
+
+	strerror_r: fix on newer cygwin
+	* lib/strerror_r.c (rpl_strerror_r): Cygwin now has
+	__xpg_strerror_r, use it.
+
 2011-05-19  Bruno Haible  <bruno@clisp.org>
 
 	strerror_r: Avoid clobbering the strerror buffer when possible.
--- a/lib/strerror_r.c
+++ b/lib/strerror_r.c
@@ -34,7 +34,11 @@
 # endif
 
 
-#if HAVE_DECL_STRERROR_R && !(__GLIBC__ >= 2 || defined __UCLIBC__)
+#if (__GLIBC__ >= 2 || defined __UCLIBC__ || defined __CYGWIN__) && HAVE___XPG_STRERROR_R /* glibc >= 2.3.4, cygwin >= 1.7.9 */
+
+# define USE_XPG_STRERROR_R 1
+
+#elif HAVE_DECL_STRERROR_R && !(__GLIBC__ >= 2 || defined __UCLIBC__)
 
 /* The system's strerror_r function is OK, except that its third argument
    is 'int', not 'size_t', or its return type is wrong.  */
@@ -43,10 +47,6 @@
 
 # define USE_SYSTEM_STRERROR_R 1
 
-#elif (__GLIBC__ >= 2 || defined __UCLIBC__) && HAVE___XPG_STRERROR_R /* glibc >= 2.3.4 */
-
-# define USE_XPG_STRERROR_R 1
-
 #else /* (__GLIBC__ >= 2 || defined __UCLIBC__ ? !HAVE___XPG_STRERROR_R : !HAVE_DECL_STRERROR_R) */
 
 /* Use the system's strerror().  */
@@ -446,7 +446,7 @@
         ret = strerror_r (errnum, buf, buflen);
     }
 # elif defined __CYGWIN__
-    /* Cygwin only provides the glibc interface, is thread-safe, and
+    /* Cygwin 1.7.8 only provides the glibc interface, is thread-safe, and
        always succeeds (although it may truncate). */
     strerror_r (errnum, buf, buflen);
     ret = 0;