-
Notifications
You must be signed in to change notification settings - Fork 0
/
mm_eh.h
125 lines (99 loc) · 4.44 KB
/
mm_eh.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/************************************************************************ *
* Goma - Multiphysics finite element software *
* Sandia National Laboratories *
* *
* Copyright (c) 2014 Sandia Corporation. *
* *
* Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, *
* the U.S. Government retains certain rights in this software. *
* *
* This software is distributed under the GNU General Public License. *
\************************************************************************/
/*
*$Id: mm_eh.h,v 5.2 2007-09-18 18:53:42 prschun Exp $
*/
#ifndef _MM_EH_H
#define _MM_EH_H
#ifdef EXTERN
#undef EXTERN
#endif
#ifdef _MM_EH_C
#define EXTERN /* do nothing */
#endif
#ifndef _MM_EH_C
#define EXTERN extern
#endif
#include <stdarg.h> /* for var args... */
/*
* This variable is included as a utility to writing informative
* strings before error exiting.
*/
extern char Err_Msg[MAX_CHAR_ERR_MSG];
EXTERN void eh
PROTO((const int , /* error_flag */
const char * const, /* file */
const int , /* line */
const char * const)); /* message */
EXTERN void wh
PROTO((const int , /* error_flag */
const char * const, /* file */
const int , /* line */
const char * const, /* message */
int * const)); /* iw */
extern void aborth(const int, const char * const, const int,
const char * const);
EXTERN void save_place /* mm_eh.c */
PROTO((const int , /* severity */
const char * const, /* routine_name */
const char * const, /* file_name */
const int )); /* line_number */
EXTERN void logprintf /* mm_eh.c */
PROTO((const char *, /* format */
... )); /* var args */
EXTERN void smooth_stop_with_msg
PROTO((const char * msg));
/* This macro expands to a function call to the error handler eh() with
* four arguments:
* IERR -- an int, if IERR=-1 there is a problem
* MESSAGE -- a string, which gets printed if the
* error dump is activated by IERR=-1
*
* eh() finally exits with -1 if an error occurred.
*
* Intent:
* -------
* EH(return_code, "I am informative.");
*/
#define EH(IERR, MESSAGE) eh(IERR, __FILE__, __LINE__, MESSAGE)
#define WH(IERR, MESSAGE) {static int iw=0; if (iw == 0) wh(IERR, __FILE__, __LINE__, MESSAGE, &iw);}
#define ABORTH(IERR, MESSAGE) aborth(IERR, __FILE__, __LINE__, MESSAGE)
#define GOMA_ERR (-1) /* definitely print; definitely exit */
#define GOMA_MSG (0) /* usually print; continue */
#define GOMA_DBG (1) /* maybe print; continue */
#define TIME_STRING_SIZE (256)
extern char current_routine[]; /* name of current routine. */
extern char current_file[]; /* name of current file */
extern int current_line; /* line number in file */
extern int current_severity; /* global error signal (-1=die,0=prnt,1=dbg) */
/*
* Yes, this is an accident waiting to happen to the unwary that don't
* use curly braces for one liners like
*
* if ( condition ) log_err("blah");
*
* that will break unless they are written as
*
* if ( condition ) { log_err("blah"); }
*
* If you can figure out a way to do it that permits varargs and throws in
* the extra args so the user doesn't have to do it by hand, then have at it.
*
* Requires use of a local static const char yo[] ="Routine_name".
*/
#define log_err save_place(GOMA_ERR, yo, __FILE__, __LINE__); logprintf
#define log_msg save_place(GOMA_MSG, yo, __FILE__, __LINE__); logprintf
#define log_dbg save_place(GOMA_DBG, yo, __FILE__, __LINE__); logprintf
#ifndef DEFAULT_GOMA_LOG_FILENAME
#define DEFAULT_GOMA_LOG_FILENAME ".log"
#endif
#endif