error.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* Copyright (C) 2005-2015 Free Software Foundation, Inc.
  2. Contributed by Richard Henderson <rth@redhat.com>.
  3. This file is part of the GNU Offloading and Multi Processing Library
  4. (libgomp).
  5. Libgomp is free software; you can redistribute it and/or modify it
  6. under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3, or (at your option)
  8. any later version.
  9. Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. more details.
  13. Under Section 7 of GPL version 3, you are granted additional
  14. permissions described in the GCC Runtime Library Exception, version
  15. 3.1, as published by the Free Software Foundation.
  16. You should have received a copy of the GNU General Public License and
  17. a copy of the GCC Runtime Library Exception along with this program;
  18. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. <http://www.gnu.org/licenses/>. */
  20. /* This file contains routines used to signal errors. Most places in the
  21. OpenMP API do not make any provision for failure, so we can't just
  22. defer the decision on reporting the problem to the user; we must do it
  23. ourselves or not at all. */
  24. /* ??? Is this about what other implementations do? Assume stderr hasn't
  25. been pointed somewhere unsafe? */
  26. #include "libgomp.h"
  27. #include <stdarg.h>
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30. #undef gomp_vdebug
  31. void
  32. gomp_vdebug (int kind __attribute__ ((unused)), const char *msg, va_list list)
  33. {
  34. if (gomp_debug_var)
  35. vfprintf (stderr, msg, list);
  36. }
  37. #undef gomp_debug
  38. void
  39. gomp_debug (int kind, const char *msg, ...)
  40. {
  41. va_list list;
  42. va_start (list, msg);
  43. gomp_vdebug (kind, msg, list);
  44. va_end (list);
  45. }
  46. void
  47. gomp_verror (const char *fmt, va_list list)
  48. {
  49. fputs ("\nlibgomp: ", stderr);
  50. vfprintf (stderr, fmt, list);
  51. fputc ('\n', stderr);
  52. }
  53. void
  54. gomp_error (const char *fmt, ...)
  55. {
  56. va_list list;
  57. va_start (list, fmt);
  58. gomp_verror (fmt, list);
  59. va_end (list);
  60. }
  61. void
  62. gomp_vfatal (const char *fmt, va_list list)
  63. {
  64. gomp_verror (fmt, list);
  65. exit (EXIT_FAILURE);
  66. }
  67. void
  68. gomp_fatal (const char *fmt, ...)
  69. {
  70. va_list list;
  71. va_start (list, fmt);
  72. gomp_vfatal (fmt, list);
  73. va_end (list);
  74. }