summaryrefslogtreecommitdiff
path: root/tests/suite/ecore/src/lib/eina_safety_checks.c
blob: 78f82c76ac556e9dfc5ee779e7c66feb226cfa8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/* EINA - EFL data type library
 * Copyright (C) 2008 Gustavo Sverzut Barbieri
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library;
 * if not, see <http://www.gnu.org/licenses/>.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "eina_private.h"
#include "eina_error.h"
#include "eina_log.h"
#include "eina_safety_checks.h"

/*============================================================================*
*                                  Local                                     *
*============================================================================*/

/*============================================================================*
*                                 Global                                     *
*============================================================================*/

/**
 * @internal
 * @brief Shut down the safety checks module.
 *
 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
 *
 * This function shuts down the error module set up by
 * eina_safety_checks_init(). It is called by eina_shutdown().
 *
 * @see eina_shutdown()
 */
Eina_Bool eina_safety_checks_shutdown(void)
{
	return EINA_TRUE;
}

/*============================================================================*
*                                   API                                      *
*============================================================================*/

/**
 * @addtogroup Eina_Safety_Checks_Group Safety Checks
 *
 * Safety checks are a set of macros to check for parameters or values
 * that should never happen, it is similar in concept to assert(), but
 * will log and return instead of abort() your program.
 *
 * Since these cases should never happen, one may wantto keep safety
 * checks enabled during tests but disable then during deploy, not
 * doing any checks at all. This is a common requirement for embedded
 * systems. Whenever to check or not should be set during compile time
 * by using @c --disable-safety-checks or @c --enable-safety-checks
 * options to @c configure script.
 *
 * Whenever these macros capture an error, EINA_LOG_ERR() will be
 * called and @c eina_error set to @c EINA_ERROR_SAFETY_FAILED and can
 * be checked with eina_error_get() after call.
 *
 * @see EINA_SAFETY_ON_NULL_RETURN(), EINA_SAFETY_ON_NULL_RETURN_VAL()
 *      and other macros.
 *
 * @{
 */

/**
 * @cond LOCAL
 */

EAPI Eina_Error EINA_ERROR_SAFETY_FAILED = 0;

static const char EINA_ERROR_SAFETY_FAILED_STR[] = "Safety check failed.";

/**
 * @endcond
 */

/**
 * @internal
 * @brief Initialize the safety checks module.
 *
 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
 *
 * This function sets up the safety checks module of Eina. It is
 * called by eina_init().
 *
 * @see eina_init()
 */
Eina_Bool eina_safety_checks_init(void)
{
	EINA_ERROR_SAFETY_FAILED =
	    eina_error_msg_static_register(EINA_ERROR_SAFETY_FAILED_STR);
	return EINA_TRUE;
}

/**
 * @}
 */