Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_exceptions.c
Go to the documentation of this file.
1
/*
2
* Nilorea Library
3
* Copyright (C) 2005-2026 Castagnier Mickael
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14
* implied. See the License for the specific language governing
15
* permissions and limitations under the License.
16
*
17
* SPDX-License-Identifier: Apache-2.0
18
*/
19
27
28
#include <pthread.h>
29
#include "
nilorea/n_common.h
"
30
#include "
nilorea/n_log.h
"
31
#include "
nilorea/n_exceptions.h
"
32
33
__thread
ExceptionContextList
*
__Exceptions
= NULL;
34
38
void
push_exception
(
void
) {
39
ExceptionContextList
* _new = (
ExceptionContextList
*)malloc(
sizeof
(
ExceptionContextList
));
40
41
if
(_new) {
42
_new->
head
=
__Exceptions
;
43
__Exceptions
= _new;
44
}
else
{
45
n_log
(
LOG_ERR
,
"Cannot even add a new exception context !!"
);
46
}
47
}
/* push_exception() */
48
53
void
pop_exception
(
int
ex) {
54
if
(!
__Exceptions
)
55
return
;
56
ExceptionContextList
* head = NULL;
57
head =
__Exceptions
->head;
58
Free
(
__Exceptions
);
59
__Exceptions
= head;
60
61
if
(ex !=
NO_EXCEPTION
) {
62
if
(
__Exceptions
) {
63
longjmp(
__Exceptions
->context, ex);
64
}
65
}
66
}
/* pop_exception */
Free
#define Free(__ptr)
Free Handler to get errors.
Definition
n_common.h:263
ExceptionContextList::head
struct ExceptionContextList * head
pointer to the next stacked exception
Definition
n_exceptions.h:63
__Exceptions
__thread ExceptionContextList * __Exceptions
Globale variable for exception stack management.
Definition
n_exceptions.c:33
pop_exception
void pop_exception(int ex)
Function to pop an exception in the list.
Definition
n_exceptions.c:53
NO_EXCEPTION
#define NO_EXCEPTION
Possibly Throwed value, everything is fine.
Definition
n_exceptions.h:45
push_exception
void push_exception(void)
Function to push an exception in the list.
Definition
n_exceptions.c:38
ExceptionContextList
Exception stack structure.
Definition
n_exceptions.h:59
n_log
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
Definition
n_log.h:113
LOG_ERR
#define LOG_ERR
error conditions
Definition
n_log.h:100
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
for Nilorea Library by
1.15.0