Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_exceptions.c
Go to the documentation of this file.
1
8
#include <pthread.h>
9
#include "
nilorea/n_common.h
"
10
#include "
nilorea/n_log.h
"
11
#include "
nilorea/n_exceptions.h
"
12
13
ExceptionContextList
*
__Exceptions
= NULL;
14
18
void
push_exception
(
void
) {
19
ExceptionContextList
* _new = (
ExceptionContextList
*)malloc(
sizeof
(
ExceptionContextList
));
20
21
if
(_new) {
22
_new->
head
=
__Exceptions
;
23
__Exceptions
= _new;
24
}
else
{
25
n_log
(
LOG_ERR
,
"Cannot even add a new exception context !!"
);
26
}
27
}
/* push_exception() */
28
33
void
pop_exception
(
int
ex) {
34
ExceptionContextList
* head = NULL;
35
head =
__Exceptions
->
head
;
36
Free
(
__Exceptions
);
37
__Exceptions
= head;
38
39
if
(ex !=
NO_EXCEPTION
) {
40
if
(
__Exceptions
) {
41
longjmp(
__Exceptions
->
context
, ex);
42
}
43
}
44
}
/* pop_exception */
Free
#define Free(__ptr)
Free Handler to get errors.
Definition
n_common.h:242
ExceptionContextList::context
jmp_buf context
saving the current context
Definition
n_exceptions.h:41
ExceptionContextList::head
struct ExceptionContextList * head
pointer to the next stacked exception
Definition
n_exceptions.h:43
pop_exception
void pop_exception(int ex)
Function to pop an exception in the list.
Definition
n_exceptions.c:33
__Exceptions
ExceptionContextList * __Exceptions
Globale variable for exception stack management.
Definition
n_exceptions.c:13
NO_EXCEPTION
#define NO_EXCEPTION
Possibly Throwed value, everything is fine.
Definition
n_exceptions.h:25
push_exception
void push_exception(void)
Function to push an exception in the list.
Definition
n_exceptions.c:18
ExceptionContextList
Exception stack structure.
Definition
n_exceptions.h:39
n_log
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
Definition
n_log.h:69
LOG_ERR
#define LOG_ERR
error conditions
Definition
n_log.h:56
n_common.h
Common headers and low-level functions & define.
n_exceptions.h
Exception management for C.
n_log.h
Generic log system.
src
n_exceptions.c
Generated on Mon Jun 9 2025 22:06:43 for Nilorea Library by
1.9.8