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
28#include <pthread.h>
29#include "nilorea/n_common.h"
30#include "nilorea/n_log.h"
32
34
38void push_exception(void) {
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
53void pop_exception(int ex) {
54 if (!__Exceptions)
55 return;
56 ExceptionContextList* head = NULL;
57 head = __Exceptions->head;
59 __Exceptions = head;
60
61 if (ex != NO_EXCEPTION) {
62 if (__Exceptions) {
63 longjmp(__Exceptions->context, ex);
64 }
65 }
66} /* pop_exception */
#define Free(__ptr)
Free Handler to get errors.
Definition n_common.h:263
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:89
#define LOG_ERR
error conditions
Definition n_log.h:76
Common headers and low-level functions & define.
Exception management for C.
Generic log system.