summaryrefslogtreecommitdiffstats
path: root/newlib/libc/string/strerror.c
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2011-02-10 16:48:18 +0000
committerEric Blake <eblake@redhat.com>2011-02-10 16:48:18 +0000
commit7c10a76dec8afaf548bf14453ebd689e3457518e (patch)
treec3e235b29e3a74fa8451f5d3f4c79977d0755296 /newlib/libc/string/strerror.c
parent27aaf2a9d19de72291d77c45649951738b697f57 (diff)
downloadcygnal-7c10a76dec8afaf548bf14453ebd689e3457518e.tar.gz
cygnal-7c10a76dec8afaf548bf14453ebd689e3457518e.tar.bz2
cygnal-7c10a76dec8afaf548bf14453ebd689e3457518e.zip
strerror_r: provide POSIX implementation
* 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.
Diffstat (limited to 'newlib/libc/string/strerror.c')
-rw-r--r--newlib/libc/string/strerror.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/newlib/libc/string/strerror.c b/newlib/libc/string/strerror.c
index 043763141..61e40ab7a 100644
--- a/newlib/libc/string/strerror.c
+++ b/newlib/libc/string/strerror.c
@@ -301,6 +301,17 @@ declares that subsequent calls to <<strerror>> may overwrite the
result string; therefore portable code cannot depend on the reentrancy
of this subroutine.
+Although this implementation of <<strerror>> guarantees a non-null
+result with a NUL-terminator, some implementations return <<NULL>>
+on failure. Although POSIX allows <<strerror>> to set <<errno>>
+to EINVAL on failure, this implementation does not do so (unless
+you provide <<_user_strerror>>).
+
+POSIX recommends that unknown <[errnum]> result in a message
+including that value, however it is not a requirement and this
+implementation does not provide that information (unless you
+provide <<_user_strerror>>).
+
This implementation of <<strerror>> provides for user-defined
extensibility. <<errno.h>> defines <[__ELASTERROR]>, which can be
used as a base for user-defined error values. If the user supplies a
@@ -313,6 +324,9 @@ character pointer. If <[errnum]> is unknown to <<_user_strerror>>,
<<_user_strerror>> returns <[NULL]>. The default <<_user_strerror>>
returns <[NULL]> for all input values.
+Note that <<_user_sterror>> must be thread-safe and not alter <<errno>>
+if <<strerror_r>> is to comply with POSIX.
+
<<strerror>> requires no supporting OS subroutines.
QUICKREF