Add GNU-compatible strerror_r.

We already had the POSIX strerror_r, but some third-party code defines
_GNU_SOURCE and expects to get the GNU strerror_r instead.

This exposed a bug in the libc internal logging functions where unlike
their standard brethren they wouldn't return the number of bytes they'd
have liked to have written.

Bug: 16243479
Change-Id: I1745752ccbdc569646d34f5071f6df2be066d5f4
This commit is contained in:
Elliott Hughes
2014-08-18 17:28:32 -07:00
parent f4e721dd51
commit 416d7ddaff
7 changed files with 115 additions and 20 deletions

View File

@@ -67,8 +67,12 @@ extern char* strcasestr(const char *haystack, const char *needle) __purefunc;
extern char* strtok(char* __restrict, const char* __restrict);
extern char* strtok_r(char* __restrict, const char* __restrict, char** __restrict);
extern char* strerror(int);
extern int strerror_r(int errnum, char *buf, size_t n);
extern char* strerror(int);
#if defined(__USE_GNU)
extern char* strerror_r(int, char*, size_t) __RENAME(__gnu_strerror_r);
#else /* POSIX */
extern int strerror_r(int, char*, size_t);
#endif
extern size_t strnlen(const char *, size_t) __purefunc;
extern char* strncat(char* __restrict, const char* __restrict, size_t);