diff options
author | Eric Blake <eblake@redhat.com> | 2011-02-10 16:48:18 +0000 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2011-02-10 16:48:18 +0000 |
commit | 7c10a76dec8afaf548bf14453ebd689e3457518e (patch) | |
tree | c3e235b29e3a74fa8451f5d3f4c79977d0755296 /newlib/libc/include/string.h | |
parent | 27aaf2a9d19de72291d77c45649951738b697f57 (diff) | |
download | cygnal-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/include/string.h')
-rw-r--r-- | newlib/libc/include/string.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/newlib/libc/include/string.h b/newlib/libc/include/string.h index 547cddd84..7202b06ab 100644 --- a/newlib/libc/include/string.h +++ b/newlib/libc/include/string.h @@ -66,7 +66,20 @@ char *_EXFUN(strdup,(const char *)); char *_EXFUN(_strdup_r,(struct _reent *, const char *)); char *_EXFUN(strndup,(const char *, size_t)); char *_EXFUN(_strndup_r,(struct _reent *, const char *, size_t)); -char *_EXFUN(strerror_r,(int, char *, size_t)); +/* 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 +char *_EXFUN(strerror_r,(int, char *, size_t)); +#else +# ifdef __GNUC__ +int _EXFUN(strerror_r,(int, char *, size_t)) __asm__ ("__xpg_strerror_r"); +# else +int _EXFUN(__xpg_strerror_r,(int, char *, size_t)); +# define strerror_r __xpg_strerror_r +# endif +#endif size_t _EXFUN(strlcat,(char *, const char *, size_t)); size_t _EXFUN(strlcpy,(char *, const char *, size_t)); int _EXFUN(strncasecmp,(const char *, const char *, size_t)); |