-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathAssert.h
62 lines (54 loc) · 3.46 KB
/
Assert.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "LoggingModule.h"
#include <csignal>
#include <cstdlib>
#include <string>
#ifdef __COVERITY__
#include <cassert>
#endif
// coverity[autosar_cpp14_m16_3_2_violation] '#' operator required for debug text only
// coverity[misra_cpp_2008_rule_16_3_2_violation] '#' operator required for debug text only
#define FWE_FATAL_ASSERT( cond, msg ) \
do \
{ \
if ( !( cond ) ) \
{ \
FWE_LOG_ERROR( "Fatal error condition occurred, aborting application: " + std::string( msg ) + " " + \
std::string( #cond ) ); \
LoggingModule::flush(); \
fatalError(); \
} \
} while ( false )
// coverity[autosar_cpp14_m16_3_2_violation] '#' operator required for debug text only
// coverity[misra_cpp_2008_rule_16_3_2_violation] '#' operator required for debug text only
#define FWE_GRACEFUL_FATAL_ASSERT( cond, msg, returnValue ) \
do \
{ \
if ( !( cond ) ) \
{ \
FWE_LOG_ERROR( "Fatal error condition occurred, exiting application: " + std::string( msg ) + " " + \
std::string( #cond ) ); \
LoggingModule::flush(); \
std::raise( SIGUSR1 ); \
return returnValue; \
} \
} while ( false )
namespace Aws
{
namespace IoTFleetWise
{
inline void
fatalError()
{
#ifdef __COVERITY__
// coverity[misra_cpp_2008_rule_5_2_12_violation] Error from cassert header
// coverity[autosar_cpp14_m5_2_12_violation] Error from cassert header
assert( false );
#else
abort();
#endif
}
} // namespace IoTFleetWise
} // namespace Aws