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 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
27#include <pthread.h>
28#include "nilorea/n_common.h"
29#include "nilorea/n_log.h"
31
33
37void push_exception(void) {
39
40 if (_new) {
41 _new->head = __Exceptions;
42 __Exceptions = _new;
43 } else {
44 n_log(LOG_ERR, "Cannot even add a new exception context !!");
45 }
46} /* push_exception() */
47
52void pop_exception(int ex) {
53 if (!__Exceptions)
54 return;
55 ExceptionContextList* head = NULL;
56 head = __Exceptions->head;
58 __Exceptions = head;
59
60 if (ex != NO_EXCEPTION) {
61 if (__Exceptions) {
62 longjmp(__Exceptions->context, ex);
63 }
64 }
65} /* pop_exception */
#define Free(__ptr)
Free Handler to get errors.
Definition n_common.h:262
jmp_buf context
saving the current context
struct ExceptionContextList * head
pointer to the next stacked exception
__thread ExceptionContextList * __Exceptions
Globale variable for exception stack management.
void pop_exception(int ex)
Function to pop an exception in the list.
#define NO_EXCEPTION
Possibly Throwed value, everything is fine.
void push_exception(void)
Function to push an exception in the list.
Exception stack structure.
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
Definition n_log.h:88
#define LOG_ERR
error conditions
Definition n_log.h:75
Common headers and low-level functions & define.
Exception management for C.
Generic log system.