]> granicus.if.org Git - postgresql/blob - src/include/utils/exc.h
Massive commit to run PGINDENT on all *.c and *.h files.
[postgresql] / src / include / utils / exc.h
1 /*-------------------------------------------------------------------------
2  *
3  * exc.h--
4  *        POSTGRES exception handling definitions.
5  *
6  *
7  * Copyright (c) 1994, Regents of the University of California
8  *
9  * $Id: exc.h,v 1.8 1997/09/07 05:02:28 momjian Exp $
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef EXC_H
14 #define EXC_H
15
16 #include <setjmp.h>
17
18 #include "config.h"
19
20 extern char    *ExcFileName;
21 extern Index    ExcLineNumber;
22
23 /*
24  * ExcMessage and Exception are now defined in c.h
25  */
26 #if defined(JMP_BUF)
27 typedef jmp_buf ExcContext;
28
29 #else
30 typedef sigjmp_buf ExcContext;
31
32 #endif
33
34 typedef Exception *ExcId;
35 typedef long    ExcDetail;
36 typedef char   *ExcData;
37
38 typedef struct ExcFrame
39 {
40         struct ExcFrame *link;
41         ExcContext              context;
42         ExcId                   id;
43         ExcDetail               detail;
44         ExcData                 data;
45         ExcMessage              message;
46 }                               ExcFrame;
47
48 extern ExcFrame *ExcCurFrameP;
49
50 #define ExcBegin()                                                                                                              \
51                 {                                                                                                                               \
52                                 ExcFrame                exception;                                                              \
53                                                                                                                                                 \
54                                 exception.link = ExcCurFrameP;                                                  \
55                                 if (sigsetjmp(exception.context, 1) == 0) {                             \
56                                                 ExcCurFrameP = &exception;                                              \
57                                                 {
58 #define ExcExcept()                                                                                                             \
59                                                 }                                                                                               \
60                                                 ExcCurFrameP = exception.link;                                  \
61                                 } else {                                                                                                \
62                                                 {
63 #define ExcEnd()                                                                                                                \
64                                                 }                                                                                               \
65                                 }                                                                                                               \
66                 }
67
68 #define raise4(x, t, d, message) \
69                 ExcRaise(&(x), (ExcDetail)(t), (ExcData)(d), (ExcMessage)(message))
70
71 #define reraise() \
72                 raise4(*exception.id,exception.detail,exception.data,exception.message)
73
74 typedef void    ExcProc(Exception *, ExcDetail, ExcData, ExcMessage);
75
76
77 /*
78  * prototypes for functions in exc.c
79  */
80 extern void             EnableExceptionHandling(bool on);
81 extern void
82 ExcRaise(Exception * excP,
83                  ExcDetail detail,
84                  ExcData data,
85                  ExcMessage message);
86
87
88 /*
89  * prototypes for functions in excabort.c
90  */
91 extern void
92 ExcAbort(const Exception * excP, ExcDetail detail, ExcData data,
93                  ExcMessage message);
94
95 #endif                                                  /* EXC_H */