QP/C  8.0.2
Real-Time Embedded Framework
Loading...
Searching...
No Matches
qsafe.h
Go to the documentation of this file.
1//============================================================================
2// SafeQP/C Real-Time Embedded Framework (RTEF)
3// Version 8.0.2
4//
5// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
6//
7// Q u a n t u m L e a P s
8// ------------------------
9// Modern Embedded Software
10//
11// SPDX-License-Identifier: LicenseRef-QL-commercial
12//
13// This software is licensed under the terms of the Quantum Leaps commercial
14// licenses. Please contact Quantum Leaps for more information about the
15// available licensing options.
16//
17// RESTRICTIONS
18// You may NOT :
19// (a) redistribute, encumber, sell, rent, lease, sublicense, or otherwise
20// transfer rights in this software,
21// (b) remove or alter any trademark, logo, copyright or other proprietary
22// notices, legends, symbols or labels present in this software,
23// (c) plagiarize this software to sidestep the licensing obligations.
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#define Q_DEFINE_THIS_MODULE(name_) \
48 static char const Q_this_module_[] = name_;
49
50#define Q_ASSERT_INCRIT(id_, expr_) \
51 ((expr_) ? ((void)0) : Q_onError(&Q_this_module_[0], (id_)))
52
53#define Q_ERROR_INCRIT(id_) \
54 (Q_onError(&Q_this_module_[0], (id_)))
55
56#define Q_ASSERT_ID(id_, expr_) do { \
57 QF_CRIT_STAT \
58 QF_CRIT_ENTRY(); \
59 (expr_) ? ((void)0) : Q_onError(&Q_this_module_[0], (id_)); \
60 QF_CRIT_EXIT(); \
61} while (false)
62
63#define Q_ERROR_ID(id_) do { \
64 QF_CRIT_STAT \
65 QF_CRIT_ENTRY(); \
66 Q_onError(&Q_this_module_[0], (id_)); \
67 QF_CRIT_EXIT(); \
68} while (false)
69
70// QF-FuSa disabled ==========================================================
71#else
72
73#define Q_DEFINE_THIS_MODULE(name_)
74#define Q_ASSERT_INCRIT(id_, expr_) ((void)0)
75#define Q_ERROR_INCRIT(id_) ((void)0)
76#define Q_ASSERT_ID(id_, expr_) ((void)0)
77#define Q_ERROR_ID(id_) ((void)0)
78
79#endif // QF-FuSa disabled
80
81//============================================================================
82#define Q_DEFINE_THIS_FILE Q_DEFINE_THIS_MODULE(__FILE__)
83#define Q_ASSERT(expr_) Q_ASSERT_ID(__LINE__, (expr_))
84#define Q_ERROR() Q_ERROR_ID(__LINE__)
85#define Q_REQUIRE_ID(id_, expr_) Q_ASSERT_ID((id_), (expr_))
86#define Q_REQUIRE(expr_) Q_ASSERT(expr_)
87#define Q_REQUIRE_INCRIT(id_, expr_) Q_ASSERT_INCRIT((id_), (expr_))
88#define Q_ENSURE_ID(id_, expr_) Q_ASSERT_ID((id_), (expr_))
89#define Q_ENSURE(expr_) Q_ASSERT(expr_)
90#define Q_ENSURE_INCRIT(id_, expr_) Q_ASSERT_INCRIT((id_), (expr_))
91#define Q_INVARIANT_ID(id_, expr_) Q_ASSERT_ID((id_), (expr_))
92#define Q_INVARIANT(expr_) Q_ASSERT(expr_)
93#define Q_INVARIANT_INCRIT(id_, expr_) Q_ASSERT_INCRIT((id_), (expr_))
94
95#ifndef Q_ASSERT_STATIC
96 #define Q_ASSERT_STATIC(expr_) extern char Q_static_assert_[(expr_) ? 1 : -1]
97#endif // ndef Q_ASSERT_STATIC
98
99#ifndef Q_NORETURN
100 #define Q_NORETURN _Noreturn void
101#endif // ndef Q_NORETURN
102
103// Is this header file used outside QP?
104#ifndef QP_VERSION
105 #define Q_DIM(array_) (sizeof(array_) / sizeof((array_)[0U]))
106#endif // ndef QP_VERSION
107
108//============================================================================
109#ifdef __cplusplus
110extern "C" {
111#endif
112
113#ifndef QP_VERSION
114 typedef int int_t;
115#endif // ndef QP_VERSION
116
118 char const * const module,
119 int_t const id);
120
121#ifdef __cplusplus
122}
123#endif
124
125#endif // QSAFE_H_
int int_t
Alias for assertion-ID numbers in QP assertions and return from QF_run()
Definition qp.h:92
#define Q_NORETURN
No-return specifier for the Q_onError() callback function.
Definition qp_port.h:23
Q_NORETURN Q_onError(char const *const module, int_t const id)