Imported more library files
Not compiling currently
This commit is contained in:
489
Libs/Matter/third_party/nlassert/include/nlassert-internal.h
vendored
Normal file
489
Libs/Matter/third_party/nlassert/include/nlassert-internal.h
vendored
Normal file
@@ -0,0 +1,489 @@
|
||||
/*
|
||||
* Copyright 2010-2016 Nest Labs Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Description:
|
||||
* This file defines macros internal to the implementation of the
|
||||
* Nest Labs assertion and exception checking facility.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NLASSERT_INTERNAL_H
|
||||
#define NLASSERT_INTERNAL_H
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
|
||||
# define __nlLIKELY(condition) __builtin_expect(condition, 1)
|
||||
# define __nlUNLIKELY(condition) __builtin_expect(condition, 0)
|
||||
#else
|
||||
# define __nlLIKELY(condition) (condition)
|
||||
# define __nlUNLIKELY(condition) (condition)
|
||||
#endif /* defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) */
|
||||
|
||||
// Notes on the unusual design of __nlSHOULD_ASSERT and __nl_ASSERT_UNUSED:
|
||||
//
|
||||
//
|
||||
// For non-production builds (aka "development" or "debug" builds)
|
||||
// ===============================================================
|
||||
//
|
||||
// The nlASSERT(condition) macro evaluates the "condition" expression and, if
|
||||
// it is false, calls NL_ASSERT_ABORT() to abort execution (after optionally
|
||||
// performing some logging and debugging operations). Partially expanded, for
|
||||
// clarity, it looks like this:
|
||||
//
|
||||
// if (__nlSHOULD_ASSERT(condition))
|
||||
// {
|
||||
// do
|
||||
// {
|
||||
// /* optional logging, backtrace, and/or trap handling */
|
||||
// } while (0);
|
||||
//
|
||||
// {
|
||||
// NL_ASSERT_ABORT();
|
||||
// }
|
||||
// }
|
||||
// else do { /* nothing */ } while (0)
|
||||
//
|
||||
// NOTE: The "if (foo) / else do { } while (0)" construct is just a more
|
||||
// robust version of the standard "do / while (0)" macro wrapper.
|
||||
// It is explained below, in the comments accompanying __nlCHECK.
|
||||
//
|
||||
// The __nlSHOULD_ASSERT(condition) macro must evaluate to true if "condition"
|
||||
// is false; conceptually, its definition is "!(condition)". But it is not
|
||||
// actually defined that way, for this reason:
|
||||
//
|
||||
// It is not uncommon for an equality test like "if (x == y)" to be accidentally
|
||||
// written as an assignment: "if (x = y)". GCC and similar compilers can detect
|
||||
// this and emit a warning, but the warning is suppressed if the assignment is
|
||||
// surrounded by an extra pair of parentheses to indicate that it is
|
||||
// intentional: "if ((x = y))". So if __nlSHOULD_ASSERT(condition) were defined
|
||||
// as "!(condition)", the parentheses around "condition" -- required by the "!"
|
||||
// operator -- would be seen by the compiler as an indication that the
|
||||
// assignment was intentional, so no warning would be emitted if, for example,
|
||||
// "nlASSERT(x == y)" were mistakenly written as "nlASSERT(x = y)".
|
||||
//
|
||||
// Therefore, __nlSHOULD_ASSERT(condition) is defined so that there will be no
|
||||
// extra parentheses around "condition" when the nlASSERT(condition) macro is
|
||||
// expanded. With this definition, nlASSERT(condition) expands to:
|
||||
//
|
||||
// if (condition)
|
||||
// {
|
||||
// /* do nothing */
|
||||
// }
|
||||
// else if (1)
|
||||
// {
|
||||
// do
|
||||
// {
|
||||
// /* optional logging, backtrace, and/or trap handling */
|
||||
// } while (0);
|
||||
//
|
||||
// {
|
||||
// NL_ASSERT_ABORT();
|
||||
// }
|
||||
// }
|
||||
// else do { /* nothing */ } while (0)
|
||||
//
|
||||
// GCC's branch-prediction hinting mechanism ("__builtin_expect(condition,1)")
|
||||
// would also suppress the "unintended assignment" warning, so is not used in
|
||||
// the macro definition. But the macro compiles to exactly the same assembly
|
||||
// code as it would if the hint were included, so omitting the hint incurs no
|
||||
// speed or memory cost. This is true for both ARM and x86 ISAs (tested under
|
||||
// GCC 4.x.x, with optimization for speed enabled via compiler flag -O3).
|
||||
//
|
||||
//
|
||||
// For production builds (aka "release" builds)
|
||||
// ============================================
|
||||
//
|
||||
// The nlASSERT(condition) macro is disabled by defining it as
|
||||
// __nlASSERT_UNUSED(condition).
|
||||
//
|
||||
// The __nlASSERT_UNUSED(condition) macro must not perform any logging or
|
||||
// debugging operations, and it must not abort program execution even when
|
||||
// "condition" is false. It cannot simply be defined as "(void)0", however,
|
||||
// because it must allow side effects in "condition", if any, to occur exactly
|
||||
// as they would in the non-production version of the macro. And it can't be
|
||||
// defined as (void)(condition) because it is desirable for an unintended
|
||||
// assignment in "condition" to be caught by the compiler, just as it would be
|
||||
// in a non-production build.
|
||||
//
|
||||
// Therefore, __nl_ASSERT_UNUSED(condition) is defined so that "condition" is
|
||||
// treated as a truth value, to ensure that unintended assignment will be
|
||||
// caught, and so that "condition" is evaluated at runtime if and only if it
|
||||
// would also be evaluated by the non-production version of nlASSERT(condition),
|
||||
// to ensure that side effects will occur identically.
|
||||
|
||||
#define __nlSHOULD_ASSERT(condition) condition) { /* do nothing */ } else if (1
|
||||
|
||||
#define __nlASSERT_UNUSED(condition) do { if (condition) { /* do nothing */ } } while (0)
|
||||
|
||||
/** @cond */
|
||||
#define __nlSTATIC_ASSERT_CONCAT(aPrefix, aSuffix) aPrefix ## aSuffix
|
||||
|
||||
#define _nlSTATIC_ASSERT_CONCAT(aPrefix, aSuffix) __nlSTATIC_ASSERT_CONCAT(aPrefix, aSuffix)
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @def _nlSTATIC_ASSERT(aCondition)
|
||||
*
|
||||
* @brief
|
||||
* This checks, at compile-time, for the specified condition, which
|
||||
* is expected to commonly be true and terminates compilation if the
|
||||
* condition is false. It is legal, in both C and C++, anywhere that
|
||||
* a declaration would be.
|
||||
*
|
||||
* @note This is a package-internal interface. If C++11/C11 or greater is
|
||||
* available, this falls back to using C++11/C11 intrinsic facilities:
|
||||
* static_assert or _Static_assert.
|
||||
*
|
||||
* @param[in] aCondition A Boolean expression to be evaluated.
|
||||
* @param[in] aMessage A pointer to a NULL-terminated C string
|
||||
* containing a caller-specified message
|
||||
* further describing the assertion
|
||||
* failure. Note, this message is not
|
||||
* actually emitted in any meaningful way for
|
||||
* non-C11 or -C++11 code. It serves to
|
||||
* simply comment or annotate the assertion
|
||||
* and to provide interface parallelism with
|
||||
* the run-time assertion interfaces.
|
||||
*
|
||||
*/
|
||||
#if defined(__cplusplus) && (__cplusplus >= 201103L)
|
||||
# define _nlSTATIC_ASSERT(aCondition, aMessage) static_assert(aCondition, aMessage)
|
||||
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
|
||||
# define _nlSTATIC_ASSERT(aCondition, aMessage) _Static_assert(aCondition, aMessage)
|
||||
#else
|
||||
# ifdef __COUNTER__
|
||||
# define _nlSTATIC_ASSERT(aCondition, aMessage) typedef char _nlSTATIC_ASSERT_CONCAT(STATIC_ASSERT_t_, __COUNTER__)[(aCondition) ? 1 : -1] __attribute__ ((unused))
|
||||
# else
|
||||
# define _nlSTATIC_ASSERT(aCondition, aMessage) typedef char _nlSTATIC_ASSERT_CONCAT(STATIC_ASSERT_t_, __LINE__)[(aCondition) ? 1 : -1] __attribute__ ((unused))
|
||||
# endif
|
||||
#endif /* defined(__cplusplus) && (__cplusplus >= 201103L) */
|
||||
|
||||
// __nlSTATIC_ASSERT_UNUSED(aCondition)
|
||||
//
|
||||
// Can be used everywhere that _nlSTATIC_ASSERT can, and behaves exactly the
|
||||
// same way except that it never asserts.
|
||||
#if defined(__cplusplus) && (__cplusplus >= 201103L)
|
||||
# define __nlSTATIC_ASSERT_UNUSED(aCondition, aMessage) static_assert((aCondition) || 1, aMessage)
|
||||
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
|
||||
# define __nlSTATIC_ASSERT_UNUSED(aCondition, aMessage) _Static_assert((aCondition) || 1, aMessage)
|
||||
#else
|
||||
# ifdef __COUNTER__
|
||||
# define __nlSTATIC_ASSERT_UNUSED(aCondition, aMessage) typedef char _nlSTATIC_ASSERT_CONCAT(STATIC_ASSERT_t_, __COUNTER__)[((aCondition) || 1) ? 1 : -1] __attribute__ ((unused))
|
||||
# else
|
||||
# define __nlSTATIC_ASSERT_UNUSED(aCondition, aMessage) typedef char _nlSTATIC_ASSERT_CONCAT(STATIC_ASSERT_t_, __LINE__)[((aCondition) || 1) ? 1 : -1] __attribute__ ((unused))
|
||||
# endif
|
||||
#endif /* defined(__cplusplus) && (__cplusplus >= 201103L) */
|
||||
|
||||
#define __NL_ASSERT_MAYBE_RUN_TRIGGERS(flags, prefix, name, condition, label, file, line, message) \
|
||||
do \
|
||||
{ \
|
||||
if ((flags) & NL_ASSERT_FLAG_LOG) { \
|
||||
NL_ASSERT_LOG(prefix, name, condition, label, file, line, message); \
|
||||
} \
|
||||
if ((flags) & NL_ASSERT_FLAG_BACKTRACE) { \
|
||||
NL_ASSERT_BACKTRACE(); \
|
||||
} \
|
||||
if ((flags) & NL_ASSERT_FLAG_TRAP) { \
|
||||
NL_ASSERT_TRAP(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define __NL_ASSERT_MAYBE_RUN_PRE_ACTION_TRIGGERS(flags, prefix, name, condition, label, file, line, message) \
|
||||
do \
|
||||
{ \
|
||||
if ((flags) & NL_ASSERT_FLAG_LOG) { \
|
||||
NL_ASSERT_LOG(prefix, name, condition, label, file, line, message); \
|
||||
} \
|
||||
if ((flags) & NL_ASSERT_FLAG_BACKTRACE) { \
|
||||
NL_ASSERT_BACKTRACE(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define __NL_ASSERT_MAYBE_RUN_POST_ACTION_TRIGGERS(flags, prefix, name, condition, label, file, line, message) \
|
||||
do \
|
||||
{ \
|
||||
if ((flags) & NL_ASSERT_FLAG_TRAP) { \
|
||||
NL_ASSERT_TRAP(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// __nlEXPECT
|
||||
|
||||
#define __nlEXPECT(flags, condition, label) \
|
||||
do \
|
||||
{ \
|
||||
if (__nlSHOULD_ASSERT(condition)) \
|
||||
{ \
|
||||
__NL_ASSERT_MAYBE_RUN_TRIGGERS((flags), \
|
||||
NL_ASSERT_PREFIX_STRING, \
|
||||
NL_ASSERT_COMPONENT_STRING, \
|
||||
#condition, \
|
||||
#label, \
|
||||
NL_ASSERT_FILE, \
|
||||
__LINE__, \
|
||||
0); \
|
||||
goto label; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define __nlEXPECT_PRINT(flags, condition, label, message) \
|
||||
do \
|
||||
{ \
|
||||
if (__nlSHOULD_ASSERT(condition)) \
|
||||
{ \
|
||||
__NL_ASSERT_MAYBE_RUN_TRIGGERS((flags), \
|
||||
NL_ASSERT_PREFIX_STRING, \
|
||||
NL_ASSERT_COMPONENT_STRING, \
|
||||
#condition, \
|
||||
#label, \
|
||||
NL_ASSERT_FILE, \
|
||||
__LINE__, \
|
||||
message); \
|
||||
goto label; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define __nlEXPECT_ACTION(flags, condition, label, action) \
|
||||
do \
|
||||
{ \
|
||||
if (__nlSHOULD_ASSERT(condition)) \
|
||||
{ \
|
||||
__NL_ASSERT_MAYBE_RUN_PRE_ACTION_TRIGGERS((flags), \
|
||||
NL_ASSERT_PREFIX_STRING, \
|
||||
NL_ASSERT_COMPONENT_STRING, \
|
||||
#condition, \
|
||||
#label, \
|
||||
NL_ASSERT_FILE, \
|
||||
__LINE__, \
|
||||
0); \
|
||||
{ \
|
||||
action; \
|
||||
} \
|
||||
__NL_ASSERT_MAYBE_RUN_POST_ACTION_TRIGGERS((flags), \
|
||||
NL_ASSERT_PREFIX_STRING, \
|
||||
NL_ASSERT_COMPONENT_STRING, \
|
||||
#condition, \
|
||||
#label, \
|
||||
NL_ASSERT_FILE, \
|
||||
__LINE__, \
|
||||
0); \
|
||||
goto label; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define __nlEXPECT_ACTION_PRINT(flags, condition, label, action, message) \
|
||||
do \
|
||||
{ \
|
||||
if (__nlSHOULD_ASSERT(condition)) \
|
||||
{ \
|
||||
__NL_ASSERT_MAYBE_RUN_PRE_ACTION_TRIGGERS((flags), \
|
||||
NL_ASSERT_PREFIX_STRING, \
|
||||
NL_ASSERT_COMPONENT_STRING, \
|
||||
#condition, \
|
||||
#label, \
|
||||
NL_ASSERT_FILE, \
|
||||
__LINE__, \
|
||||
message); \
|
||||
{ \
|
||||
action; \
|
||||
} \
|
||||
__NL_ASSERT_MAYBE_RUN_POST_ACTION_TRIGGERS((flags), \
|
||||
NL_ASSERT_PREFIX_STRING, \
|
||||
NL_ASSERT_COMPONENT_STRING, \
|
||||
#condition, \
|
||||
#label, \
|
||||
NL_ASSERT_FILE, \
|
||||
__LINE__, \
|
||||
message); \
|
||||
goto label; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define __nlEXPECT_SUCCESS(flags, status, label) __nlEXPECT(flags, status == 0, label)
|
||||
#define __nlEXPECT_SUCCESS_PRINT(flags, status, label, message) __nlEXPECT_PRINT(flags, status == 0, label, message)
|
||||
#define __nlEXPECT_SUCCESS_ACTION(flags, status, label, action) __nlEXPECT_ACTION(flags, status == 0, label, action)
|
||||
#define __nlEXPECT_SUCCESS_ACTION_PRINT(flags, status, label, action, message) __nlEXPECT_ACTION_PRINT(flags, status == 0, label, action, message)
|
||||
|
||||
#define __nlNEXPECT(flags, condition, label) __nlEXPECT(flags, !(condition), label)
|
||||
#define __nlNEXPECT_PRINT(flags, condition, label, message) __nlEXPECT_PRINT(flags, !(condition), label, message)
|
||||
#define __nlNEXPECT_ACTION(flags, condition, label, action) __nlEXPECT_ACTION(flags, !(condition), label, action)
|
||||
#define __nlNEXPECT_ACTION_PRINT(flags, condition, label, action, message) __nlEXPECT_ACTION_PRINT(flags, !(condition), label, action, message)
|
||||
|
||||
// __nlCHECK
|
||||
//
|
||||
// NOTE: Some of these macros take a C statement as a parameter. The unusual
|
||||
// "else do {} while(0)" construct allows those macros to work properly when
|
||||
// that parameter is set to "continue" or "break" (which isn't unexpected in
|
||||
// an assert macro).
|
||||
//
|
||||
// If the macros were written in the standard way by wrapping them in a
|
||||
// "do/while(0)", they could fail silently: A "continue" or "break" statement,
|
||||
// intended to break out of one or all iterations of the loop containing the
|
||||
// macro invocation -- would instead just break out of the macro's internal
|
||||
// do-while.
|
||||
|
||||
#define __nlCHECK(flags, condition) \
|
||||
if (__nlSHOULD_ASSERT(condition)) \
|
||||
{ \
|
||||
__NL_ASSERT_MAYBE_RUN_TRIGGERS((flags), \
|
||||
NL_ASSERT_PREFIX_STRING, \
|
||||
NL_ASSERT_COMPONENT_STRING, \
|
||||
#condition, \
|
||||
0, \
|
||||
NL_ASSERT_FILE, \
|
||||
__LINE__, \
|
||||
0); \
|
||||
} \
|
||||
else do {} while (0)
|
||||
|
||||
#define __nlCHECK_ACTION(flags, condition, action) \
|
||||
if (__nlSHOULD_ASSERT(condition)) \
|
||||
{ \
|
||||
__NL_ASSERT_MAYBE_RUN_PRE_ACTION_TRIGGERS((flags), \
|
||||
NL_ASSERT_PREFIX_STRING, \
|
||||
NL_ASSERT_COMPONENT_STRING, \
|
||||
#condition, \
|
||||
0, \
|
||||
NL_ASSERT_FILE, \
|
||||
__LINE__, \
|
||||
0); \
|
||||
{ \
|
||||
action; \
|
||||
} \
|
||||
__NL_ASSERT_MAYBE_RUN_POST_ACTION_TRIGGERS((flags), \
|
||||
NL_ASSERT_PREFIX_STRING, \
|
||||
NL_ASSERT_COMPONENT_STRING, \
|
||||
#condition, \
|
||||
0, \
|
||||
NL_ASSERT_FILE, \
|
||||
__LINE__, \
|
||||
0); \
|
||||
} \
|
||||
else do {} while (0) /* This is explained in the comment above __nlCHECK */
|
||||
|
||||
#define __nlCHECK_PRINT(flags, condition, message) \
|
||||
if (__nlSHOULD_ASSERT(condition)) \
|
||||
{ \
|
||||
__NL_ASSERT_MAYBE_RUN_TRIGGERS((flags), \
|
||||
NL_ASSERT_PREFIX_STRING, \
|
||||
NL_ASSERT_COMPONENT_STRING, \
|
||||
#condition, \
|
||||
0, \
|
||||
NL_ASSERT_FILE, \
|
||||
__LINE__, \
|
||||
message); \
|
||||
} \
|
||||
else do {} while (0) /* This is explained in the comment above __nlCHECK */
|
||||
|
||||
#define __nlCHECK_SUCCESS(flags, status) __nlCHECK(flags, status == 0)
|
||||
#define __nlCHECK_SUCCESS_ACTION(flags, status, action) __nlCHECK_ACTION(flags, status == 0, action)
|
||||
#define __nlCHECK_SUCCESS_PRINT(flags, status, message) __nlCHECK_PRINT(flags, status == 0, message)
|
||||
|
||||
#define __nlNCHECK(flags, condition) __nlCHECK(flags, !(condition))
|
||||
#define __nlNCHECK_ACTION(flags, condition, action) __nlCHECK_ACTION(flags, !(condition), action)
|
||||
#define __nlNCHECK_PRINT(flags, condition, message) __nlCHECK_PRINT(flags, !(condition), message)
|
||||
|
||||
// __nlVERIFY
|
||||
|
||||
#define __nlVERIFY(flags, condition) __nlCHECK(flags, condition)
|
||||
#define __nlVERIFY_ACTION(flags, condition, action) __nlCHECK_ACTION(flags, condition, action)
|
||||
#define __nlVERIFY_PRINT(flags, condition, message) __nlCHECK_PRINT(flags, condition, message)
|
||||
|
||||
#define __nlVERIFY_SUCCESS(flags, status) __nlCHECK_SUCCESS(flags, status)
|
||||
#define __nlVERIFY_SUCCESS_ACTION(flags, status, action) __nlCHECK_SUCCESS_ACTION(flags, status, action)
|
||||
#define __nlVERIFY_SUCCESS_PRINT(flags, status, message) __nlCHECK_SUCCESS_PRINT(flags, status, message)
|
||||
|
||||
#define __nlNVERIFY(flags, condition) __nlNCHECK(flags, condition)
|
||||
#define __nlNVERIFY_ACTION(flags, condition, action) __nlNCHECK_ACTION(flags, condition, action)
|
||||
#define __nlNVERIFY_PRINT(flags, condition, message) __nlNCHECK_PRINT(flags, condition, message)
|
||||
|
||||
// __nlPRECONDITION
|
||||
|
||||
#define __nlPRECONDITION(flags, condition, termination) \
|
||||
if (__nlSHOULD_ASSERT(condition)) \
|
||||
{ \
|
||||
__NL_ASSERT_MAYBE_RUN_TRIGGERS((flags), \
|
||||
NL_ASSERT_PREFIX_STRING, \
|
||||
NL_ASSERT_COMPONENT_STRING, \
|
||||
#condition, \
|
||||
0, \
|
||||
NL_ASSERT_FILE, \
|
||||
__LINE__, \
|
||||
0); \
|
||||
{ \
|
||||
termination; \
|
||||
} \
|
||||
} \
|
||||
else do {} while (0) /* This is explained in the comment above __nlCHECK */
|
||||
|
||||
#define __nlPRECONDITION_ACTION(flags, condition, termination, action) \
|
||||
if (__nlSHOULD_ASSERT(condition)) \
|
||||
{ \
|
||||
__NL_ASSERT_MAYBE_RUN_PRE_ACTION_TRIGGERS((flags), \
|
||||
NL_ASSERT_PREFIX_STRING, \
|
||||
NL_ASSERT_COMPONENT_STRING, \
|
||||
#condition, \
|
||||
0, \
|
||||
NL_ASSERT_FILE, \
|
||||
__LINE__, \
|
||||
0); \
|
||||
{ \
|
||||
action; \
|
||||
} \
|
||||
__NL_ASSERT_MAYBE_RUN_POST_ACTION_TRIGGERS((flags), \
|
||||
NL_ASSERT_PREFIX_STRING, \
|
||||
NL_ASSERT_COMPONENT_STRING, \
|
||||
#condition, \
|
||||
0, \
|
||||
NL_ASSERT_FILE, \
|
||||
__LINE__, \
|
||||
0); \
|
||||
{ \
|
||||
termination; \
|
||||
} \
|
||||
} \
|
||||
else do {} while (0) /* This is explained in the comment above __nlCHECK */
|
||||
|
||||
#define __nlPRECONDITION_PRINT(flags, condition, termination, message) \
|
||||
if (__nlSHOULD_ASSERT(condition)) \
|
||||
{ \
|
||||
__NL_ASSERT_MAYBE_RUN_TRIGGERS((flags), \
|
||||
NL_ASSERT_PREFIX_STRING, \
|
||||
NL_ASSERT_COMPONENT_STRING, \
|
||||
#condition, \
|
||||
0, \
|
||||
NL_ASSERT_FILE, \
|
||||
__LINE__, \
|
||||
message); \
|
||||
{ \
|
||||
termination; \
|
||||
} \
|
||||
} \
|
||||
else do {} while (0) /* This is explained in the comment above __nlCHECK */
|
||||
|
||||
#define __nlPRECONDITION_SUCCESS(flags, status, termination) __nlPRECONDITION(flags, status == 0, termination)
|
||||
#define __nlPRECONDITION_SUCCESS_ACTION(flags, status, termination, action) __nlPRECONDITION_ACTION(flags, status == 0, termination, action)
|
||||
#define __nlPRECONDITION_SUCCESS_PRINT(flags, status, termination, message) __nlPRECONDITION_PRINT(flags, status == 0, termination, message)
|
||||
|
||||
#define __nlNPRECONDITION(flags, condition, termination) __nlPRECONDITION(flags, !(condition), termination)
|
||||
#define __nlNPRECONDITION_ACTION(flags, condition, termination, action) __nlPRECONDITION_ACTION(flags, !(condition), termination, action)
|
||||
#define __nlNPRECONDITION_PRINT(flags, condition, termination, message) __nlPRECONDITION_PRINT(flags, !(condition), termination, message)
|
||||
|
||||
// __nlABORT
|
||||
|
||||
#define __nlABORT(flags, condition) __nlPRECONDITION(flags, condition, NL_ASSERT_ABORT())
|
||||
|
||||
#define __nlABORT_ACTION(flags, condition, action) __nlPRECONDITION_ACTION(flags, condition, NL_ASSERT_ABORT(), action)
|
||||
|
||||
#endif /* NLASSERT_INTERNAL_H */
|
||||
2143
Libs/Matter/third_party/nlassert/include/nlassert-nonproduction.h
vendored
Normal file
2143
Libs/Matter/third_party/nlassert/include/nlassert-nonproduction.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
713
Libs/Matter/third_party/nlassert/include/nlassert-production.h
vendored
Normal file
713
Libs/Matter/third_party/nlassert/include/nlassert-production.h
vendored
Normal file
@@ -0,0 +1,713 @@
|
||||
/*
|
||||
* Copyright 2010-2016 Nest Labs Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file defines macros and interfaces for performing
|
||||
* compile- and run-time assertion checking and run-time
|
||||
* exception handling when #NL_ASSERT_PRODUCTION is true.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NLASSERT_PRODUCTION_H
|
||||
#define NLASSERT_PRODUCTION_H
|
||||
|
||||
#include "nlassert-internal.h"
|
||||
|
||||
// nlCHECK
|
||||
|
||||
/**
|
||||
* @implements nlCHECK(aCondition)
|
||||
*
|
||||
*/
|
||||
#define nlCHECK(aCondition) __nlASSERT_UNUSED(aCondition)
|
||||
|
||||
/**
|
||||
* @implements nlCHECK_ACTION(aCondition, anAction)
|
||||
*
|
||||
*/
|
||||
#define nlCHECK_ACTION(aCondition, anAction) __nlASSERT_UNUSED(aCondition)
|
||||
|
||||
/**
|
||||
* @implements nlCHECK_PRINT(aCondition, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlCHECK_PRINT(aCondition, aMessage) __nlASSERT_UNUSED(aCondition)
|
||||
|
||||
/**
|
||||
* @implements nlCHECK_SUCCESS(aStatus)
|
||||
*
|
||||
*/
|
||||
#define nlCHECK_SUCCESS(aStatus) __nlASSERT_UNUSED(aStatus)
|
||||
|
||||
/**
|
||||
* @implements nlCHECK_SUCCESS_ACTION(aStatus, anAction)
|
||||
*
|
||||
*/
|
||||
#define nlCHECK_SUCCESS_ACTION(aStatus, anAction) __nlASSERT_UNUSED(aStatus)
|
||||
|
||||
/**
|
||||
* @implements nlCHECK_SUCCESS_PRINT(aStatus, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlCHECK_SUCCESS_PRINT(aStatus, aMessage) __nlASSERT_UNUSED(aStatus)
|
||||
|
||||
/**
|
||||
* @implements nlNCHECK(aCondition)
|
||||
*
|
||||
*/
|
||||
#define nlNCHECK(aCondition) __nlASSERT_UNUSED(aCondition)
|
||||
|
||||
/**
|
||||
* @implements nlNCHECK_ACTION(aCondition, anAction)
|
||||
*
|
||||
*/
|
||||
#define nlNCHECK_ACTION(aCondition, anAction) __nlASSERT_UNUSED(aCondition)
|
||||
|
||||
/**
|
||||
* @implements nlNCHECK_PRINT(aCondition, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlNCHECK_PRINT(aCondition, aMessage) __nlASSERT_UNUSED(aCondition)
|
||||
|
||||
// nlVERIFY
|
||||
|
||||
/**
|
||||
* @def NL_ASSERT_VERIFY_PRODUCTION_FLAGS_DEFAULT
|
||||
*
|
||||
* @brief
|
||||
* This defines the default behavioral flags for verify-style
|
||||
* exception family assertions when #NL_ASSERT_PRODUCTION is
|
||||
* enabled.
|
||||
*
|
||||
* This may be used to override #NL_ASSERT_VERIFY_PRODUCTION_FLAGS as follows:
|
||||
*
|
||||
* @code
|
||||
* #define NL_ASSERT_VERIFY_PRODUCTION_FLAGS NL_ASSERT_VERIFY_PRODUCTION_FLAGS_DEFAULT
|
||||
*
|
||||
* #include <nlassert.h>
|
||||
* @endcode
|
||||
*
|
||||
* @sa #NL_ASSERT_VERIFY_PRODUCTION_FLAGS
|
||||
*
|
||||
* @sa #NL_ASSERT_PRODUCTION
|
||||
*
|
||||
* @sa #NL_ASSERT_FLAG_BACKTRACE
|
||||
* @sa #NL_ASSERT_FLAG_LOG
|
||||
* @sa #NL_ASSERT_FLAG_TRAP
|
||||
*
|
||||
* @ingroup verify-style
|
||||
*
|
||||
*/
|
||||
#define NL_ASSERT_VERIFY_PRODUCTION_FLAGS_DEFAULT (NL_ASSERT_FLAG_BACKTRACE | NL_ASSERT_FLAG_LOG)
|
||||
|
||||
/**
|
||||
* @def NL_ASSERT_VERIFY_PRODUCTION_FLAGS
|
||||
*
|
||||
* @brief
|
||||
* This defines the behavioral flags when #NL_ASSERT_PRODUCTION is
|
||||
* enabled that govern the behavior for verify-style exception
|
||||
* family assertions when the assertion expression evaluates to
|
||||
* false.
|
||||
*
|
||||
* @sa #NL_ASSERT_USE_FLAGS_DEFAULT
|
||||
*
|
||||
* @sa #NL_ASSERT_VERIFY_PRODUCTION_FLAGS_DEFAULT
|
||||
*
|
||||
* @sa #NL_ASSERT_PRODUCTION
|
||||
*
|
||||
* @sa #NL_ASSERT_FLAG_BACKTRACE
|
||||
* @sa #NL_ASSERT_FLAG_LOG
|
||||
* @sa #NL_ASSERT_FLAG_TRAP
|
||||
*
|
||||
* @ingroup verify-style
|
||||
*
|
||||
*/
|
||||
#if NL_ASSERT_USE_FLAGS_DEFAULT
|
||||
#define NL_ASSERT_VERIFY_PRODUCTION_FLAGS NL_ASSERT_VERIFY_PRODUCTION_FLAGS_DEFAULT
|
||||
#elif !defined(NL_ASSERT_VERIFY_PRODUCTION_FLAGS)
|
||||
#define NL_ASSERT_VERIFY_PRODUCTION_FLAGS (NL_ASSERT_FLAG_NONE)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @implements nlVERIFY(aCondition)
|
||||
*
|
||||
*/
|
||||
#define nlVERIFY(aCondition) __nlVERIFY(NL_ASSERT_VERIFY_PRODUCTION_FLAGS, aCondition)
|
||||
|
||||
/**
|
||||
* @implements nlVERIFY_ACTION(aCondition, anAction)
|
||||
*
|
||||
*/
|
||||
#define nlVERIFY_ACTION(aCondition, anAction) __nlVERIFY_ACTION(NL_ASSERT_VERIFY_PRODUCTION_FLAGS, aCondition, anAction)
|
||||
|
||||
/**
|
||||
* @implements nlVERIFY_PRINT(aCondition, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlVERIFY_PRINT(aCondition, aMessage) __nlVERIFY_PRINT(NL_ASSERT_VERIFY_PRODUCTION_FLAGS, aCondition, aMessage)
|
||||
|
||||
/**
|
||||
* @implements nlVERIFY_SUCCESS(aStatus)
|
||||
*
|
||||
*/
|
||||
#define nlVERIFY_SUCCESS(aStatus) __nlVERIFY_SUCCESS(NL_ASSERT_VERIFY_PRODUCTION_FLAGS, aStatus)
|
||||
|
||||
/**
|
||||
* @implements nlVERIFY_SUCCESS_ACTION(aStatus, anAction)
|
||||
*
|
||||
*/
|
||||
#define nlVERIFY_SUCCESS_ACTION(aStatus, anAction) __nlVERIFY_SUCCESS_ACTION(NL_ASSERT_VERIFY_PRODUCTION_FLAGS, aStatus, anAction)
|
||||
|
||||
/**
|
||||
* @implements nlVERIFY_SUCCESS_PRINT(aStatus, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlVERIFY_SUCCESS_PRINT(aStatus, aMessage) __nlVERIFY_SUCCESS_PRINT(NL_ASSERT_VERIFY_PRODUCTION_FLAGS, aStatus, aMessage)
|
||||
|
||||
/**
|
||||
* @implements nlNVERIFY(aCondition)
|
||||
*
|
||||
*/
|
||||
#define nlNVERIFY(aCondition) __nlNVERIFY(NL_ASSERT_VERIFY_PRODUCTION_FLAGS, aCondition)
|
||||
|
||||
/**
|
||||
* @implements nlNVERIFY_ACTION(aCondition, anAction)
|
||||
*
|
||||
*/
|
||||
#define nlNVERIFY_ACTION(aCondition, anAction) __nlNVERIFY_ACTION(NL_ASSERT_VERIFY_PRODUCTION_FLAGS, aCondition, anAction)
|
||||
|
||||
/**
|
||||
* @implements nlNVERIFY_PRINT(aCondition, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlNVERIFY_PRINT(aCondition, aMessage) __nlNVERIFY_PRINT(NL_ASSERT_VERIFY_PRODUCTION_FLAGS, aCondition, aMessage)
|
||||
|
||||
// nlDESIRE
|
||||
|
||||
/**
|
||||
* @def NL_ASSERT_DESIRE_PRODUCTION_FLAGS_DEFAULT
|
||||
*
|
||||
* @brief
|
||||
* This defines the default behavioral flags for desire-style
|
||||
* exception family assertions when #NL_ASSERT_PRODUCTION is
|
||||
* enabled.
|
||||
*
|
||||
* This may be used to override #NL_ASSERT_DESIRE_PRODUCTION_FLAGS as follows:
|
||||
*
|
||||
* @code
|
||||
* #define NL_ASSERT_DESIRE_PRODUCTION_FLAGS NL_ASSERT_DESIRE_PRODUCTION_FLAGS_DEFAULT
|
||||
*
|
||||
* #include <nlassert.h>
|
||||
* @endcode
|
||||
*
|
||||
* @sa #NL_ASSERT_DESIRE_PRODUCTION_FLAGS
|
||||
*
|
||||
* @sa #NL_ASSERT_PRODUCTION
|
||||
*
|
||||
* @sa #NL_ASSERT_FLAG_BACKTRACE
|
||||
* @sa #NL_ASSERT_FLAG_LOG
|
||||
* @sa #NL_ASSERT_FLAG_TRAP
|
||||
*
|
||||
* @ingroup desire-style
|
||||
*
|
||||
*/
|
||||
#define NL_ASSERT_DESIRE_PRODUCTION_FLAGS_DEFAULT (NL_ASSERT_FLAG_NONE)
|
||||
|
||||
/**
|
||||
* @def NL_ASSERT_DESIRE_PRODUCTION_FLAGS
|
||||
*
|
||||
* @brief
|
||||
* This defines the behavioral flags when #NL_ASSERT_PRODUCTION is
|
||||
* enabled that govern the behavior for desire-style exception
|
||||
* family assertions when the assertion expression evaluates to
|
||||
* false.
|
||||
*
|
||||
* @sa #NL_ASSERT_USE_FLAGS_DEFAULT
|
||||
*
|
||||
* @sa #NL_ASSERT_DESIRE_PRODUCTION_FLAGS_DEFAULT
|
||||
*
|
||||
* @sa #NL_ASSERT_PRODUCTION
|
||||
*
|
||||
* @sa #NL_ASSERT_FLAG_BACKTRACE
|
||||
* @sa #NL_ASSERT_FLAG_LOG
|
||||
* @sa #NL_ASSERT_FLAG_TRAP
|
||||
*
|
||||
* @ingroup desire-style
|
||||
*
|
||||
*/
|
||||
#if NL_ASSERT_USE_FLAGS_DEFAULT
|
||||
#define NL_ASSERT_DESIRE_PRODUCTION_FLAGS NL_ASSERT_DESIRE_PRODUCTION_FLAGS_DEFAULT
|
||||
#elif !defined(NL_ASSERT_DESIRE_PRODUCTION_FLAGS)
|
||||
#define NL_ASSERT_DESIRE_PRODUCTION_FLAGS (NL_ASSERT_FLAG_NONE)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @implements nlDESIRE(aCondition, aLabel)
|
||||
*
|
||||
*/
|
||||
#define nlDESIRE(aCondition, aLabel) __nlEXPECT(NL_ASSERT_DESIRE_PRODUCTION_FLAGS, aCondition, aLabel)
|
||||
|
||||
/**
|
||||
* @implements nlDESIRE_PRINT(aCondition, aLabel, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlDESIRE_PRINT(aCondition, aLabel, aMessage) __nlEXPECT_PRINT(NL_ASSERT_DESIRE_PRODUCTION_FLAGS, aCondition, aLabel, aMessage)
|
||||
|
||||
/**
|
||||
* @implements nlDESIRE_ACTION(aCondition, aLabel, anAction)
|
||||
*
|
||||
*/
|
||||
#define nlDESIRE_ACTION(aCondition, aLabel, anAction) __nlEXPECT_ACTION(NL_ASSERT_DESIRE_PRODUCTION_FLAGS, aCondition, aLabel, anAction)
|
||||
|
||||
/**
|
||||
* @implements nlDESIRE_ACTION_PRINT(aCondition, aLabel, anAction, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlDESIRE_ACTION_PRINT(aCondition, aLabel, anAction, aMessage) __nlEXPECT_ACTION_PRINT(NL_ASSERT_DESIRE_PRODUCTION_FLAGS, aCondition, aLabel, anAction, aMessage)
|
||||
|
||||
/**
|
||||
* @implements nlDESIRE_SUCCESS(aStatus, aLabel)
|
||||
*
|
||||
*/
|
||||
#define nlDESIRE_SUCCESS(aStatus, aLabel) __nlEXPECT_SUCCESS(NL_ASSERT_DESIRE_PRODUCTION_FLAGS, aStatus, aLabel)
|
||||
|
||||
/**
|
||||
* @implements nlDESIRE_SUCCESS_PRINT(aStatus, aLabel, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlDESIRE_SUCCESS_PRINT(aStatus, aLabel, aMessage) __nlEXPECT_SUCCESS_PRINT(NL_ASSERT_DESIRE_PRODUCTION_FLAGS, aStatus, aLabel, aMessage)
|
||||
|
||||
/**
|
||||
* @implements nlDESIRE_SUCCESS_ACTION(aStatus, aLabel, anAction)
|
||||
*
|
||||
*/
|
||||
#define nlDESIRE_SUCCESS_ACTION(aStatus, aLabel, anAction) __nlEXPECT_SUCCESS_ACTION(NL_ASSERT_DESIRE_PRODUCTION_FLAGS, aStatus, aLabel, anAction)
|
||||
|
||||
/**
|
||||
* @implements nlDESIRE_SUCCESS_ACTION_PRINT(aStatus, aLabel, anAction, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlDESIRE_SUCCESS_ACTION_PRINT(aStatus, aLabel, anAction, aMessage) __nlEXPECT_SUCCESS_ACTION_PRINT(NL_ASSERT_DESIRE_PRODUCTION_FLAGS, aStatus, aLabel, anAction, aMessage)
|
||||
|
||||
/**
|
||||
* @implements nlNDESIRE(aCondition, aLabel)
|
||||
*
|
||||
*/
|
||||
#define nlNDESIRE(aCondition, aLabel) __nlNEXPECT(NL_ASSERT_DESIRE_PRODUCTION_FLAGS, aCondition, aLabel)
|
||||
|
||||
/**
|
||||
* @implements nlNDESIRE_PRINT(aCondition, aLabel, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlNDESIRE_PRINT(aCondition, aLabel, aMessage) __nlNEXPECT_PRINT(NL_ASSERT_DESIRE_PRODUCTION_FLAGS, aCondition, aLabel, aMessage)
|
||||
|
||||
/**
|
||||
* @implements nlNDESIRE_ACTION(aCondition, aLabel, anAction)
|
||||
*
|
||||
*/
|
||||
#define nlNDESIRE_ACTION(aCondition, aLabel, anAction) __nlNEXPECT_ACTION(NL_ASSERT_DESIRE_PRODUCTION_FLAGS, aCondition, aLabel, anAction)
|
||||
|
||||
/**
|
||||
* @implements nlNDESIRE_ACTION_PRINT(aCondition, aLabel, anAction, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlNDESIRE_ACTION_PRINT(aCondition, aLabel, anAction, aMessage) __nlNEXPECT_ACTION_PRINT(NL_ASSERT_DESIRE_PRODUCTION_FLAGS, aCondition, aLabel, anAction, aMessage)
|
||||
|
||||
// nlREQUIRE
|
||||
|
||||
/**
|
||||
* @def NL_ASSERT_REQUIRE_PRODUCTION_FLAGS_DEFAULT
|
||||
*
|
||||
* @brief
|
||||
* This defines the default behavioral flags for require-style
|
||||
* exception family assertions when #NL_ASSERT_PRODUCTION is
|
||||
* enabled.
|
||||
*
|
||||
* This may be used to override #NL_ASSERT_REQUIRE_PRODUCTION_FLAGS as follows:
|
||||
*
|
||||
* @code
|
||||
* #define NL_ASSERT_REQUIRE_PRODUCTION_FLAGS NL_ASSERT_REQUIRE_PRODUCTION_FLAGS_DEFAULT
|
||||
*
|
||||
* #include <nlassert.h>
|
||||
* @endcode
|
||||
*
|
||||
* @sa #NL_ASSERT_REQUIRE_PRODUCTION_FLAGS
|
||||
*
|
||||
* @sa #NL_ASSERT_PRODUCTION
|
||||
*
|
||||
* @sa #NL_ASSERT_FLAG_BACKTRACE
|
||||
* @sa #NL_ASSERT_FLAG_LOG
|
||||
* @sa #NL_ASSERT_FLAG_TRAP
|
||||
*
|
||||
* @ingroup require-style
|
||||
*
|
||||
*/
|
||||
#define NL_ASSERT_REQUIRE_PRODUCTION_FLAGS_DEFAULT (NL_ASSERT_FLAG_BACKTRACE | NL_ASSERT_FLAG_LOG)
|
||||
|
||||
/**
|
||||
* @def NL_ASSERT_REQUIRE_PRODUCTION_FLAGS
|
||||
*
|
||||
* @brief
|
||||
* This defines the behavioral flags when #NL_ASSERT_PRODUCTION is
|
||||
* enabled that govern the behavior for require-style exception
|
||||
* family assertions when the assertion expression evaluates to
|
||||
* false.
|
||||
*
|
||||
* @sa #NL_ASSERT_USE_FLAGS_DEFAULT
|
||||
*
|
||||
* @sa #NL_ASSERT_REQUIRE_PRODUCTION_FLAGS_DEFAULT
|
||||
*
|
||||
* @sa #NL_ASSERT_PRODUCTION
|
||||
*
|
||||
* @sa #NL_ASSERT_FLAG_BACKTRACE
|
||||
* @sa #NL_ASSERT_FLAG_LOG
|
||||
* @sa #NL_ASSERT_FLAG_TRAP
|
||||
*
|
||||
* @ingroup require-style
|
||||
*
|
||||
*/
|
||||
#if NL_ASSERT_USE_FLAGS_DEFAULT
|
||||
#define NL_ASSERT_REQUIRE_PRODUCTION_FLAGS NL_ASSERT_REQUIRE_PRODUCTION_FLAGS_DEFAULT
|
||||
#elif !defined(NL_ASSERT_REQUIRE_PRODUCTION_FLAGS)
|
||||
#define NL_ASSERT_REQUIRE_PRODUCTION_FLAGS (NL_ASSERT_FLAG_NONE)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @implements nlREQUIRE(aCondition, aLabel)
|
||||
*
|
||||
*/
|
||||
#define nlREQUIRE(aCondition, aLabel) __nlEXPECT(NL_ASSERT_REQUIRE_PRODUCTION_FLAGS, aCondition, aLabel)
|
||||
|
||||
/**
|
||||
* @implements nlREQUIRE_PRINT(aCondition, aLabel, aMessage)
|
||||
*/
|
||||
#define nlREQUIRE_PRINT(aCondition, aLabel, aMessage) __nlEXPECT_PRINT(NL_ASSERT_REQUIRE_PRODUCTION_FLAGS, aCondition, aLabel, aMessage)
|
||||
|
||||
/**
|
||||
* @implements nlREQUIRE_ACTION(aCondition, aLabel, anAction)
|
||||
*
|
||||
*/
|
||||
#define nlREQUIRE_ACTION(aCondition, aLabel, anAction) __nlEXPECT_ACTION(NL_ASSERT_REQUIRE_PRODUCTION_FLAGS, aCondition, aLabel, anAction)
|
||||
|
||||
/**
|
||||
* @implements nlREQUIRE_ACTION_PRINT(aCondition, aLabel, anAction, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlREQUIRE_ACTION_PRINT(aCondition, aLabel, anAction, aMessage) __nlEXPECT_ACTION_PRINT(NL_ASSERT_REQUIRE_PRODUCTION_FLAGS, aCondition, aLabel, anAction, aMessage)
|
||||
|
||||
/**
|
||||
* @implements nlREQUIRE_SUCCESS(aStatus, aLabel)
|
||||
*
|
||||
*/
|
||||
#define nlREQUIRE_SUCCESS(aStatus, aLabel) __nlEXPECT_SUCCESS(NL_ASSERT_REQUIRE_PRODUCTION_FLAGS, aStatus, aLabel)
|
||||
|
||||
/**
|
||||
* @implements nlREQUIRE_SUCCESS_PRINT(aStatus, aLabel, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlREQUIRE_SUCCESS_PRINT(aStatus, aLabel, aMessage) __nlEXPECT_SUCCESS_PRINT(NL_ASSERT_REQUIRE_PRODUCTION_FLAGS, aStatus, aLabel, aMessage)
|
||||
|
||||
/**
|
||||
* @implements nlREQUIRE_SUCCESS_ACTION(aStatus, aLabel, anAction)
|
||||
*
|
||||
*/
|
||||
#define nlREQUIRE_SUCCESS_ACTION(aStatus, aLabel, anAction) __nlEXPECT_SUCCESS_ACTION(NL_ASSERT_REQUIRE_PRODUCTION_FLAGS, aStatus, aLabel, anAction)
|
||||
|
||||
/**
|
||||
* @implements nlREQUIRE_SUCCESS_ACTION_PRINT(aStatus, aLabel, anAction, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlREQUIRE_SUCCESS_ACTION_PRINT(aStatus, aLabel, anAction, aMessage) __nlEXPECT_SUCCESS_ACTION_PRINT(NL_ASSERT_REQUIRE_PRODUCTION_FLAGS, aStatus, aLabel, anAction, aMessage)
|
||||
|
||||
/**
|
||||
* @implements nlNREQUIRE(aCondition, aLabel)
|
||||
*
|
||||
*/
|
||||
#define nlNREQUIRE(aCondition, aLabel) __nlNEXPECT(NL_ASSERT_REQUIRE_PRODUCTION_FLAGS, aCondition, aLabel)
|
||||
|
||||
/**
|
||||
* @implements nlNREQUIRE_PRINT(aCondition, aLabel, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlNREQUIRE_PRINT(aCondition, aLabel, aMessage) __nlNEXPECT_PRINT(NL_ASSERT_REQUIRE_PRODUCTION_FLAGS, aCondition, aLabel, aMessage)
|
||||
|
||||
/**
|
||||
* @implements nlNREQUIRE_ACTION(aCondition, aLabel, anAction)
|
||||
*
|
||||
*/
|
||||
#define nlNREQUIRE_ACTION(aCondition, aLabel, anAction) __nlNEXPECT_ACTION(NL_ASSERT_REQUIRE_PRODUCTION_FLAGS, aCondition, aLabel, anAction)
|
||||
|
||||
/**
|
||||
* @implements nlNREQUIRE_ACTION_PRINT(aCondition, aLabel, anAction, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlNREQUIRE_ACTION_PRINT(aCondition, aLabel, anAction, aMessage) __nlNEXPECT_ACTION_PRINT(NL_ASSERT_REQUIRE_PRODUCTION_FLAGS, aCondition, aLabel, anAction, aMessage)
|
||||
|
||||
// nlPRECONDITION
|
||||
|
||||
/**
|
||||
* @def NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS_DEFAULT
|
||||
*
|
||||
* @brief
|
||||
* This defines the default behavioral flags for precondition-style
|
||||
* exception family assertions when #NL_ASSERT_PRODUCTION is
|
||||
* enabled.
|
||||
*
|
||||
* This may be used to override #NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS as follows:
|
||||
*
|
||||
* @code
|
||||
* #define NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS_DEFAULT
|
||||
*
|
||||
* #include <nlassert.h>
|
||||
* @endcode
|
||||
*
|
||||
* @sa #NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS
|
||||
*
|
||||
* @sa #NL_ASSERT_PRODUCTION
|
||||
*
|
||||
* @sa #NL_ASSERT_FLAG_BACKTRACE
|
||||
* @sa #NL_ASSERT_FLAG_LOG
|
||||
* @sa #NL_ASSERT_FLAG_TRAP
|
||||
*
|
||||
* @ingroup precondition-style
|
||||
*
|
||||
*/
|
||||
#define NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS_DEFAULT (NL_ASSERT_FLAG_BACKTRACE | NL_ASSERT_FLAG_LOG)
|
||||
|
||||
/**
|
||||
* @def NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS
|
||||
*
|
||||
* @brief
|
||||
* This defines the behavioral flags when #NL_ASSERT_PRODUCTION is
|
||||
* disabled that govern the behavior for precondition-style exception
|
||||
* family assertions when the assertion expression evaluates to
|
||||
* false.
|
||||
*
|
||||
* @sa #NL_ASSERT_USE_FLAGS_DEFAULT
|
||||
*
|
||||
* @sa #NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS_DEFAULT
|
||||
*
|
||||
* @sa #NL_ASSERT_PRODUCTION
|
||||
*
|
||||
* @sa #NL_ASSERT_FLAG_BACKTRACE
|
||||
* @sa #NL_ASSERT_FLAG_LOG
|
||||
* @sa #NL_ASSERT_FLAG_TRAP
|
||||
*
|
||||
* @ingroup precondition-style
|
||||
*
|
||||
*/
|
||||
#if NL_ASSERT_USE_FLAGS_DEFAULT
|
||||
#define NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS_DEFAULT
|
||||
#elif !defined(NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS)
|
||||
#define NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS (NL_ASSERT_FLAG_NONE)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @implements nlPRECONDITION(aCondition)
|
||||
*
|
||||
*/
|
||||
#define nlPRECONDITION(aCondition) __nlPRECONDITION(NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS, aCondition, return)
|
||||
|
||||
/**
|
||||
* @implements nlPRECONDITION_ACTION(aCondition, anAction)
|
||||
*
|
||||
*/
|
||||
#define nlPRECONDITION_ACTION(aCondition, anAction) __nlPRECONDITION_ACTION(NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS, aCondition, return, anAction)
|
||||
|
||||
/**
|
||||
* @implements nlPRECONDITION_PRINT(aCondition, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlPRECONDITION_PRINT(aCondition, aMessage) __nlPRECONDITION_PRINT(NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS, aCondition, return, aMessage)
|
||||
|
||||
/**
|
||||
* @implements nlPRECONDITION_SUCCESS(aStatus)
|
||||
*
|
||||
*/
|
||||
#define nlPRECONDITION_SUCCESS(aStatus) __nlPRECONDITION_SUCCESS(NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS, aStatus, return)
|
||||
|
||||
/**
|
||||
* @implements nlPRECONDITION_SUCCESS_ACTION(aStatus, anAction)
|
||||
*
|
||||
*/
|
||||
#define nlPRECONDITION_SUCCESS_ACTION(aStatus, anAction) __nlPRECONDITION_SUCCESS_ACTION(NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS, aStatus, return, anAction)
|
||||
|
||||
/**
|
||||
* @implements nlPRECONDITION_SUCCESS_PRINT(aStatus, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlPRECONDITION_SUCCESS_PRINT(aStatus, aMessage) __nlPRECONDITION_SUCCESS_PRINT(NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS, aStatus, return, aMessage)
|
||||
|
||||
/**
|
||||
* @implements nlNPRECONDITION(aCondition)
|
||||
*
|
||||
*/
|
||||
#define nlNPRECONDITION(aCondition) __nlNPRECONDITION(NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS, aCondition, return)
|
||||
|
||||
/**
|
||||
* @implements nlNPRECONDITION_ACTION(aCondition, anAction)
|
||||
*
|
||||
*/
|
||||
#define nlNPRECONDITION_ACTION(aCondition, anAction) __nlNPRECONDITION_ACTION(NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS, aCondition, return, anAction)
|
||||
|
||||
/**
|
||||
* @implements nlNPRECONDITION_PRINT(aCondition, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlNPRECONDITION_PRINT(aCondition, aMessage) __nlNPRECONDITION_PRINT(NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS, aCondition, return, aMessage)
|
||||
|
||||
/**
|
||||
* @implements nlPRECONDITION_VALUE(aCondition, aValue)
|
||||
*
|
||||
*/
|
||||
#define nlPRECONDITION_VALUE(aCondition, aValue) __nlPRECONDITION(NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS, aCondition, return aValue)
|
||||
|
||||
/**
|
||||
* @implements nlPRECONDITION_VALUE_ACTION(aCondition, aValue, anAction)
|
||||
*
|
||||
*/
|
||||
#define nlPRECONDITION_VALUE_ACTION(aCondition, aValue, anAction) __nlPRECONDITION_ACTION(NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS, aCondition, return aValue, anAction)
|
||||
|
||||
/**
|
||||
* @implements nlPRECONDITION_VALUE_PRINT(aCondition, aValue, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlPRECONDITION_VALUE_PRINT(aCondition, aValue, aMessage) __nlPRECONDITION_PRINT(NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS, aCondition, return aValue, aMessage)
|
||||
|
||||
/**
|
||||
* @implements nlPRECONDITION_VALUE_SUCCESS(aStatus, aValue)
|
||||
*
|
||||
*/
|
||||
#define nlPRECONDITION_VALUE_SUCCESS(aStatus, aValue) __nlPRECONDITION_SUCCESS(NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS, aStatus, return aValue)
|
||||
|
||||
/**
|
||||
* @implements nlPRECONDITION_VALUE_SUCCESS_ACTION(aStatus, aValue, anAction)
|
||||
*
|
||||
*/
|
||||
#define nlPRECONDITION_VALUE_SUCCESS_ACTION(aStatus, aValue, anAction) __nlPRECONDITION_SUCCESS_ACTION(NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS, aStatus, return aValue, anAction)
|
||||
|
||||
/**
|
||||
* @implements nlPRECONDITION_VALUE_SUCCESS_PRINT(aStatus, aValue, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlPRECONDITION_VALUE_SUCCESS_PRINT(aStatus, aValue, aMessage) __nlPRECONDITION_SUCCESS_PRINT(NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS, aStatus, return aValue, aMessage)
|
||||
|
||||
/**
|
||||
* @implements nlNPRECONDITION_VALUE(aCondition, aValue)
|
||||
*
|
||||
*/
|
||||
#define nlNPRECONDITION_VALUE(aCondition, aValue) __nlNPRECONDITION(NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS, aCondition, return aValue)
|
||||
|
||||
/**
|
||||
* @implements nlNPRECONDITION_VALUE_ACTION(aCondition, aValue, anAction)
|
||||
*
|
||||
*/
|
||||
#define nlNPRECONDITION_VALUE_ACTION(aCondition, aValue, anAction) __nlNPRECONDITION_ACTION(NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS, aCondition, return aValue, anAction)
|
||||
|
||||
/**
|
||||
* @implements nlNPRECONDITION_VALUE_PRINT(aCondition, aValue, aMessage)
|
||||
*
|
||||
*/
|
||||
#define nlNPRECONDITION_VALUE_PRINT(aCondition, aValue, aMessage) __nlNPRECONDITION_PRINT(NL_ASSERT_PRECONDITION_PRODUCTION_FLAGS, aCondition, return aValue, aMessage)
|
||||
|
||||
// nlASSERT
|
||||
|
||||
/**
|
||||
* @implements nlASSERT(aCondition)
|
||||
*
|
||||
*/
|
||||
#define nlASSERT(aCondition) __nlASSERT_UNUSED(aCondition)
|
||||
|
||||
/**
|
||||
* @implements nlASSERT_ACTION(aCondition, anAction)
|
||||
*
|
||||
*/
|
||||
#define nlASSERT_ACTION(aCondition, anAction) __nlASSERT_UNUSED(aCondition)
|
||||
|
||||
// nlABORT
|
||||
|
||||
/**
|
||||
* @def NL_ASSERT_ABORT_PRODUCTION_FLAGS_DEFAULT
|
||||
*
|
||||
* @brief
|
||||
* This defines the default behavioral flags for abort-style
|
||||
* exception family assertions when #NL_ASSERT_PRODUCTION is
|
||||
* enabled.
|
||||
*
|
||||
* This may be used to override #NL_ASSERT_ABORT_PRODUCTION_FLAGS as follows:
|
||||
*
|
||||
* @code
|
||||
* #define NL_ASSERT_ABORT_PRODUCTION_FLAGS NL_ASSERT_ABORT_PRODUCTION_FLAGS_DEFAULT
|
||||
*
|
||||
* #include <nlassert.h>
|
||||
* @endcode
|
||||
*
|
||||
* @sa #NL_ASSERT_ABORT_PRODUCTION_FLAGS
|
||||
*
|
||||
* @sa #NL_ASSERT_PRODUCTION
|
||||
*
|
||||
* @sa #NL_ASSERT_FLAG_BACKTRACE
|
||||
* @sa #NL_ASSERT_FLAG_LOG
|
||||
* @sa #NL_ASSERT_FLAG_TRAP
|
||||
*
|
||||
* @ingroup abort-style
|
||||
*
|
||||
*/
|
||||
#define NL_ASSERT_ABORT_PRODUCTION_FLAGS_DEFAULT (NL_ASSERT_FLAG_BACKTRACE | NL_ASSERT_FLAG_LOG)
|
||||
|
||||
/**
|
||||
* @def NL_ASSERT_ABORT_PRODUCTION_FLAGS
|
||||
*
|
||||
* @brief
|
||||
* This defines the behavioral flags when #NL_ASSERT_PRODUCTION is
|
||||
* enabled that govern the behavior for abort-style exception
|
||||
* family assertions when the assertion expression evaluates to
|
||||
* false.
|
||||
*
|
||||
* @sa #NL_ASSERT_USE_FLAGS_DEFAULT
|
||||
*
|
||||
* @sa #NL_ASSERT_ABORT_PRODUCTION_FLAGS_DEFAULT
|
||||
*
|
||||
* @sa #NL_ASSERT_PRODUCTION
|
||||
*
|
||||
* @sa #NL_ASSERT_FLAG_BACKTRACE
|
||||
* @sa #NL_ASSERT_FLAG_LOG
|
||||
* @sa #NL_ASSERT_FLAG_TRAP
|
||||
*
|
||||
* @ingroup abort-style
|
||||
*
|
||||
*/
|
||||
#if NL_ASSERT_USE_FLAGS_DEFAULT
|
||||
#define NL_ASSERT_ABORT_PRODUCTION_FLAGS NL_ASSERT_ABORT_PRODUCTION_FLAGS_DEFAULT
|
||||
#elif !defined(NL_ASSERT_ABORT_PRODUCTION_FLAGS)
|
||||
#define NL_ASSERT_ABORT_PRODUCTION_FLAGS (NL_ASSERT_FLAG_NONE)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @implements nlABORT(aCondition)
|
||||
*
|
||||
*/
|
||||
#define nlABORT(aCondition) __nlABORT(NL_ASSERT_ABORT_PRODUCTION_FLAGS, aCondition)
|
||||
|
||||
/**
|
||||
* @implements nlABORT_ACTION(aCondition, anAction)
|
||||
*
|
||||
*/
|
||||
#define nlABORT_ACTION(aCondition, anAction) __nlABORT_ACTION(NL_ASSERT_ABORT_PRODUCTION_FLAGS, aCondition, anAction)
|
||||
|
||||
#endif /* NLASSERT_PRODUCTION_H */
|
||||
1728
Libs/Matter/third_party/nlassert/include/nlassert.h
vendored
Normal file
1728
Libs/Matter/third_party/nlassert/include/nlassert.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user