libc: make strerror_rl() usable for libc

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44916
This commit is contained in:
Konstantin Belousov
2024-04-23 20:04:29 +03:00
parent cbbc5770a3
commit 92771bc00a
2 changed files with 7 additions and 5 deletions
+2
View File
@@ -374,5 +374,7 @@ struct __nl_cat_d;
struct _xlocale;
struct __nl_cat_d *__catopen_l(const char *name, int type,
struct _xlocale *locale);
int __strerror_rl(int errnum, char *strerrbuf, size_t buflen,
struct _xlocale *locale);
#endif /* _LIBC_PRIVATE_H_ */
+5 -5
View File
@@ -74,8 +74,8 @@ errstr(int num, const char *uprefix, char *buf, size_t len)
strlcat(buf, t, len);
}
static int
strerror_rl(int errnum, char *strerrbuf, size_t buflen, locale_t locale)
int
__strerror_rl(int errnum, char *strerrbuf, size_t buflen, locale_t locale)
{
int retval = 0;
#if defined(NLS)
@@ -116,7 +116,7 @@ strerror_rl(int errnum, char *strerrbuf, size_t buflen, locale_t locale)
int
strerror_r(int errnum, char *strerrbuf, size_t buflen)
{
return (strerror_rl(errnum, strerrbuf, buflen, __get_locale()));
return (__strerror_rl(errnum, strerrbuf, buflen, __get_locale()));
}
char *
@@ -124,7 +124,7 @@ strerror_l(int num, locale_t locale)
{
static _Thread_local char ebuf[NL_TEXTMAX];
if (strerror_rl(num, ebuf, sizeof(ebuf), locale) != 0)
if (__strerror_rl(num, ebuf, sizeof(ebuf), locale) != 0)
errno = EINVAL;
return (ebuf);
}
@@ -134,7 +134,7 @@ strerror(int num)
{
static char ebuf[NL_TEXTMAX];
if (strerror_rl(num, ebuf, sizeof(ebuf), __get_locale()) != 0)
if (__strerror_rl(num, ebuf, sizeof(ebuf), __get_locale()) != 0)
errno = EINVAL;
return (ebuf);
}