]> git.ipfire.org Git - thirdparty/glibc.git/blame - misc/bits/error.h
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / misc / bits / error.h
CommitLineData
fae56ce8 1/* Specializations for error functions.
6d7e8eda 2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
fae56ce8
UD
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
59ba27a6 16 License along with the GNU C Library; if not, see
5a82c748 17 <https://www.gnu.org/licenses/>. */
fae56ce8
UD
18
19#ifndef _ERROR_H
b80bfc8b 20# error "Never include <bits/error.h> directly; use <error.h> instead."
fae56ce8
UD
21#endif
22
23
24extern void __REDIRECT (__error_alias, (int __status, int __errnum,
a784e502 25 const char *__format, ...),
fae56ce8
UD
26 error)
27 __attribute__ ((__format__ (__printf__, 3, 4)));
28extern void __REDIRECT (__error_noreturn, (int __status, int __errnum,
a784e502 29 const char *__format, ...),
fae56ce8
UD
30 error)
31 __attribute__ ((__noreturn__, __format__ (__printf__, 3, 4)));
32
33
34/* If we know the function will never return make sure the compiler
35 realizes that, too. */
36__extern_always_inline void
a784e502 37error (int __status, int __errnum, const char *__format, ...)
fae56ce8
UD
38{
39 if (__builtin_constant_p (__status) && __status != 0)
40 __error_noreturn (__status, __errnum, __format, __va_arg_pack ());
41 else
42 __error_alias (__status, __errnum, __format, __va_arg_pack ());
43}
44
45
46extern void __REDIRECT (__error_at_line_alias, (int __status, int __errnum,
a784e502 47 const char *__fname,
fae56ce8 48 unsigned int __line,
a784e502 49 const char *__format, ...),
fae56ce8
UD
50 error_at_line)
51 __attribute__ ((__format__ (__printf__, 5, 6)));
52extern void __REDIRECT (__error_at_line_noreturn, (int __status, int __errnum,
a784e502 53 const char *__fname,
fae56ce8 54 unsigned int __line,
a784e502 55 const char *__format,
a1a363d2 56 ...),
fae56ce8
UD
57 error_at_line)
58 __attribute__ ((__noreturn__, __format__ (__printf__, 5, 6)));
59
60
61/* If we know the function will never return make sure the compiler
62 realizes that, too. */
63__extern_always_inline void
a784e502
UD
64error_at_line (int __status, int __errnum, const char *__fname,
65 unsigned int __line, const char *__format, ...)
fae56ce8
UD
66{
67 if (__builtin_constant_p (__status) && __status != 0)
68 __error_at_line_noreturn (__status, __errnum, __fname, __line, __format,
69 __va_arg_pack ());
70 else
71 __error_at_line_alias (__status, __errnum, __fname, __line,
72 __format, __va_arg_pack ());
73}