| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#ifndef _@GUARD_PREFIX@_ERROR_H |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
#if @HAVE_ERROR_H@ && !defined __MINGW32__ |
| 27 |
# @INCLUDE_NEXT@ @NEXT_ERROR_H@ |
| 28 |
#endif |
| 29 |
|
| 30 |
#ifndef _@GUARD_PREFIX@_ERROR_H |
| 31 |
#define _@GUARD_PREFIX@_ERROR_H |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
#if !_GL_CONFIG_H_INCLUDED |
| 36 |
#error "Please include config.h first." |
| 37 |
#endif |
| 38 |
|
| 39 |
|
| 40 |
#include <stddef.h> |
| 41 |
|
| 42 |
|
| 43 |
#include <stdio.h> |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
#if GNULIB_VFPRINTF_POSIX |
| 48 |
# define _GL_ATTRIBUTE_SPEC_PRINTF_ERROR _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD |
| 49 |
#else |
| 50 |
# define _GL_ATTRIBUTE_SPEC_PRINTF_ERROR _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM |
| 51 |
#endif |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
#if defined __GNUC__ || defined __clang__ |
| 57 |
|
| 58 |
|
| 59 |
# define __gl_error_call1(function, status, ...) \ |
| 60 |
((function) (status, __VA_ARGS__), \ |
| 61 |
(status) != 0 ? unreachable () : (void) 0) |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
# define __gl_error_call(function, status, ...) \ |
| 70 |
(__builtin_constant_p (status) \ |
| 71 |
? __gl_error_call1 (function, status, __VA_ARGS__) \ |
| 72 |
: __extension__ \ |
| 73 |
({ \ |
| 74 |
int const __errstatus = status; \ |
| 75 |
__gl_error_call1 (function, __errstatus, __VA_ARGS__); \ |
| 76 |
})) |
| 77 |
#else |
| 78 |
# define __gl_error_call(function, status, ...) \ |
| 79 |
(function) (status, __VA_ARGS__) |
| 80 |
#endif |
| 81 |
|
| 82 |
#ifdef __cplusplus |
| 83 |
extern "C" { |
| 84 |
#endif |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
#if @REPLACE_ERROR@ |
| 90 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 91 |
# undef error |
| 92 |
# define error rpl_error |
| 93 |
# endif |
| 94 |
_GL_FUNCDECL_RPL (error, void, |
| 95 |
(int __status, int __errnum, const char *__format, ...) |
| 96 |
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4))); |
| 97 |
_GL_CXXALIAS_RPL (error, void, |
| 98 |
(int __status, int __errnum, const char *__format, ...)); |
| 99 |
# ifndef _GL_NO_INLINE_ERROR |
| 100 |
# undef error |
| 101 |
# define error(status, ...) \ |
| 102 |
__gl_error_call (rpl_error, status, __VA_ARGS__) |
| 103 |
# endif |
| 104 |
#else |
| 105 |
# if ! @HAVE_ERROR@ |
| 106 |
_GL_FUNCDECL_SYS (error, void, |
| 107 |
(int __status, int __errnum, const char *__format, ...) |
| 108 |
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4))); |
| 109 |
# endif |
| 110 |
_GL_CXXALIAS_SYS (error, void, |
| 111 |
(int __status, int __errnum, const char *__format, ...)); |
| 112 |
# ifndef _GL_NO_INLINE_ERROR |
| 113 |
# ifdef error |
| 114 |
*/ |
| 115 |
# if _GL_GNUC_PREREQ (4, 7) |
| 116 |
# pragma GCC diagnostic push |
| 117 |
# pragma GCC diagnostic ignored "-Wattributes" |
| 118 |
_GL_ATTRIBUTE_MAYBE_UNUSED |
| 119 |
static void |
| 120 |
_GL_ATTRIBUTE_ALWAYS_INLINE |
| 121 |
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4)) |
| 122 |
_gl_inline_error (int __status, int __errnum, const char *__format, ...) |
| 123 |
{ |
| 124 |
return error (__status, __errnum, __format, __builtin_va_arg_pack ()); |
| 125 |
} |
| 126 |
# pragma GCC diagnostic pop |
| 127 |
# undef error |
| 128 |
# define error(status, ...) \ |
| 129 |
__gl_error_call (_gl_inline_error, status, __VA_ARGS__) |
| 130 |
# endif |
| 131 |
# else |
| 132 |
# define error(status, ...) \ |
| 133 |
__gl_error_call (error, status, __VA_ARGS__) |
| 134 |
# endif |
| 135 |
# endif |
| 136 |
#endif |
| 137 |
#if __GLIBC__ >= 2 |
| 138 |
_GL_CXXALIASWARN (error); |
| 139 |
#endif |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
#if @REPLACE_ERROR_AT_LINE@ |
| 144 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 145 |
# undef error_at_line |
| 146 |
# define error_at_line rpl_error_at_line |
| 147 |
# endif |
| 148 |
_GL_FUNCDECL_RPL (error_at_line, void, |
| 149 |
(int __status, int __errnum, const char *__filename, |
| 150 |
unsigned int __lineno, const char *__format, ...) |
| 151 |
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6))); |
| 152 |
_GL_CXXALIAS_RPL (error_at_line, void, |
| 153 |
(int __status, int __errnum, const char *__filename, |
| 154 |
unsigned int __lineno, const char *__format, ...)); |
| 155 |
# ifndef _GL_NO_INLINE_ERROR |
| 156 |
# undef error_at_line |
| 157 |
# define error_at_line(status, ...) \ |
| 158 |
__gl_error_call (rpl_error_at_line, status, __VA_ARGS__) |
| 159 |
# endif |
| 160 |
#else |
| 161 |
# if ! @HAVE_ERROR_AT_LINE@ |
| 162 |
_GL_FUNCDECL_SYS (error_at_line, void, |
| 163 |
(int __status, int __errnum, const char *__filename, |
| 164 |
unsigned int __lineno, const char *__format, ...) |
| 165 |
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6))); |
| 166 |
# endif |
| 167 |
_GL_CXXALIAS_SYS (error_at_line, void, |
| 168 |
(int __status, int __errnum, const char *__filename, |
| 169 |
unsigned int __lineno, const char *__format, ...)); |
| 170 |
# ifndef _GL_NO_INLINE_ERROR |
| 171 |
# ifdef error_at_line |
| 172 |
*/ |
| 173 |
# if _GL_GNUC_PREREQ (4, 7) |
| 174 |
# pragma GCC diagnostic push |
| 175 |
# pragma GCC diagnostic ignored "-Wattributes" |
| 176 |
_GL_ATTRIBUTE_MAYBE_UNUSED |
| 177 |
static void |
| 178 |
_GL_ATTRIBUTE_ALWAYS_INLINE |
| 179 |
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6)) |
| 180 |
_gl_inline_error_at_line (int __status, int __errnum, const char *__filename, |
| 181 |
unsigned int __lineno, const char *__format, ...) |
| 182 |
{ |
| 183 |
return error_at_line (__status, __errnum, __filename, __lineno, __format, |
| 184 |
__builtin_va_arg_pack ()); |
| 185 |
} |
| 186 |
# pragma GCC diagnostic pop |
| 187 |
# undef error_at_line |
| 188 |
# define error_at_line(status, ...) \ |
| 189 |
__gl_error_call (_gl_inline_error_at_line, status, __VA_ARGS__) |
| 190 |
# endif |
| 191 |
# else |
| 192 |
# define error_at_line(status, ...) \ |
| 193 |
__gl_error_call (error_at_line, status, __VA_ARGS__) |
| 194 |
# endif |
| 195 |
# endif |
| 196 |
#endif |
| 197 |
_GL_CXXALIASWARN (error_at_line); |
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
extern void (*error_print_progname) (void); |
| 203 |
|
| 204 |
|
| 205 |
extern unsigned int error_message_count; |
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
extern int error_one_per_line; |
| 210 |
|
| 211 |
#ifdef __cplusplus |
| 212 |
} |
| 213 |
#endif |
| 214 |
|
| 215 |
#endif |
| 216 |
#endif |