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