QP/C++
8.1.2
Real-Time Event Framework
Loading...
Searching...
No Matches
qsafe.h
Go to the documentation of this file.
1
//============================================================================
2
// QP/C/C++ Real-Time Event Framework (RTEF)
3
//
4
// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
5
//
6
// Q u a n t u m L e a P s
7
// ------------------------
8
// Modern Embedded Software
9
//
10
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
11
//
12
// This software is dual-licensed under the terms of the open-source GNU
13
// General Public License (GPL) or under the terms of one of the closed-
14
// source Quantum Leaps commercial licenses.
15
//
16
// Redistributions in source code must retain this top-level comment block.
17
// Plagiarizing this software to sidestep the license obligations is illegal.
18
//
19
// NOTE:
20
// The GPL does NOT permit the incorporation of this code into proprietary
21
// programs. Please contact Quantum Leaps for commercial licensing options,
22
// which expressly supersede the GPL and are designed explicitly for
23
// closed-source distribution.
24
//
25
// Quantum Leaps contact information:
26
// <www.state-machine.com/licensing>
27
// <info@state-machine.com>
28
//============================================================================
29
#ifndef QSAFE_H_
30
#define QSAFE_H_
31
32
// QF-FuSa enabled ===========================================================
33
#ifndef Q_UNSAFE
34
35
#ifndef QF_CRIT_STAT
36
#define QF_CRIT_STAT
37
#endif
38
39
#ifndef QF_CRIT_ENTRY
40
#define QF_CRIT_ENTRY() ((void)0)
41
#endif
42
43
#ifndef QF_CRIT_EXIT
44
#define QF_CRIT_EXIT() ((void)0)
45
#endif
46
47
#ifndef QF_CRIT_EST
48
#define QF_CRIT_EST() ((void)0)
49
#endif
50
51
#define Q_DEFINE_THIS_MODULE(name_) \
52
static char const Q_this_module_[] = name_;
53
54
#define Q_ASSERT_INCRIT(id_, expr_) \
55
((expr_) ? (void)0 : Q_onError(&Q_this_module_[0], (id_)))
56
57
#define Q_ERROR_INCRIT(id_) \
58
(Q_onError(&Q_this_module_[0], (id_)))
59
60
#define Q_ASSERT_ID(id_, expr_) do { \
61
QF_CRIT_STAT \
62
QF_CRIT_ENTRY(); \
63
((expr_) ? (void)0 : Q_onError(&Q_this_module_[0], (id_))); \
64
QF_CRIT_EXIT(); \
65
} while (false)
66
67
#define Q_ERROR_ID(id_) do { \
68
QF_CRIT_EST(); \
69
Q_onError(&Q_this_module_[0], (id_)); \
70
} while (false)
71
72
#define Q_ASSERT_LOCAL(id_, expr_) do { \
73
if (!(expr_)) { \
74
QF_CRIT_EST(); \
75
Q_onError(&Q_this_module_[0], (id_)); \
76
} \
77
} while (false)
78
79
// QF-FuSa disabled ==========================================================
80
#else
81
82
#define Q_DEFINE_THIS_MODULE(name_)
83
#define Q_ASSERT_INCRIT(id_, expr_) ((void)0)
84
#define Q_ERROR_INCRIT(id_) ((void)0)
85
#define Q_ASSERT_ID(id_, expr_) ((void)0)
86
#define Q_ERROR_ID(id_) ((void)0)
87
#define Q_ASSERT_LOCAL(id_, expr_) ((void)0)
88
89
#endif
// QF-FuSa disabled
90
91
//============================================================================
92
#define Q_DEFINE_THIS_FILE Q_DEFINE_THIS_MODULE(__FILE__)
93
#define Q_ASSERT(expr_) Q_ASSERT_ID(__LINE__, (expr_))
94
#define Q_ERROR() Q_ERROR_ID(__LINE__)
95
96
#define Q_REQUIRE(expr_) Q_ASSERT(expr_)
97
#define Q_REQUIRE_ID(id_, expr_) Q_ASSERT_ID((id_), (expr_))
98
#define Q_REQUIRE_INCRIT(id_, expr_) Q_ASSERT_INCRIT((id_), (expr_))
99
#define Q_REQUIRE_LOCAL(id_, expr_) Q_ASSERT_LOCAL((id_), (expr_))
100
101
#define Q_ENSURE(expr_) Q_ASSERT(expr_)
102
#define Q_ENSURE_ID(id_, expr_) Q_ASSERT_ID((id_), (expr_))
103
#define Q_ENSURE_INCRIT(id_, expr_) Q_ASSERT_INCRIT((id_), (expr_))
104
#define Q_ENSURE_LOCAL(id_, expr_) Q_ASSERT_LOCAL((id_), (expr_))
105
106
#define Q_INVARIANT(expr_) Q_ASSERT(expr_)
107
#define Q_INVARIANT_ID(id_, expr_) Q_ASSERT_ID((id_), (expr_))
108
#define Q_INVARIANT_INCRIT(id_, expr_) Q_ASSERT_INCRIT((id_), (expr_))
109
#define Q_INVARIANT_LOCAL(id_, expr_) Q_ASSERT_LOCAL((id_), (expr_))
110
111
#define Q_ERROR_LOCAL(id_) Q_ERROR_ID(id_)
112
113
#ifndef Q_ASSERT_STATIC
114
#define Q_ASSERT_STATIC(expr_) \
115
void Q_assert_(char (*Q_static_assert_error)[(expr_) ? 1 : -1])
116
#endif
117
118
//============================================================================
119
//! @cond INTERNAL
120
#ifndef Q_NORETURN
121
#ifdef __cplusplus
122
#define Q_NORETURN [[ noreturn ]] void
123
#else
124
#define Q_NORETURN _Noreturn void
125
#endif
126
#endif
127
128
// Is this header file used outside QP?
129
#ifndef Q_DIM
130
#define Q_DIM(array_) (sizeof(array_) / sizeof((array_)[0U]))
131
#endif
132
//! @endcond
133
134
//============================================================================
135
#ifdef __cplusplus
136
extern
"C"
{
137
#endif
138
139
#ifndef QP_VERSION
140
typedef
int
int_t
;
141
#endif
142
143
Q_NORETURN
Q_onError
(
144
char
const
*
const
module,
145
int_t
const
id
);
146
147
#ifdef __cplusplus
148
}
149
#endif
150
151
#endif
// QSAFE_H_
int_t
int int_t
Alias for assertion-ID numbers in QP assertions and return from QP::QF::run().
Definition
qp.hpp:87
Q_NORETURN
#define Q_NORETURN
No-return specifier for the Q_onError() callback function.
Definition
qp_port.hpp:26
Q_onError
Q_NORETURN Q_onError(char const *const module, int_t const id)
Custom error handler Callback function invoked after detecting an error (part of QP Functional Safety...
qpcpp
include
qsafe.h
© 2005-
Quantum Leaps
|
Using Online Help
|
QP/C++ 8.1.2
| created with
Spexygen
© 2005-
Quantum Leaps
|
Using Online Help
|
QP/C++ 8.1.2
| created with
Spexygen