This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: strerror_r questions
On Feb 9 17:17, Eric Blake wrote:
> On 02/09/2011 03:43 PM, Eric Blake wrote:
> * libc/include/string.h (strerror_r): Update declaration.
> * libc/string/strerror.c (strerror): Update documentation.
> * libc/string/strerror_r.c (strerror_r): Always return
> NUL-terminated string; don't overwrite too-short buf.
> * libc/string/xpg_strerror_r.c (__xpg_strerror_r): Implement
> POSIX variant.
> * libc/string/Makefile.am (GENERAL_SOURCES): Build new file.
> * libc/string/Makefile.in: Regenerate.
Looks good to me with a minor note:
> +/* There are two common strerror_r variants. If you request
> + _GNU_SOURCE, you get the GNU version; otherwise you get the POSIX
> + version. POSIX requires that #undef strerror_r will still let you
> + invoke the underlying function, but that requires gcc support. */
> +#ifdef _GNU_SOURCE
I would still prefer if we could use the same #if expression as
documented in glibc's `man strerror_r':
(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
But we can't do that right now because our features.h defines
_POSIX_C_SOURCE very different from glibc.
In newlib, _POSIX_C_SOURCE is *only* defined automatically, if
_XOPEN_SOURCE is defined.
In glibc, _POSIX_C_SOURCE is always defined automatically, *unless*
_XOPEN_SOURCE has a value >= 500, and the default value is 200809L,
aka POSIX1-2008.
I think we should fix that. However, this doesn't affect this patch
immediately, so, please check it in.
Thanks,
Corinna
--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat