RTEMS 6.1-rc1
xil_assert.h
Go to the documentation of this file.
1/******************************************************************************
2* Copyright (c) 2009 - 2021 Xilinx, Inc. All rights reserved.
3* SPDX-License-Identifier: MIT
4******************************************************************************/
5
6/*****************************************************************************/
35#ifndef XIL_ASSERT_H /* prevent circular inclusions */
36#define XIL_ASSERT_H /* by using protection macros */
37
38#include "xil_types.h"
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44
45/***************************** Include Files *********************************/
46
47
48/************************** Constant Definitions *****************************/
49
50#define XIL_ASSERT_NONE 0U
51#define XIL_ASSERT_OCCURRED 1U
52#define XNULL NULL
53
54extern u32 Xil_AssertStatus;
55extern s32 Xil_AssertWait;
56extern void Xil_Assert(const char8 *File, s32 Line);
60void XNullHandler(void *NullParameter);
61
66typedef void (*Xil_AssertCallback) (const char8 *File, s32 Line);
67
68/***************** Macros (Inline Functions) Definitions *********************/
69
70#ifndef NDEBUG
71
72/*****************************************************************************/
86#define Xil_AssertVoid(Expression) \
87{ \
88 if (Expression) { \
89 Xil_AssertStatus = XIL_ASSERT_NONE; \
90 } else { \
91 Xil_Assert(__FILE__, __LINE__); \
92 Xil_AssertStatus = XIL_ASSERT_OCCURRED; \
93 return; \
94 } \
95}
96
97/*****************************************************************************/
111#define Xil_AssertNonvoid(Expression) \
112{ \
113 if (Expression) { \
114 Xil_AssertStatus = XIL_ASSERT_NONE; \
115 } else { \
116 Xil_Assert(__FILE__, __LINE__); \
117 Xil_AssertStatus = XIL_ASSERT_OCCURRED; \
118 return 0; \
119 } \
120}
121
122/*****************************************************************************/
131#define Xil_AssertVoidAlways() \
132{ \
133 Xil_Assert(__FILE__, __LINE__); \
134 Xil_AssertStatus = XIL_ASSERT_OCCURRED; \
135 return; \
136}
137
138/*****************************************************************************/
148#define Xil_AssertNonvoidAlways() \
149{ \
150 Xil_Assert(__FILE__, __LINE__); \
151 Xil_AssertStatus = XIL_ASSERT_OCCURRED; \
152 return 0; \
153}
154
155
156#else
157
158#define Xil_AssertVoid(Expression)
159#define Xil_AssertVoidAlways()
160#define Xil_AssertNonvoid(Expression)
161#define Xil_AssertNonvoidAlways()
162
163#endif
164
165/************************** Function Prototypes ******************************/
166
168
169#ifdef __cplusplus
170}
171#endif
172
173#endif /* end of protection macro */
void(* Xil_AssertCallback)(const char8 *File, s32 Line)
Definition: xil_assert.h:66
void XNullHandler(void *NullParameter)
Null handler function. This follows the XInterruptHandler signature for interrupt handlers....
Definition: xil_assert.c:120
void Xil_Assert(const char8 *File, s32 Line)
Implement assert. Currently, it calls a user-defined callback function if one has been set....
Definition: xil_assert.c:74
s32 Xil_AssertWait
This variable allows the assert functionality to be changed for testing such that it does not wait in...
Definition: xil_assert.c:51
u32 Xil_AssertStatus
This variable allows testing to be done easier with asserts. An assert sets this variable such that a...
Definition: xil_assert.c:44
void Xil_AssertSetCallback(Xil_AssertCallback Routine)
Set up a callback function to be invoked when an assert occurs. If a callback is already installed,...
Definition: xil_assert.c:101