SURFEX v8.1
General documentation of Surfex
raise.h
Go to the documentation of this file.
1 #ifndef _RAISE_H_
2 #define _RAISE_H_
3 
4 /* raise.h */
5 
6 #include <stdio.h>
7 #include <string.h>
8 #include <signal.h>
9 #include <unistd.h>
10 
11 extern void abor1fl_(const char *filename, const int *linenum,
12  const char *s,
13  int filenamelen, int slen);
14 extern void abor1_(const char *s, int slen);
15 
16 #define ABOR1(txt) { const char *t = (txt); t ? abor1_(t, strlen(t)) : abor1_("",0); }
17 
18 #define ABOR1FL(txt) { \
19  const char *t = (txt); \
20  int linenum=__LINE__; \
21  t ? abor1fl_(__FILE__, &linenum, t, sizeof(__FILE__)-1, strlen(t)) \
22  : abor1fl_(__FILE__, &linenum, "", sizeof(__FILE__)-1, 0); \
23  _exit(1); /* Should never end up here */ }
24 
25 #define RAISE(x) { \
26  if ((x) == SIGABRT) { \
27  ABOR1FL("*** Fatal error; aborting (SIGABRT) ..."); \
28  _exit(1); /* Should never end up here */ \
29  } \
30  else raise(x); \
31 }
32 
33 #endif /* _RAISE_H_ */
void abor1_(const char *s, int slen)
void abor1fl_(const char *filename, const int *linenum, const char *s, int filenamelen, int slen)