Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / nlassert / repo / include / stdc / assert.h
1 /*
2  *
3  *   Copyright 2015-2016 Nest Labs Inc. All Rights Reserved.
4  *
5  *   Licensed under the Apache License, Version 2.0 (the "License");
6  *   you may not use this file except in compliance with the License.
7  *   You may obtain a copy of the License at
8  *
9  *   http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *   Unless required by applicable law or agreed to in writing, software
12  *   distributed under the License is distributed on an "AS IS" BASIS,
13  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *   See the License for the specific language governing permissions and
15  *   limitations under the License.
16  *
17  */
18
19 /**
20  *    @file
21  *      This file provides an ISO/IEC 9899:1999-, C89-, and
22  *      C99-compatible Standard C Library header and assertion
23  *      interface definition, implemented atop Nest Labs assertion
24  *      checking and runtime exception interfaces such that consistent
25  *      platform and system capabilities, behavior, and output may
26  *      be implemented and enforced across the two interfaces.
27  *
28  *      Systems wishing to use this in lieu of their Standard C
29  *      Library header of the same name should ensure that their
30  *      toolchain is configured to either ignore or deprioritize
31  *      standard search paths while placing the directory this header
32  *      is contained in among the preferred header search paths.
33  *
34  */
35
36 #ifndef NL_ASSERT_STDC_ASSERT_H
37 #define NL_ASSERT_STDC_ASSERT_H
38
39 #include <nlassert.h>
40
41 /**
42  *  @def assert(aExpression)
43  *
44  *  @brief
45  *    This checks for the specified condition, which is expected to
46  *    commonly be true and takes action, based on configuration, and
47  *    aborts the current program execution if the condition is false.
48  *
49  *  This provides a workalike macro for the ISO/IEC 9899:1999, C89,
50  *  and C99 Standard C Library
51  *  [assert()](http://pubs.opengroup.org/onlinepubs/009695399/functions/assert.html)
52  *  macro interface and bases it upon the equivalent #nlABORT macro,
53  *  which has the same semantics, and the same behavior when active. The
54  *  difference between the #nlABORT macro and this assert() macro is that
55  *  #nlABORT is always active, while this one is inactive when NDEBUG is
56  *  defined and active when NDEBUG is undefined. Note that when this macro
57  *  is inactive, the test is __completely__ elided; side effects, if any,
58  *  in the tested expression will not be produced.
59  *
60  *  System integrators may want to use this as opposed to their native
61  *  Standard C Library assert() to ensure consistent capabilities,
62  *  behavior, and output across their software modules when runtime
63  *  assertions occur where the Nest Labs assertion checking and
64  *  runtime exception handling is also used.
65  *
66  *  @param[in]  aExpression  A Boolean expression to be evaluated.
67  *
68  *  @sa #nlASSERT
69  *
70  */
71 #ifdef NDEBUG
72 #ifdef __cplusplus
73 #define assert(aExpression) (static_cast<void> (0))
74 #else
75 #define assert(aExpression) ((void) (0))
76 #endif
77 #else
78 #define assert(aExpression) nlABORT(aExpression)
79 #endif
80
81 #endif /* NL_ASSERT_STDC_ASSERT_H */