strerror_r questions
Eric Blake
eblake@redhat.com
Wed Feb 9 22:11:00 GMT 2011
On 02/06/2011 02:52 AM, Corinna Vinschen wrote:
> First of all, the existing implementation follows glibc's lead, so
> it should stick to the API but the behavior should be fixed.
>
> Other than that, the Linux approach would work best. Provide both
> interfaces and use test macros. Fortunately they are documented in the
> man page:
>
> The XSI-compliant version of strerror_r() is provided if:
> (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
> Otherwise, the GNU-specific version is provided.
>
> Ideally we don't define _GNU_SOURCE by default, so this should result in
> getting the POSIX version by default.
Well, for backwards compatibility (as well as glibc compatibility), I
thought it better we still get the _GNU_SOURCE version by default; but I
can tweak things if you really want me to default to POSIX when no
feature test macros are present. At any rate, here's the newlib side of
the patch (cygwin will need to be patched separately).
2011-02-08 Eric Blake <eblake@redhat.com>
* libc/include/string.h (strerror_r): Update declaration.
* libc/string/strerror_r.c (strerror_r): Always return
NUL-terminated string.
* 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.
---
newlib/ChangeLog | 10 ++++++++++
newlib/libc/include/string.h | 17 ++++++++++++++++-
newlib/libc/string/Makefile.am | 3 ++-
newlib/libc/string/Makefile.in | 14 +++++++++++---
newlib/libc/string/strerror_r.c | 26 +++++++++++++++++++++-----
newlib/libc/string/xpg_strerror_r.c | 19 +++++++++++++++++++
6 files changed, 79 insertions(+), 10 deletions(-)
create mode 100644 newlib/libc/string/xpg_strerror_r.c
--
Eric Blake eblake@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: newlib.patch48
URL: <http://sourceware.org/pipermail/newlib/attachments/20110209/968a5c56/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://sourceware.org/pipermail/newlib/attachments/20110209/968a5c56/attachment.sig>
More information about the Newlib
mailing list