|
1 | 1 | //============================================================================ |
2 | | -// SafeQP/C Real-Time Event Framework (RTEF) |
| 2 | +// QP/C/C++ Real-Time Event Framework (RTEF) |
3 | 3 | // |
4 | 4 | // Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. |
5 | 5 | // |
6 | 6 | // Q u a n t u m L e a P s |
7 | 7 | // ------------------------ |
8 | 8 | // Modern Embedded Software |
9 | 9 | // |
10 | | -// SPDX-License-Identifier: LicenseRef-QL-commercial |
| 10 | +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial |
11 | 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. |
| 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 | 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. |
| 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. |
23 | 24 | // |
24 | 25 | // Quantum Leaps contact information: |
25 | 26 | // <www.state-machine.com/licensing> |
|
43 | 44 | #define QF_CRIT_EXIT() ((void)0) |
44 | 45 | #endif |
45 | 46 |
|
| 47 | +#ifndef QF_CRIT_EST |
| 48 | + #define QF_CRIT_EST() ((void)0) |
| 49 | +#endif |
| 50 | + |
46 | 51 | #define Q_DEFINE_THIS_MODULE(name_) \ |
47 | 52 | static char const Q_this_module_[] = name_; |
48 | 53 |
|
|
60 | 65 | } while (false) |
61 | 66 |
|
62 | 67 | #define Q_ERROR_ID(id_) do { \ |
63 | | - QF_CRIT_STAT \ |
64 | | - QF_CRIT_ENTRY(); \ |
| 68 | + QF_CRIT_EST(); \ |
65 | 69 | Q_onError(&Q_this_module_[0], (id_)); \ |
66 | | - QF_CRIT_EXIT(); \ |
| 70 | +} while (false) |
| 71 | + |
| 72 | +#define Q_ASSERT_LOCAL(id_, expr_) do { \ |
| 73 | + if (expr_) {} else { \ |
| 74 | + QF_CRIT_EST(); \ |
| 75 | + Q_onError(&Q_this_module_[0], (id_)); \ |
| 76 | + } \ |
67 | 77 | } while (false) |
68 | 78 |
|
69 | 79 | // QF-FuSa disabled ========================================================== |
70 | 80 | #else |
71 | 81 |
|
72 | 82 | #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) |
| 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) |
77 | 88 |
|
78 | 89 | #endif // QF-FuSa disabled |
79 | 90 |
|
80 | 91 | //============================================================================ |
81 | 92 | #define Q_DEFINE_THIS_FILE Q_DEFINE_THIS_MODULE(__FILE__) |
82 | 93 | #define Q_ASSERT(expr_) Q_ASSERT_ID(__LINE__, (expr_)) |
83 | 94 | #define Q_ERROR() Q_ERROR_ID(__LINE__) |
84 | | -#define Q_REQUIRE_ID(id_, expr_) Q_ASSERT_ID((id_), (expr_)) |
| 95 | + |
85 | 96 | #define Q_REQUIRE(expr_) Q_ASSERT(expr_) |
| 97 | +#define Q_REQUIRE_ID(id_, expr_) Q_ASSERT_ID((id_), (expr_)) |
86 | 98 | #define Q_REQUIRE_INCRIT(id_, expr_) Q_ASSERT_INCRIT((id_), (expr_)) |
87 | | -#define Q_ENSURE_ID(id_, expr_) Q_ASSERT_ID((id_), (expr_)) |
| 99 | +#define Q_REQUIRE_LOCAL(id_, expr_) Q_ASSERT_LOCAL((id_), (expr_)) |
| 100 | + |
88 | 101 | #define Q_ENSURE(expr_) Q_ASSERT(expr_) |
| 102 | +#define Q_ENSURE_ID(id_, expr_) Q_ASSERT_ID((id_), (expr_)) |
89 | 103 | #define Q_ENSURE_INCRIT(id_, expr_) Q_ASSERT_INCRIT((id_), (expr_)) |
90 | | -#define Q_INVARIANT_ID(id_, expr_) Q_ASSERT_ID((id_), (expr_)) |
| 104 | +#define Q_ENSURE_LOCAL(id_, expr_) Q_ASSERT_LOCAL((id_), (expr_)) |
| 105 | + |
91 | 106 | #define Q_INVARIANT(expr_) Q_ASSERT(expr_) |
| 107 | +#define Q_INVARIANT_ID(id_, expr_) Q_ASSERT_ID((id_), (expr_)) |
92 | 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_) |
93 | 112 |
|
94 | 113 | #ifndef Q_ASSERT_STATIC |
95 | 114 | #define Q_ASSERT_STATIC(expr_) extern char Q_static_assert_[(expr_) ? 1 : -1] |
|
0 commit comments