error-ldbl.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* Redirections for error.h functions for -mlong-double-64.
  17. Copyright (C) 2019-2026 Free Software Foundation, Inc.
  18. This file is part of the GNU C Library.
  19. The GNU C Library is free software; you can redistribute it and/or
  20. modify it under the terms of the GNU Lesser General Public
  21. License as published by the Free Software Foundation; either
  22. version 2.1 of the License, or (at your option) any later version.
  23. The GNU C Library is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26. Lesser General Public License for more details.
  27. You should have received a copy of the GNU Lesser General Public
  28. License along with the GNU C Library; if not, see
  29. <https://www.gnu.org/licenses/>. */
  30. #ifndef _ERROR_H
  31. # error "Never include <bits/error-ldbl.h> directly; use <error.h> instead."
  32. #endif
  33. #if defined __extern_always_inline && defined __va_arg_pack
  34. extern void __REDIRECT_LDBL (__error_alias, (int __status, int __errnum,
  35. const char *__format, ...), error)
  36. __attribute__ ((__format__ (__printf__, 3, 4)));
  37. extern void __REDIRECT_LDBL (__error_noreturn, (int __status, int __errnum,
  38. const char *__format, ...), error)
  39. __attribute__ ((__noreturn__, __format__ (__printf__, 3, 4)));
  40. /* If we know the function will never return make sure the compiler
  41. realizes that, too. */
  42. __extern_always_inline void
  43. error (int __status, int __errnum, const char *__format, ...)
  44. {
  45. if (__builtin_constant_p (__status) && __status != 0)
  46. __error_noreturn (__status, __errnum, __format, __va_arg_pack ());
  47. else
  48. __error_alias (__status, __errnum, __format, __va_arg_pack ());
  49. }
  50. extern void __REDIRECT_LDBL (__error_at_line_alias, (int __status, int __errnum,
  51. const char *__fname, unsigned int __line,
  52. const char *__format, ...), error_at_line)
  53. __attribute__ ((__format__ (__printf__, 5, 6)));
  54. extern void __REDIRECT_LDBL (__error_at_line_noreturn, (int __status, int __errnum,
  55. const char *__fname, unsigned int __line,
  56. const char *__format, ...), error_at_line)
  57. __attribute__ ((__noreturn__, __format__ (__printf__, 5, 6)));
  58. /* If we know the function will never return make sure the compiler
  59. realizes that, too. */
  60. __extern_always_inline void
  61. error_at_line (int __status, int __errnum, const char *__fname,
  62. unsigned int __line, const char *__format, ...)
  63. {
  64. if (__builtin_constant_p (__status) && __status != 0)
  65. __error_at_line_noreturn (__status, __errnum, __fname, __line, __format,
  66. __va_arg_pack ());
  67. else
  68. __error_at_line_alias (__status, __errnum, __fname, __line,
  69. __format, __va_arg_pack ());
  70. }
  71. #endif
  72. __LDBL_REDIR_DECL (error)
  73. __LDBL_REDIR_DECL (error_at_line)