EM-ODP 4.4.0
Event Machine on ODP
Loading...
Searching...
No Matches
event_machine_error.c
1/*
2 * Copyright (c) 2015-2023, Nokia Solutions and Networks
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its
15 * contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef _GNU_SOURCE
32#define _GNU_SOURCE
33#endif
34
35#ifdef HAVE_CONFIG_H
36#include "config.h"
37#endif
38
39#include <odp_api.h>
40
41#include <event_machine.h>
42
43#include "em_error.h"
44#include "em_mem.h"
45
48{
49 RETURN_ERROR_IF(!em_shm->error_handler.initialized,
50 EM_ERR_NOT_INITIALIZED, EM_ESCOPE_REGISTER_ERROR_HANDLER,
51 "Error Handling not initialized!");
52
53 odp_ticketlock_lock(&em_shm->error_handler.lock);
54
55 em_shm->error_handler.em_error_handler = handler;
56
57 odp_ticketlock_unlock(&em_shm->error_handler.lock);
58
59 return EM_OK;
60}
61
64{
65 RETURN_ERROR_IF(!em_shm->error_handler.initialized,
66 EM_ERR_NOT_INITIALIZED, EM_ESCOPE_UNREGISTER_ERROR_HANDLER,
67 "Error Handling not initialized!");
68
69 odp_ticketlock_lock(&em_shm->error_handler.lock);
70
71 em_shm->error_handler.em_error_handler = default_error_handler;
72
73 odp_ticketlock_unlock(&em_shm->error_handler.lock);
74
75 return EM_OK;
76}
77
78void
79em_error(em_status_t error, em_escope_t escope, ...)
80{
81 va_list args_list;
82
83 va_start(args_list, escope);
84
85 select_error_handler(error, escope, args_list);
86
87 va_end(args_list);
88}
#define RETURN_ERROR_IF(cond, error, escope, fmt,...)
Definition em_error.h:65
em_shm_t * em_shm
#define EM_OK
uint32_t em_escope_t
em_status_t(* em_error_handler_t)(em_eo_t eo, em_status_t error, em_escope_t escope, va_list args)
void em_error(em_status_t error, em_escope_t escope,...)
em_status_t em_unregister_error_handler(void)
uint32_t em_status_t
em_status_t em_register_error_handler(em_error_handler_t handler)
@ EM_ERR_NOT_INITIALIZED