From: Eric Blake Date: Thu, 19 May 2011 18:51:36 +0000 (-0600) Subject: strerror_r: fix on newer cygwin X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b79d34835799d78d05b99916bfc363850905601c;p=pspp 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 --- diff --git a/ChangeLog b/ChangeLog index 4e22ecba26..f5e455b44f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-05-19 Eric Blake + + 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 strerror_r: Avoid clobbering the strerror buffer when possible. diff --git a/lib/strerror_r.c b/lib/strerror_r.c index c4aa5d9d14..fe1185ba4e 100644 --- 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 @@ strerror_r (int errnum, char *buf, size_t buflen) 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;