]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo_bsp/ps7_cortexa9_0/include/xil_assert.h
47347ad2b9c4bcd2c86d6e6599d639c6c3fc7558
[freertos] / FreeRTOS / Demo / CORTEX_A9_Zynq_ZC702 / RTOSDemo_bsp / ps7_cortexa9_0 / include / xil_assert.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2009 - 2014 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 * This file contains assert related functions.
38 *
39 * <pre>
40 * MODIFICATION HISTORY:
41 *
42 * Ver   Who    Date   Changes
43 * ----- ---- -------- -------------------------------------------------------
44 * 1.00a hbm  07/14/09 First release
45 * </pre>
46 *
47 ******************************************************************************/
48
49 #ifndef XIL_ASSERT_H    /* prevent circular inclusions */
50 #define XIL_ASSERT_H    /* by using protection macros */
51
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55
56
57 /***************************** Include Files *********************************/
58
59
60 /************************** Constant Definitions *****************************/
61
62 #define XIL_ASSERT_NONE     0
63 #define XIL_ASSERT_OCCURRED 1
64 #define XNULL NULL
65
66 extern unsigned int Xil_AssertStatus;
67 extern void Xil_Assert(const char *, int);
68 void XNullHandler(void *NullParameter);
69
70 /**
71  * This data type defines a callback to be invoked when an
72  * assert occurs. The callback is invoked only when asserts are enabled
73  */
74 typedef void (*Xil_AssertCallback) (const char *File, int Line);
75
76 /***************** Macros (Inline Functions) Definitions *********************/
77
78 #ifndef NDEBUG
79
80 /*****************************************************************************/
81 /**
82 * This assert macro is to be used for functions that do not return anything
83 * (void). This in conjunction with the Xil_AssertWait boolean can be used to
84 * accomodate tests so that asserts which fail allow execution to continue.
85 *
86 * @param    expression is the expression to evaluate. If it evaluates to
87 *           false, the assert occurs.
88 *
89 * @return   Returns void unless the Xil_AssertWait variable is true, in which
90 *           case no return is made and an infinite loop is entered.
91 *
92 * @note     None.
93 *
94 ******************************************************************************/
95 #define Xil_AssertVoid(Expression)                \
96 {                                                  \
97     if (Expression) {                              \
98         Xil_AssertStatus = XIL_ASSERT_NONE;       \
99     } else {                                       \
100         Xil_Assert(__FILE__, __LINE__);            \
101         Xil_AssertStatus = XIL_ASSERT_OCCURRED;   \
102         return;                                    \
103     }                                              \
104 }
105
106 /*****************************************************************************/
107 /**
108 * This assert macro is to be used for functions that do return a value. This in
109 * conjunction with the Xil_AssertWait boolean can be used to accomodate tests
110 * so that asserts which fail allow execution to continue.
111 *
112 * @param    expression is the expression to evaluate. If it evaluates to false,
113 *           the assert occurs.
114 *
115 * @return   Returns 0 unless the Xil_AssertWait variable is true, in which
116 *           case no return is made and an infinite loop is entered.
117 *
118 * @note     None.
119 *
120 ******************************************************************************/
121 #define Xil_AssertNonvoid(Expression)             \
122 {                                                  \
123     if (Expression) {                              \
124         Xil_AssertStatus = XIL_ASSERT_NONE;       \
125     } else {                                       \
126         Xil_Assert(__FILE__, __LINE__);            \
127         Xil_AssertStatus = XIL_ASSERT_OCCURRED;   \
128         return 0;                                  \
129     }                                              \
130 }
131
132 /*****************************************************************************/
133 /**
134 * Always assert. This assert macro is to be used for functions that do not
135 * return anything (void). Use for instances where an assert should always
136 * occur.
137 *
138 * @return Returns void unless the Xil_AssertWait variable is true, in which
139 *         case no return is made and an infinite loop is entered.
140 *
141 * @note   None.
142 *
143 ******************************************************************************/
144 #define Xil_AssertVoidAlways()                   \
145 {                                                  \
146    Xil_Assert(__FILE__, __LINE__);                 \
147    Xil_AssertStatus = XIL_ASSERT_OCCURRED;        \
148    return;                                         \
149 }
150
151 /*****************************************************************************/
152 /**
153 * Always assert. This assert macro is to be used for functions that do return
154 * a value. Use for instances where an assert should always occur.
155 *
156 * @return Returns void unless the Xil_AssertWait variable is true, in which
157 *         case no return is made and an infinite loop is entered.
158 *
159 * @note   None.
160 *
161 ******************************************************************************/
162 #define Xil_AssertNonvoidAlways()                \
163 {                                                  \
164    Xil_Assert(__FILE__, __LINE__);                 \
165    Xil_AssertStatus = XIL_ASSERT_OCCURRED;        \
166    return 0;                                       \
167 }
168
169
170 #else
171
172 #define Xil_AssertVoid(Expression)
173 #define Xil_AssertVoidAlways()
174 #define Xil_AssertNonvoid(Expression)
175 #define Xil_AssertNonvoidAlways()
176
177 #endif
178
179 /************************** Function Prototypes ******************************/
180
181 void Xil_AssertSetCallback(Xil_AssertCallback Routine);
182
183 #ifdef __cplusplus
184 }
185 #endif
186
187 #endif  /* end of protection macro */