QP/C  8.0.3
Real-Time Event Framework
Loading...
Searching...
No Matches
qsafe.h
Go to the documentation of this file.
1//============================================================================
2// SafeQP/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: LicenseRef-QL-commercial
11//
12// This software is licensed under the terms of the Quantum Leaps commercial
13// licenses. Please contact Quantum Leaps for more information about the
14// available licensing options.
15//
16// RESTRICTIONS
17// You may NOT :
18// (a) redistribute, encumber, sell, rent, lease, sublicense, or otherwise
19// transfer rights in this software,
20// (b) remove or alter any trademark, logo, copyright or other proprietary
21// notices, legends, symbols or labels present in this software,
22// (c) plagiarize this software to sidestep the licensing obligations.
23//
24// Quantum Leaps contact information:
25// <www.state-machine.com/licensing>
26// <info@state-machine.com>
27//============================================================================
28#ifndef QSAFE_H_
29#define QSAFE_H_
30
31// QF-FuSa enabled ===========================================================
32#ifndef Q_UNSAFE
33
34#ifndef QF_CRIT_STAT
35 #define QF_CRIT_STAT
36#endif
37
38#ifndef QF_CRIT_ENTRY
39 #define QF_CRIT_ENTRY() ((void)0)
40#endif
41
42#ifndef QF_CRIT_EXIT
43 #define QF_CRIT_EXIT() ((void)0)
44#endif
45
46#define Q_DEFINE_THIS_MODULE(name_) \
47 static char const Q_this_module_[] = name_;
48
49#define Q_ASSERT_INCRIT(id_, expr_) \
50 ((expr_) ? ((void)0) : Q_onError(&Q_this_module_[0], (id_)))
51
52#define Q_ERROR_INCRIT(id_) \
53 (Q_onError(&Q_this_module_[0], (id_)))
54
55#define Q_ASSERT_ID(id_, expr_) do { \
56 QF_CRIT_STAT \
57 QF_CRIT_ENTRY(); \
58 (expr_) ? ((void)0) : Q_onError(&Q_this_module_[0], (id_)); \
59 QF_CRIT_EXIT(); \
60} while (false)
61
62#define Q_ERROR_ID(id_) do { \
63 QF_CRIT_STAT \
64 QF_CRIT_ENTRY(); \
65 Q_onError(&Q_this_module_[0], (id_)); \
66 QF_CRIT_EXIT(); \
67} while (false)
68
69// QF-FuSa disabled ==========================================================
70#else
71
72#define Q_DEFINE_THIS_MODULE(name_)
73#define Q_ASSERT_INCRIT(id_, expr_) ((void)0)
74#define Q_ERROR_INCRIT(id_) ((void)0)
75#define Q_ASSERT_ID(id_, expr_) ((void)0)
76#define Q_ERROR_ID(id_) ((void)0)
77
78#endif // QF-FuSa disabled
79
80//============================================================================
81#define Q_DEFINE_THIS_FILE Q_DEFINE_THIS_MODULE(__FILE__)
82#define Q_ASSERT(expr_) Q_ASSERT_ID(__LINE__, (expr_))
83#define Q_ERROR() Q_ERROR_ID(__LINE__)
84#define Q_REQUIRE_ID(id_, expr_) Q_ASSERT_ID((id_), (expr_))
85#define Q_REQUIRE(expr_) Q_ASSERT(expr_)
86#define Q_REQUIRE_INCRIT(id_, expr_) Q_ASSERT_INCRIT((id_), (expr_))
87#define Q_ENSURE_ID(id_, expr_) Q_ASSERT_ID((id_), (expr_))
88#define Q_ENSURE(expr_) Q_ASSERT(expr_)
89#define Q_ENSURE_INCRIT(id_, expr_) Q_ASSERT_INCRIT((id_), (expr_))
90#define Q_INVARIANT_ID(id_, expr_) Q_ASSERT_ID((id_), (expr_))
91#define Q_INVARIANT(expr_) Q_ASSERT(expr_)
92#define Q_INVARIANT_INCRIT(id_, expr_) Q_ASSERT_INCRIT((id_), (expr_))
93
94#ifndef Q_ASSERT_STATIC
95 #define Q_ASSERT_STATIC(expr_) extern char Q_static_assert_[(expr_) ? 1 : -1]
96#endif // ndef Q_ASSERT_STATIC
97
98#ifndef Q_NORETURN
99 #define Q_NORETURN _Noreturn void
100#endif // ndef Q_NORETURN
101
102// Is this header file used outside QP?
103#ifndef QP_VERSION
104 #define Q_DIM(array_) (sizeof(array_) / sizeof((array_)[0U]))
105#endif // ndef QP_VERSION
106
107//============================================================================
108#ifdef __cplusplus
109extern "C" {
110#endif
111
112#ifndef QP_VERSION
113 typedef int int_t;
114#endif // ndef QP_VERSION
115
117 char const * const module,
118 int_t const id);
119
120#ifdef __cplusplus
121}
122#endif
123
124#endif // QSAFE_H_
int int_t
Alias for assertion-ID numbers in QP assertions and return from QF_run()
Definition qp.h:91
#define Q_NORETURN
Definition qsafe.h:99
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...