1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

string: Add strerrorname_np and strerrordesc_np

The strerrorname_np returns error number name (e.g. "EINVAL" for EINVAL)
while strerrordesc_np returns string describing error number (e.g
"Invalid argument" for EINVAL).  Different than strerror,
strerrordesc_np does not attempt to translate the return description,
both functions return NULL for an invalid error number.

They should be used instead of sys_errlist and sys_nerr, both are
thread and async-signal safe.  These functions are GNU extensions.

Checked on x86-64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
and s390x-linux-gnu.

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
This commit is contained in:
Adhemerval Zanella
2020-05-18 17:41:25 -03:00
parent bfe05aa289
commit 325081b9eb
42 changed files with 259 additions and 1 deletions

View File

@ -428,6 +428,13 @@ extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen)
extern char *strerror_r (int __errnum, char *__buf, size_t __buflen)
__THROW __nonnull ((2)) __wur __attr_access ((__write_only__, 2, 3));
# endif
# ifdef __USE_GNU
/* Return a string describing the meaning of tthe error in ERR. */
extern const char *strerrordesc_np (int __err) __THROW;
/* Return a string with the error name in ERR. */
extern const char *strerrorname_np (int __err) __THROW;
# endif
#endif
#ifdef __USE_XOPEN2K8