1*8feb0f0bSmrg /* Copyright (C) 2005-2020 Free Software Foundation, Inc.
21debfc3dSmrg Contributed by Richard Henderson <rth@redhat.com>.
31debfc3dSmrg
41debfc3dSmrg This file is part of the GNU Offloading and Multi Processing Library
51debfc3dSmrg (libgomp).
61debfc3dSmrg
71debfc3dSmrg Libgomp is free software; you can redistribute it and/or modify it
81debfc3dSmrg under the terms of the GNU General Public License as published by
91debfc3dSmrg the Free Software Foundation; either version 3, or (at your option)
101debfc3dSmrg any later version.
111debfc3dSmrg
121debfc3dSmrg Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
131debfc3dSmrg WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
141debfc3dSmrg FOR A PARTICULAR PURPOSE. See the GNU General Public License for
151debfc3dSmrg more details.
161debfc3dSmrg
171debfc3dSmrg Under Section 7 of GPL version 3, you are granted additional
181debfc3dSmrg permissions described in the GCC Runtime Library Exception, version
191debfc3dSmrg 3.1, as published by the Free Software Foundation.
201debfc3dSmrg
211debfc3dSmrg You should have received a copy of the GNU General Public License and
221debfc3dSmrg a copy of the GCC Runtime Library Exception along with this program;
231debfc3dSmrg see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
241debfc3dSmrg <http://www.gnu.org/licenses/>. */
251debfc3dSmrg
261debfc3dSmrg /* This file contains routines used to signal errors. Most places in the
271debfc3dSmrg OpenMP API do not make any provision for failure, so we can't just
281debfc3dSmrg defer the decision on reporting the problem to the user; we must do it
291debfc3dSmrg ourselves or not at all. */
301debfc3dSmrg /* ??? Is this about what other implementations do? Assume stderr hasn't
311debfc3dSmrg been pointed somewhere unsafe? */
321debfc3dSmrg
331debfc3dSmrg #include "libgomp.h"
341debfc3dSmrg #include <stdarg.h>
351debfc3dSmrg #include <stdio.h>
361debfc3dSmrg #include <stdlib.h>
371debfc3dSmrg
381debfc3dSmrg
391debfc3dSmrg #undef gomp_vdebug
401debfc3dSmrg void
gomp_vdebug(int kind,const char * msg,va_list list)411debfc3dSmrg gomp_vdebug (int kind __attribute__ ((unused)), const char *msg, va_list list)
421debfc3dSmrg {
431debfc3dSmrg if (gomp_debug_var)
441debfc3dSmrg vfprintf (stderr, msg, list);
451debfc3dSmrg }
461debfc3dSmrg
471debfc3dSmrg #undef gomp_debug
481debfc3dSmrg void
gomp_debug(int kind,const char * msg,...)491debfc3dSmrg gomp_debug (int kind, const char *msg, ...)
501debfc3dSmrg {
511debfc3dSmrg va_list list;
521debfc3dSmrg
531debfc3dSmrg va_start (list, msg);
541debfc3dSmrg gomp_vdebug (kind, msg, list);
551debfc3dSmrg va_end (list);
561debfc3dSmrg }
571debfc3dSmrg
581debfc3dSmrg void
gomp_verror(const char * fmt,va_list list)591debfc3dSmrg gomp_verror (const char *fmt, va_list list)
601debfc3dSmrg {
611debfc3dSmrg fputs ("\nlibgomp: ", stderr);
621debfc3dSmrg vfprintf (stderr, fmt, list);
631debfc3dSmrg fputc ('\n', stderr);
641debfc3dSmrg }
651debfc3dSmrg
661debfc3dSmrg void
gomp_error(const char * fmt,...)671debfc3dSmrg gomp_error (const char *fmt, ...)
681debfc3dSmrg {
691debfc3dSmrg va_list list;
701debfc3dSmrg
711debfc3dSmrg va_start (list, fmt);
721debfc3dSmrg gomp_verror (fmt, list);
731debfc3dSmrg va_end (list);
741debfc3dSmrg }
751debfc3dSmrg
761debfc3dSmrg void
gomp_vfatal(const char * fmt,va_list list)771debfc3dSmrg gomp_vfatal (const char *fmt, va_list list)
781debfc3dSmrg {
791debfc3dSmrg gomp_verror (fmt, list);
801debfc3dSmrg exit (EXIT_FAILURE);
811debfc3dSmrg }
821debfc3dSmrg
831debfc3dSmrg void
gomp_fatal(const char * fmt,...)841debfc3dSmrg gomp_fatal (const char *fmt, ...)
851debfc3dSmrg {
861debfc3dSmrg va_list list;
871debfc3dSmrg
881debfc3dSmrg va_start (list, fmt);
891debfc3dSmrg gomp_vfatal (fmt, list);
901debfc3dSmrg va_end (list);
911debfc3dSmrg }
92