]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo_bsp/ps7_cortexa9_0/libsrc/standalone_v6_6/src/xil_assert.h
Update Zynq, MPSoc Cortex-A53 and MPSoc Cortex-R5 demo projects to build with the...
[freertos] / FreeRTOS / Demo / CORTEX_A9_Zynq_ZC702 / RTOSDemo_bsp / ps7_cortexa9_0 / libsrc / standalone_v6_6 / src / xil_assert.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2009 - 2016 Xilinx, Inc. All rights reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 *
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
30 *
31 ******************************************************************************/
32 /*****************************************************************************/
33 /**
34 *
35 * @file xil_assert.h
36 *
37 * @addtogroup common_assert_apis Assert APIs and Macros
38 *
39 * The xil_assert.h file contains assert related functions and macros.
40 * Assert APIs/Macros specifies that a application program satisfies certain
41 * conditions at particular points in its execution. These function can be
42 * used by application programs to ensure that, application code is satisfying
43 * certain conditions.
44 *
45 * @{
46 * <pre>
47 * MODIFICATION HISTORY:
48 *
49 * Ver   Who    Date   Changes
50 * ----- ---- -------- -------------------------------------------------------
51 * 1.00a hbm  07/14/09 First release
52 * 6.0   kvn  05/31/16 Make Xil_AsserWait a global variable
53 * </pre>
54 *
55 ******************************************************************************/
56
57 #ifndef XIL_ASSERT_H    /* prevent circular inclusions */
58 #define XIL_ASSERT_H    /* by using protection macros */
59
60 #include "xil_types.h"
61
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65
66
67 /***************************** Include Files *********************************/
68
69
70 /************************** Constant Definitions *****************************/
71
72 #define XIL_ASSERT_NONE     0U
73 #define XIL_ASSERT_OCCURRED 1U
74 #define XNULL NULL
75
76 extern u32 Xil_AssertStatus;
77 extern s32 Xil_AssertWait;
78 extern void Xil_Assert(const char8 *File, s32 Line);
79 void XNullHandler(void *NullParameter);
80
81 /**
82  * This data type defines a callback to be invoked when an
83  * assert occurs. The callback is invoked only when asserts are enabled
84  */
85 typedef void (*Xil_AssertCallback) (const char8 *File, s32 Line);
86
87 /***************** Macros (Inline Functions) Definitions *********************/
88
89 #ifndef NDEBUG
90
91 /*****************************************************************************/
92 /**
93 * @brief    This assert macro is to be used for void functions. This in
94 *           conjunction with the Xil_AssertWait boolean can be used to
95 *           accomodate tests so that asserts which fail allow execution to
96 *           continue.
97 *
98 * @param    Expression: expression to be evaluated. If it evaluates to
99 *           false, the assert occurs.
100 *
101 * @return   Returns void unless the Xil_AssertWait variable is true, in which
102 *           case no return is made and an infinite loop is entered.
103 *
104 ******************************************************************************/
105 #define Xil_AssertVoid(Expression)                \
106 {                                                  \
107     if (Expression) {                              \
108         Xil_AssertStatus = XIL_ASSERT_NONE;       \
109     } else {                                       \
110         Xil_Assert(__FILE__, __LINE__);            \
111         Xil_AssertStatus = XIL_ASSERT_OCCURRED;   \
112         return;                                    \
113     }                                              \
114 }
115
116 /*****************************************************************************/
117 /**
118 * @brief    This assert macro is to be used for functions that do return a
119 *           value. This in conjunction with the Xil_AssertWait boolean can be
120 *           used to accomodate tests so that asserts which fail allow execution
121 *           to continue.
122 *
123 * @param    Expression: expression to be evaluated. If it evaluates to false,
124 *           the assert occurs.
125 *
126 * @return   Returns 0 unless the Xil_AssertWait variable is true, in which
127 *               case no return is made and an infinite loop is entered.
128 *
129 ******************************************************************************/
130 #define Xil_AssertNonvoid(Expression)             \
131 {                                                  \
132     if (Expression) {                              \
133         Xil_AssertStatus = XIL_ASSERT_NONE;       \
134     } else {                                       \
135         Xil_Assert(__FILE__, __LINE__);            \
136         Xil_AssertStatus = XIL_ASSERT_OCCURRED;   \
137         return 0;                                  \
138     }                                              \
139 }
140
141 /*****************************************************************************/
142 /**
143 * @brief     Always assert. This assert macro is to be used for void functions.
144 *            Use for instances where an assert should always occur.
145 *
146 * @return    Returns void unless the Xil_AssertWait variable is true, in which
147 *                case no return is made and an infinite loop is entered.
148 *
149 ******************************************************************************/
150 #define Xil_AssertVoidAlways()                   \
151 {                                                  \
152    Xil_Assert(__FILE__, __LINE__);                 \
153    Xil_AssertStatus = XIL_ASSERT_OCCURRED;        \
154    return;                                         \
155 }
156
157 /*****************************************************************************/
158 /**
159 * @brief   Always assert. This assert macro is to be used for functions that
160 *          do return a value. Use for instances where an assert should always
161 *          occur.
162 *
163 * @return Returns void unless the Xil_AssertWait variable is true, in which
164 *             case no return is made and an infinite loop is entered.
165 *
166 ******************************************************************************/
167 #define Xil_AssertNonvoidAlways()                \
168 {                                                  \
169    Xil_Assert(__FILE__, __LINE__);                 \
170    Xil_AssertStatus = XIL_ASSERT_OCCURRED;        \
171    return 0;                                       \
172 }
173
174
175 #else
176
177 #define Xil_AssertVoid(Expression)
178 #define Xil_AssertVoidAlways()
179 #define Xil_AssertNonvoid(Expression)
180 #define Xil_AssertNonvoidAlways()
181
182 #endif
183
184 /************************** Function Prototypes ******************************/
185
186 void Xil_AssertSetCallback(Xil_AssertCallback Routine);
187
188 #ifdef __cplusplus
189 }
190 #endif
191
192 #endif  /* end of protection macro */
193 /**
194 * @} End of "addtogroup common_assert_apis".
195 */