X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fstrerror_r.c;h=1fa52d99da600dbf43e19cd46c23f9230296ef4f;hb=f9e83fd48cb5c5a0b5a65751710138d42c814402;hp=ec89762d72a1fef99fb98e950451db01ad19072c;hpb=1838494765155d7c9ac63832182cd4ef9f368bf5;p=gnulib.git diff --git a/lib/strerror_r.c b/lib/strerror_r.c index ec89762d7..1fa52d99d 100644 --- a/lib/strerror_r.c +++ b/lib/strerror_r.c @@ -1,6 +1,6 @@ /* strerror_r.c --- POSIX compatible system error routine - Copyright (C) 2010 Free Software Foundation, Inc. + Copyright (C) 2010-2011 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 @@ -24,10 +24,10 @@ #include -#if HAVE_DECL_STRERROR_R && !(__GLIBC__ >= 2) && !EXTEND_STRERROR_R +#if HAVE_DECL_STRERROR_R && !(__GLIBC__ >= 2 || defined __UCLIBC__) && !EXTEND_STRERROR_R /* The system's strerror_r function is OK, except that its third argument - is 'int', not 'size_t'. */ + is 'int', not 'size_t', or its return type is wrong. */ # include @@ -61,6 +61,11 @@ strerror_r (int errnum, char *buf, size_t buflen) else ret = strerror_r (errnum, buf, buflen); } +# elif defined __CYGWIN__ + /* Cygwin only provides the glibc interface, is thread-safe, and + always succeeds (although it may truncate). */ + strerror_r (errnum, buf, buflen); + ret = 0; # else ret = strerror_r (errnum, buf, buflen); # endif @@ -90,7 +95,7 @@ strerror_r (int errnum, char *buf, size_t buflen) return (ret < 0 ? errno : ret); } -#elif __GLIBC__ >= 2 && HAVE___XPG_STRERROR_R /* glibc >= 2.3.4 */ && !EXTEND_STRERROR_R +#elif (__GLIBC__ >= 2 || defined __UCLIBC__) && HAVE___XPG_STRERROR_R /* glibc >= 2.3.4 */ && !EXTEND_STRERROR_R int strerror_r (int errnum, char *buf, size_t buflen) @@ -98,10 +103,10 @@ strerror_r (int errnum, char *buf, size_t buflen) extern int __xpg_strerror_r (int errnum, char *buf, size_t buflen); int ret = __xpg_strerror_r (errnum, buf, buflen); - return (ret < 0 ? errno : 0); + return (ret < 0 ? errno : ret); } -#else /* (__GLIBC__ >= 2 ? !HAVE___XPG_STRERROR_R : !HAVE_DECL_STRERROR_R) || EXTEND_STRERROR_R */ +#else /* (__GLIBC__ >= 2 || defined __UCLIBC__ ? !HAVE___XPG_STRERROR_R : !HAVE_DECL_STRERROR_R) || EXTEND_STRERROR_R */ # include "glthread/lock.h"