35#include "ws_symbol_export.h"
36#include "ws_attributes.h"
38#define XCEPT_GROUP_ANY 0
39#define XCEPT_CODE_ANY 0
40#define XCEPT_BAD_ALLOC 1
46enum { except_no_call, except_call };
49 unsigned long except_group;
50 unsigned long except_code;
55 const char *
volatile except_message;
56 void *
volatile except_dyndata;
60 void (*except_func)(
void *);
71enum except_stacktype {
72 XCEPT_CLEANUP, XCEPT_CATCHER
137WS_DLL_PUBLIC WS_NORETURN
void except_throw(
long group,
long code,
const char *msg);
139WS_DLL_PUBLIC WS_NORETURN
void except_throwd(
long,
long,
const char *,
void *);
140WS_DLL_PUBLIC WS_NORETURN
void except_vthrowf(
long group,
long code,
const char *fmt, va_list vl);
141WS_DLL_PUBLIC WS_NORETURN
void except_throwf(
long,
long,
const char *, ...)
143WS_DLL_PUBLIC
void (*except_unhandled_catcher(
void (*)(
except_t *)))(
except_t *);
144extern
unsigned long except_code(
except_t *);
145extern
unsigned long except_group(
except_t *);
146extern const
char *except_message(
except_t *);
147extern
void *except_data(
except_t *);
157WS_DLL_PUBLIC
void except_set_allocator(
void *(*)(
size_t),
void (*)(
void *));
158WS_DLL_PUBLIC
void *except_alloc(
size_t);
188#define except_code(E) ((E)->except_id.except_code)
189#define except_group(E) ((E)->except_id.except_group)
190#define except_message(E) ((E)->except_message)
191#define except_data(E) ((E)->except_dyndata)
205#define except_cleanup_push(F, C) \
207 struct except_stacknode except_sn; \
208 struct except_cleanup except_cl; \
209 except_setup_clean(&except_sn, &except_cl, F, C)
211#define except_cleanup_pop(E) \
214 except_cl.except_func(except_cl.except_context); \
217#define except_checked_cleanup_pop(F, E) \
219 assert (except_cl.except_func == (F)); \
221 except_cl.except_func(except_cl.except_context); \
226#define except_cleanup_push_pfx(pfx, F, C) \
228 struct except_stacknode pfx##_except_sn; \
229 struct except_cleanup pfx##_except_cl; \
230 except_setup_clean(&pfx##_except_sn, &pfx##_except_cl, F, C)
232#define except_cleanup_pop_pfx(pfx, E) \
235 pfx##_except_cl.except_func(pfx##_except_cl.except_context);\
238#define except_checked_cleanup_pop_pfx(pfx, F, E) \
240 assert (pfx##_except_cl.except_func == (F)); \
242 pfx##_except_cl.except_func(pfx##_except_cl.except_context);\
247#define except_try_push(ID, NUM, PPE) \
249 struct except_stacknode except_sn; \
250 struct except_catch except_ch; \
251 except_setup_try(&except_sn, &except_ch, ID, NUM); \
252 if (setjmp(except_ch.except_jmp)) \
253 *(PPE) = &except_ch.except_obj; \
257#define except_try_pop() \
258 except_free(except_ch.except_obj.except_dyndata); \
WS_DLL_PUBLIC struct except_stacknode * except_pop(void)
Pop the top node from the exception stack.
Definition except.c:270
WS_DLL_PUBLIC void except_setup_try(struct except_stacknode *, struct except_catch *, const except_id_t[], size_t)
Set up a try block for exception handling.
Definition except.c:259
WS_DLL_PUBLIC void * except_take_data(except_t *ex)
Take data from an exception object.
Definition except.c:374
const struct except_stacknode * except_get_top(void)
Get the top node from the exception stack.
Definition except.c:175
WS_DLL_PUBLIC void except_setup_clean(struct except_stacknode *, struct except_cleanup *, void(*)(void *), void *)
Set up a cleanup handler for exception handling.
Definition except.c:249
WS_DLL_PUBLIC WS_NORETURN void except_throw(long group, long code, const char *msg)
Throw an exception with a message and optional data.
Definition except.c:288
WS_DLL_PUBLIC int except_init(void)
Initialize the exception handling system.
Definition except.c:160
WS_DLL_PUBLIC void except_deinit(void)
Deinitialize the exception handling system.
Definition except.c:167
WS_DLL_PUBLIC WS_NORETURN void except_rethrow(except_t *except)
Rethrow an exception.
Definition except.c:278
WS_DLL_PUBLIC void except_free(void *ptr)
Frees memory allocated for an exception node.
Definition except.c:396
void except_set_top(struct except_stacknode *node)
Set the top node of an exception stack.
Definition except.c:180
Represents a node in the exception handling stack.
Definition except.h:82
struct except_cleanup * except_cleanup
Definition except.h:87
enum except_stacktype except_type
Definition except.h:84
struct except_stacknode * except_down
Definition except.h:83
struct except_catch * except_catcher
Definition except.h:86