error.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* Specializations for error functions.
  2. Copyright (C) 2007 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. #ifndef _ERROR_H
  17. # error "Never include <bits/error.h> directly; use <error.h> instead."
  18. #endif
  19. extern void __REDIRECT (__error_alias, (int __status, int __errnum,
  20. __const char *__format, ...),
  21. error)
  22. __attribute__ ((__format__ (__printf__, 3, 4)));
  23. extern void __REDIRECT (__error_noreturn, (int __status, int __errnum,
  24. __const char *__format, ...),
  25. error)
  26. __attribute__ ((__noreturn__, __format__ (__printf__, 3, 4)));
  27. /* If we know the function will never return make sure the compiler
  28. realizes that, too. */
  29. __extern_always_inline void
  30. error (int __status, int __errnum, __const char *__format, ...)
  31. {
  32. if (__builtin_constant_p (__status) && __status != 0)
  33. __error_noreturn (__status, __errnum, __format, __va_arg_pack ());
  34. else
  35. __error_alias (__status, __errnum, __format, __va_arg_pack ());
  36. }
  37. extern void __REDIRECT (__error_at_line_alias, (int __status, int __errnum,
  38. __const char *__fname,
  39. unsigned int __line,
  40. __const char *__format, ...),
  41. error_at_line)
  42. __attribute__ ((__format__ (__printf__, 5, 6)));
  43. extern void __REDIRECT (__error_at_line_noreturn, (int __status, int __errnum,
  44. __const char *__fname,
  45. unsigned int __line,
  46. __const char *__format,
  47. ...),
  48. error_at_line)
  49. __attribute__ ((__noreturn__, __format__ (__printf__, 5, 6)));
  50. /* If we know the function will never return make sure the compiler
  51. realizes that, too. */
  52. __extern_always_inline void
  53. error_at_line (int __status, int __errnum, __const char *__fname,
  54. unsigned int __line,__const char *__format, ...)
  55. {
  56. if (__builtin_constant_p (__status) && __status != 0)
  57. __error_at_line_noreturn (__status, __errnum, __fname, __line, __format,
  58. __va_arg_pack ());
  59. else
  60. __error_at_line_alias (__status, __errnum, __fname, __line,
  61. __format, __va_arg_pack ());
  62. }