| 1 | /* |
| 2 | Copyright (c) 2005-2021 Intel Corporation |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef __TBB_detail__assert_H |
| 18 | #define __TBB_detail__assert_H |
| 19 | |
| 20 | #include "_config.h" |
| 21 | |
| 22 | #if __TBBMALLOC_BUILD |
| 23 | namespace rml { namespace internal { |
| 24 | #else |
| 25 | namespace tbb { |
| 26 | namespace detail { |
| 27 | namespace r1 { |
| 28 | #endif |
| 29 | //! Process an assertion failure. |
| 30 | /** Normally called from __TBB_ASSERT macro. |
| 31 | If assertion handler is null, print message for assertion failure and abort. |
| 32 | Otherwise call the assertion handler. */ |
| 33 | TBB_EXPORT void __TBB_EXPORTED_FUNC assertion_failure(const char* location, int line, const char* expression, const char* ); |
| 34 | #if __TBBMALLOC_BUILD |
| 35 | }} // namespaces rml::internal |
| 36 | #else |
| 37 | } // namespace r1 |
| 38 | } // namespace detail |
| 39 | } // namespace tbb |
| 40 | #endif |
| 41 | |
| 42 | #if __TBBMALLOC_BUILD |
| 43 | //! Release version of assertions |
| 44 | #define __TBB_ASSERT_RELEASE(predicate,message) ((predicate)?((void)0) : rml::internal::assertion_failure(__func__,__LINE__,#predicate,message)) |
| 45 | #else |
| 46 | #define __TBB_ASSERT_RELEASE(predicate,message) ((predicate)?((void)0) : tbb::detail::r1::assertion_failure(__func__,__LINE__,#predicate,message)) |
| 47 | #endif |
| 48 | |
| 49 | #if TBB_USE_ASSERT |
| 50 | //! Assert that predicate is true. |
| 51 | /** If predicate is false, print assertion failure message. |
| 52 | If the comment argument is not NULL, it is printed as part of the failure message. |
| 53 | The comment argument has no other effect. */ |
| 54 | #define __TBB_ASSERT(predicate,message) __TBB_ASSERT_RELEASE(predicate,message) |
| 55 | //! "Extended" version |
| 56 | #define __TBB_ASSERT_EX __TBB_ASSERT |
| 57 | #else |
| 58 | //! No-op version of __TBB_ASSERT. |
| 59 | #define __TBB_ASSERT(predicate,comment) ((void)0) |
| 60 | //! "Extended" version is useful to suppress warnings if a variable is only used with an assert |
| 61 | #define __TBB_ASSERT_EX(predicate,comment) ((void)(1 && (predicate))) |
| 62 | #endif // TBB_USE_ASSERT |
| 63 | |
| 64 | #endif // __TBB_detail__assert_H |
| 65 | |