From 325081b9eb2035f8f025255206889208f330b590 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Mon, 18 May 2020 17:41:25 -0300 Subject: 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 Reviewed-by: Carlos O'Donell --- manual/errno.texi | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'manual/errno.texi') diff --git a/manual/errno.texi b/manual/errno.texi index 8cb4ce8b48..1834339220 100644 --- a/manual/errno.texi +++ b/manual/errno.texi @@ -1207,6 +1207,29 @@ to @code{errno}. The function @code{perror} is declared in @file{stdio.h}. @end deftypefun +@deftypefun void strerrorname_np (int @var{errnum}) +@standards{GNU, string.h} +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +This function returns the name describing the error @var{errnum} or +@code{NULL} if there is no known constant with this value (e.g "EINVAL" +for @code{EINVAL}). + +@pindex string.h +This function is a GNU extension, declared in the header file @file{string.h}. +@end deftypefun + +@deftypefun void strerrordesc_np (int @var{errnum}) +@standards{GNU, string.h} +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +This function returns the message describing the error @var{errnum} or +@code{NULL} if there is no known constant with this value (e.g "Invalid +argument" for @code{EINVAL}). Different than @code{strerror} the returned +description is not translated. + +@pindex string.h +This function is a GNU extension, declared in the header file @file{string.h}. +@end deftypefun + @code{strerror} and @code{perror} produce the exact same message for any given error code; the precise text varies from system to system. With @theglibc{}, the messages are fairly short; there are no multi-line -- cgit v1.2.3-70-g09d2