| 1 |
/* do not edit automatically generated by mc from RTExceptions. */ |
| 2 |
/* RTExceptions.def runtime exception handler routines. |
| 3 |
|
| 4 |
Copyright (C) 2008-2025 Free Software Foundation, Inc. |
| 5 |
Contributed by Gaius Mulley <[email protected]>. |
| 6 |
|
| 7 |
This file is part of GNU Modula-2. |
| 8 |
|
| 9 |
GNU Modula-2 is free software; you can redistribute it and/or modify |
| 10 |
it under the terms of the GNU General Public License as published by |
| 11 |
the Free Software Foundation; either version 3, or (at your option) |
| 12 |
any later version. |
| 13 |
|
| 14 |
GNU Modula-2 is distributed in the hope that it will be useful, but |
| 15 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 |
General Public License for more details. |
| 18 |
|
| 19 |
Under Section 7 of GPL version 3, you are granted additional |
| 20 |
permissions described in the GCC Runtime Library Exception, version |
| 21 |
3.1, as published by the Free Software Foundation. |
| 22 |
|
| 23 |
You should have received a copy of the GNU General Public License and |
| 24 |
a copy of the GCC Runtime Library Exception along with this program; |
| 25 |
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 26 |
<http://www.gnu.org/licenses/>. */ |
| 27 |
|
| 28 |
|
| 29 |
#if !defined (_RTExceptions_H) |
| 30 |
# define _RTExceptions_H |
| 31 |
|
| 32 |
# ifdef __cplusplus |
| 33 |
extern "C" { |
| 34 |
# endif |
| 35 |
#include <stdbool.h> |
| 36 |
# if !defined (PROC_D) |
| 37 |
# define PROC_D |
| 38 |
typedef void (*PROC_t) (void); |
| 39 |
typedef struct { PROC_t proc; } PROC; |
| 40 |
# endif |
| 41 |
|
| 42 |
# include "GSYSTEM.h" |
| 43 |
|
| 44 |
# if defined (_RTExceptions_C) |
| 45 |
# define EXTERN |
| 46 |
# else |
| 47 |
# define EXTERN extern |
| 48 |
# endif |
| 49 |
|
| 50 |
#if !defined (RTExceptions_EHBlock_D) |
| 51 |
# define RTExceptions_EHBlock_D |
| 52 |
typedef void *RTExceptions_EHBlock; |
| 53 |
#endif |
| 54 |
|
| 55 |
typedef struct RTExceptions_ProcedureHandler_p RTExceptions_ProcedureHandler; |
| 56 |
|
| 57 |
typedef void (*RTExceptions_ProcedureHandler_t) (void); |
| 58 |
struct RTExceptions_ProcedureHandler_p { RTExceptions_ProcedureHandler_t proc; }; |
| 59 |
|
| 60 |
|
| 61 |
/* |
| 62 |
Raise - invoke the exception handler associated with, number, |
| 63 |
in the active EHBlock. It keeps a record of the number |
| 64 |
and message in the EHBlock for later use. |
| 65 |
*/ |
| 66 |
|
| 67 |
EXTERN void RTExceptions_Raise (unsigned int number, void * file, unsigned int line, unsigned int column, void * function, void * message) __attribute__ ((noreturn)); |
| 68 |
|
| 69 |
/* |
| 70 |
SetExceptionBlock - sets, source, as the active EHB. |
| 71 |
*/ |
| 72 |
|
| 73 |
EXTERN void RTExceptions_SetExceptionBlock (RTExceptions_EHBlock source); |
| 74 |
|
| 75 |
/* |
| 76 |
GetExceptionBlock - returns the active EHB. |
| 77 |
*/ |
| 78 |
|
| 79 |
EXTERN RTExceptions_EHBlock RTExceptions_GetExceptionBlock (void); |
| 80 |
|
| 81 |
/* |
| 82 |
GetTextBuffer - returns the address of the EHB buffer. |
| 83 |
*/ |
| 84 |
|
| 85 |
EXTERN void * RTExceptions_GetTextBuffer (RTExceptions_EHBlock e); |
| 86 |
|
| 87 |
/* |
| 88 |
GetTextBufferSize - return the size of the EHB text buffer. |
| 89 |
*/ |
| 90 |
|
| 91 |
EXTERN unsigned int RTExceptions_GetTextBufferSize (RTExceptions_EHBlock e); |
| 92 |
|
| 93 |
/* |
| 94 |
GetNumber - return the exception number associated with, |
| 95 |
source. |
| 96 |
*/ |
| 97 |
|
| 98 |
EXTERN unsigned int RTExceptions_GetNumber (RTExceptions_EHBlock source); |
| 99 |
|
| 100 |
/* |
| 101 |
InitExceptionBlock - creates and returns a new exception block. |
| 102 |
*/ |
| 103 |
|
| 104 |
EXTERN RTExceptions_EHBlock RTExceptions_InitExceptionBlock (void); |
| 105 |
|
| 106 |
/* |
| 107 |
KillExceptionBlock - destroys the EHB, e, and all its handlers. |
| 108 |
*/ |
| 109 |
|
| 110 |
EXTERN RTExceptions_EHBlock RTExceptions_KillExceptionBlock (RTExceptions_EHBlock e); |
| 111 |
|
| 112 |
/* |
| 113 |
PushHandler - install a handler in EHB, e. |
| 114 |
*/ |
| 115 |
|
| 116 |
EXTERN void RTExceptions_PushHandler (RTExceptions_EHBlock e, unsigned int number, RTExceptions_ProcedureHandler p); |
| 117 |
|
| 118 |
/* |
| 119 |
PopHandler - removes the handler associated with, number, from |
| 120 |
EHB, e. |
| 121 |
*/ |
| 122 |
|
| 123 |
EXTERN void RTExceptions_PopHandler (RTExceptions_EHBlock e, unsigned int number); |
| 124 |
|
| 125 |
/* |
| 126 |
DefaultErrorCatch - displays the current error message in |
| 127 |
the current exception block and then |
| 128 |
calls HALT. |
| 129 |
*/ |
| 130 |
|
| 131 |
EXTERN void RTExceptions_DefaultErrorCatch (void); |
| 132 |
|
| 133 |
/* |
| 134 |
BaseExceptionsThrow - configures the Modula-2 exceptions to call |
| 135 |
THROW which in turn can be caught by an |
| 136 |
exception block. If this is not called then |
| 137 |
a Modula-2 exception will simply call an |
| 138 |
error message routine and then HALT. |
| 139 |
*/ |
| 140 |
|
| 141 |
EXTERN void RTExceptions_BaseExceptionsThrow (void); |
| 142 |
|
| 143 |
/* |
| 144 |
IsInExceptionState - returns TRUE if the program is currently |
| 145 |
in the exception state. |
| 146 |
*/ |
| 147 |
|
| 148 |
EXTERN bool RTExceptions_IsInExceptionState (void); |
| 149 |
|
| 150 |
/* |
| 151 |
SetExceptionState - returns the current exception state and |
| 152 |
then sets the current exception state to, |
| 153 |
to. |
| 154 |
*/ |
| 155 |
|
| 156 |
EXTERN bool RTExceptions_SetExceptionState (bool to); |
| 157 |
|
| 158 |
/* |
| 159 |
SwitchExceptionState - assigns, from, with the current exception |
| 160 |
state and then assigns the current exception |
| 161 |
to, to. |
| 162 |
*/ |
| 163 |
|
| 164 |
EXTERN void RTExceptions_SwitchExceptionState (bool *from, bool to); |
| 165 |
|
| 166 |
/* |
| 167 |
GetBaseExceptionBlock - returns the initial language exception block |
| 168 |
created. |
| 169 |
*/ |
| 170 |
|
| 171 |
EXTERN RTExceptions_EHBlock RTExceptions_GetBaseExceptionBlock (void); |
| 172 |
|
| 173 |
/* |
| 174 |
SetExceptionSource - sets the current exception source to, source. |
| 175 |
*/ |
| 176 |
|
| 177 |
EXTERN void RTExceptions_SetExceptionSource (void * source); |
| 178 |
|
| 179 |
/* |
| 180 |
GetExceptionSource - returns the current exception source. |
| 181 |
*/ |
| 182 |
|
| 183 |
EXTERN void * RTExceptions_GetExceptionSource (void); |
| 184 |
# ifdef __cplusplus |
| 185 |
} |
| 186 |
# endif |
| 187 |
|
| 188 |
# undef EXTERN |
| 189 |
#endif |