diff options
Diffstat (limited to 'gl/error.in.h')
| -rw-r--r-- | gl/error.in.h | 71 |
1 files changed, 58 insertions, 13 deletions
diff --git a/gl/error.in.h b/gl/error.in.h index 51f8cafd..6c512ec8 100644 --- a/gl/error.in.h +++ b/gl/error.in.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Declarations for error-reporting functions. | 1 | /* Declarations for error-reporting functions. |
| 2 | Copyright (C) 1995-1997, 2003, 2006, 2008-2024 Free Software Foundation, | 2 | Copyright (C) 1995-1997, 2003, 2006, 2008-2025 Free Software Foundation, |
| 3 | Inc. | 3 | Inc. |
| 4 | This file is part of the GNU C Library. | 4 | This file is part of the GNU C Library. |
| 5 | 5 | ||
| @@ -23,20 +23,23 @@ | |||
| 23 | or error_at_line(...) invocations. */ | 23 | or error_at_line(...) invocations. */ |
| 24 | 24 | ||
| 25 | /* The include_next requires a split double-inclusion guard. */ | 25 | /* The include_next requires a split double-inclusion guard. */ |
| 26 | #if @HAVE_ERROR_H@ | 26 | #if @HAVE_ERROR_H@ && !defined __MINGW32__ |
| 27 | # @INCLUDE_NEXT@ @NEXT_ERROR_H@ | 27 | # @INCLUDE_NEXT@ @NEXT_ERROR_H@ |
| 28 | #endif | 28 | #endif |
| 29 | 29 | ||
| 30 | #ifndef _@GUARD_PREFIX@_ERROR_H | 30 | #ifndef _@GUARD_PREFIX@_ERROR_H |
| 31 | #define _@GUARD_PREFIX@_ERROR_H | 31 | #define _@GUARD_PREFIX@_ERROR_H |
| 32 | 32 | ||
| 33 | /* This file uses _GL_ATTRIBUTE_ALWAYS_INLINE, _GL_ATTRIBUTE_FORMAT, | 33 | /* This file uses _GL_ATTRIBUTE_ALWAYS_INLINE, _GL_ATTRIBUTE_COLD, |
| 34 | _GL_ATTRIBUTE_MAYBE_UNUSED. */ | 34 | _GL_ATTRIBUTE_FORMAT, _GL_ATTRIBUTE_MAYBE_UNUSED. */ |
| 35 | #if !_GL_CONFIG_H_INCLUDED | 35 | #if !_GL_CONFIG_H_INCLUDED |
| 36 | #error "Please include config.h first." | 36 | #error "Please include config.h first." |
| 37 | #endif | 37 | #endif |
| 38 | 38 | ||
| 39 | /* Get 'unreachable'. */ | 39 | /* Get va_list. */ |
| 40 | #include <stdarg.h> | ||
| 41 | |||
| 42 | /* Get 'gl_unreachable'. */ | ||
| 40 | #include <stddef.h> | 43 | #include <stddef.h> |
| 41 | 44 | ||
| 42 | /* Get _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM. */ | 45 | /* Get _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM. */ |
| @@ -54,11 +57,11 @@ | |||
| 54 | It evaluates its arguments only once. | 57 | It evaluates its arguments only once. |
| 55 | Test case: Compile copy-file.c with "gcc -Wimplicit-fallthrough". */ | 58 | Test case: Compile copy-file.c with "gcc -Wimplicit-fallthrough". */ |
| 56 | #if defined __GNUC__ || defined __clang__ | 59 | #if defined __GNUC__ || defined __clang__ |
| 57 | /* Use 'unreachable' to tell the compiler when the function call does not | 60 | /* Use 'gl_unreachable' to tell the compiler when the function call does not |
| 58 | return. */ | 61 | return. */ |
| 59 | # define __gl_error_call1(function, status, ...) \ | 62 | # define __gl_error_call1(function, status, ...) \ |
| 60 | ((function) (status, __VA_ARGS__), \ | 63 | ((function) (status, __VA_ARGS__), \ |
| 61 | (status) != 0 ? unreachable () : (void) 0) | 64 | (status) != 0 ? gl_unreachable () : (void) 0) |
| 62 | /* If STATUS is a not a constant, the function call may or may not return; | 65 | /* If STATUS is a not a constant, the function call may or may not return; |
| 63 | therefore -Wimplicit-fallthrough will produce a warning. Use a compound | 66 | therefore -Wimplicit-fallthrough will produce a warning. Use a compound |
| 64 | statement in order to evaluate STATUS only once. | 67 | statement in order to evaluate STATUS only once. |
| @@ -92,7 +95,8 @@ extern "C" { | |||
| 92 | # define error rpl_error | 95 | # define error rpl_error |
| 93 | # endif | 96 | # endif |
| 94 | _GL_FUNCDECL_RPL (error, void, | 97 | _GL_FUNCDECL_RPL (error, void, |
| 95 | (int __status, int __errnum, const char *__format, ...) | 98 | (int __status, int __errnum, const char *__format, ...), |
| 99 | _GL_ATTRIBUTE_COLD | ||
| 96 | _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4))); | 100 | _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4))); |
| 97 | _GL_CXXALIAS_RPL (error, void, | 101 | _GL_CXXALIAS_RPL (error, void, |
| 98 | (int __status, int __errnum, const char *__format, ...)); | 102 | (int __status, int __errnum, const char *__format, ...)); |
| @@ -104,7 +108,8 @@ _GL_CXXALIAS_RPL (error, void, | |||
| 104 | #else | 108 | #else |
| 105 | # if ! @HAVE_ERROR@ | 109 | # if ! @HAVE_ERROR@ |
| 106 | _GL_FUNCDECL_SYS (error, void, | 110 | _GL_FUNCDECL_SYS (error, void, |
| 107 | (int __status, int __errnum, const char *__format, ...) | 111 | (int __status, int __errnum, const char *__format, ...), |
| 112 | _GL_ATTRIBUTE_COLD | ||
| 108 | _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4))); | 113 | _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4))); |
| 109 | # endif | 114 | # endif |
| 110 | _GL_CXXALIAS_SYS (error, void, | 115 | _GL_CXXALIAS_SYS (error, void, |
| @@ -117,7 +122,7 @@ _GL_CXXALIAS_SYS (error, void, | |||
| 117 | # pragma GCC diagnostic ignored "-Wattributes" | 122 | # pragma GCC diagnostic ignored "-Wattributes" |
| 118 | _GL_ATTRIBUTE_MAYBE_UNUSED | 123 | _GL_ATTRIBUTE_MAYBE_UNUSED |
| 119 | static void | 124 | static void |
| 120 | _GL_ATTRIBUTE_ALWAYS_INLINE | 125 | _GL_ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_COLD |
| 121 | _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4)) | 126 | _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4)) |
| 122 | _gl_inline_error (int __status, int __errnum, const char *__format, ...) | 127 | _gl_inline_error (int __status, int __errnum, const char *__format, ...) |
| 123 | { | 128 | { |
| @@ -147,7 +152,8 @@ _GL_CXXALIASWARN (error); | |||
| 147 | # endif | 152 | # endif |
| 148 | _GL_FUNCDECL_RPL (error_at_line, void, | 153 | _GL_FUNCDECL_RPL (error_at_line, void, |
| 149 | (int __status, int __errnum, const char *__filename, | 154 | (int __status, int __errnum, const char *__filename, |
| 150 | unsigned int __lineno, const char *__format, ...) | 155 | unsigned int __lineno, const char *__format, ...), |
| 156 | _GL_ATTRIBUTE_COLD | ||
| 151 | _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6))); | 157 | _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6))); |
| 152 | _GL_CXXALIAS_RPL (error_at_line, void, | 158 | _GL_CXXALIAS_RPL (error_at_line, void, |
| 153 | (int __status, int __errnum, const char *__filename, | 159 | (int __status, int __errnum, const char *__filename, |
| @@ -161,7 +167,8 @@ _GL_CXXALIAS_RPL (error_at_line, void, | |||
| 161 | # if ! @HAVE_ERROR_AT_LINE@ | 167 | # if ! @HAVE_ERROR_AT_LINE@ |
| 162 | _GL_FUNCDECL_SYS (error_at_line, void, | 168 | _GL_FUNCDECL_SYS (error_at_line, void, |
| 163 | (int __status, int __errnum, const char *__filename, | 169 | (int __status, int __errnum, const char *__filename, |
| 164 | unsigned int __lineno, const char *__format, ...) | 170 | unsigned int __lineno, const char *__format, ...), |
| 171 | _GL_ATTRIBUTE_COLD | ||
| 165 | _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6))); | 172 | _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6))); |
| 166 | # endif | 173 | # endif |
| 167 | _GL_CXXALIAS_SYS (error_at_line, void, | 174 | _GL_CXXALIAS_SYS (error_at_line, void, |
| @@ -175,7 +182,7 @@ _GL_CXXALIAS_SYS (error_at_line, void, | |||
| 175 | # pragma GCC diagnostic ignored "-Wattributes" | 182 | # pragma GCC diagnostic ignored "-Wattributes" |
| 176 | _GL_ATTRIBUTE_MAYBE_UNUSED | 183 | _GL_ATTRIBUTE_MAYBE_UNUSED |
| 177 | static void | 184 | static void |
| 178 | _GL_ATTRIBUTE_ALWAYS_INLINE | 185 | _GL_ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_COLD |
| 179 | _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6)) | 186 | _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6)) |
| 180 | _gl_inline_error_at_line (int __status, int __errnum, const char *__filename, | 187 | _gl_inline_error_at_line (int __status, int __errnum, const char *__filename, |
| 181 | unsigned int __lineno, const char *__format, ...) | 188 | unsigned int __lineno, const char *__format, ...) |
| @@ -196,6 +203,44 @@ _gl_inline_error_at_line (int __status, int __errnum, const char *__filename, | |||
| 196 | #endif | 203 | #endif |
| 197 | _GL_CXXALIASWARN (error_at_line); | 204 | _GL_CXXALIASWARN (error_at_line); |
| 198 | 205 | ||
| 206 | /* Print a message with 'vfprintf (stderr, FORMAT, ARGS)'; | ||
| 207 | if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). | ||
| 208 | If STATUS is nonzero, terminate the program with 'exit (STATUS)'. | ||
| 209 | Use the globals error_print_progname and error_message_count similarly | ||
| 210 | to error(). */ | ||
| 211 | |||
| 212 | extern void verror (int __status, int __errnum, const char *__format, | ||
| 213 | va_list __args) | ||
| 214 | _GL_ATTRIBUTE_COLD | ||
| 215 | _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 3, 0)); | ||
| 216 | #ifndef _GL_NO_INLINE_ERROR | ||
| 217 | # ifndef verror | ||
| 218 | # define verror(status, ...) \ | ||
| 219 | __gl_error_call (verror, status, __VA_ARGS__) | ||
| 220 | # define GNULIB_defined_verror 1 | ||
| 221 | # endif | ||
| 222 | #endif | ||
| 223 | |||
| 224 | /* Print a message with 'vfprintf (stderr, FORMAT, ARGS)'; | ||
| 225 | if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). | ||
| 226 | If STATUS is nonzero, terminate the program with 'exit (STATUS)'. | ||
| 227 | If FNAME is not NULL, prepend the message with "FNAME:LINENO:". | ||
| 228 | Use the globals error_print_progname, error_message_count, and | ||
| 229 | error_one_per_line similarly to error_at_line(). */ | ||
| 230 | |||
| 231 | extern void verror_at_line (int __status, int __errnum, const char *__fname, | ||
| 232 | unsigned int __lineno, const char *__format, | ||
| 233 | va_list __args) | ||
| 234 | _GL_ATTRIBUTE_COLD | ||
| 235 | _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 5, 0)); | ||
| 236 | #ifdef _GL_NO_INLINE_ERROR | ||
| 237 | # ifndef verror_at_line | ||
| 238 | # define verror_at_line(status, ...) \ | ||
| 239 | __gl_error_call (verror_at_line, status, __VA_ARGS__) | ||
| 240 | # define GNULIB_defined_verror_at_line 1 | ||
| 241 | # endif | ||
| 242 | #endif | ||
| 243 | |||
| 199 | /* If NULL, error will flush stdout, then print on stderr the program | 244 | /* If NULL, error will flush stdout, then print on stderr the program |
| 200 | name, a colon and a space. Otherwise, error will call this | 245 | name, a colon and a space. Otherwise, error will call this |
| 201 | function without parameters instead. */ | 246 | function without parameters instead. */ |
