1 | // Copyright (C) 2015 ChaosForge Ltd
|
---|
2 | // http://chaosforge.org/
|
---|
3 | //
|
---|
4 | // This file is part of Nova libraries.
|
---|
5 | // For conditions of distribution and use, see copying.txt file in root folder.
|
---|
6 |
|
---|
7 | #define NV_BASE_COMMON_HH
|
---|
8 | #define NV_INTERNAL_INCLUDE
|
---|
9 | #include "nv/base/assert.hh"
|
---|
10 | #undef NV_BASE_COMMON_HH
|
---|
11 | #include "nv/core/logging.hh"
|
---|
12 |
|
---|
13 | extern "C" {
|
---|
14 | #if NV_COMPILER == NV_MSVC
|
---|
15 | NV_NORETURN void __cdecl exit( _In_ int _Code );
|
---|
16 | #else
|
---|
17 | void exit( int status_code ) NV_NORETURN;
|
---|
18 | #endif
|
---|
19 | }
|
---|
20 |
|
---|
21 | #if NV_DEBUG
|
---|
22 | # if NV_COMPILER == NV_MSVC
|
---|
23 | extern "C" {
|
---|
24 | void __cdecl _wassert( const wchar_t * _Message, const wchar_t *_File, unsigned _Line );
|
---|
25 | }
|
---|
26 |
|
---|
27 | void nv::detail::assert_fail( const wchar_t * message, const wchar_t* file, unsigned line )
|
---|
28 | {
|
---|
29 | _wassert( message, file, line );
|
---|
30 | }
|
---|
31 | # else // NV_COMPILER
|
---|
32 | # if NV_COMPILER == NV_CLANG
|
---|
33 | extern "C" {
|
---|
34 | extern void __assert(const char *, const char *, unsigned int, const char *) NV_NORETURN;
|
---|
35 | }
|
---|
36 | #define NV_ASSERT_IMPL __assert
|
---|
37 | # else
|
---|
38 | extern "C" {
|
---|
39 | extern void __assert_fail(const char *, const char *, unsigned int, const char *) NV_NORETURN;
|
---|
40 | }
|
---|
41 | #define NV_ASSERT_IMPL __assert_fail
|
---|
42 | # endif
|
---|
43 | NV_NORETURN void nv::detail::assert_fail( const char * assertion, const char * file, unsigned int line, const char * function )
|
---|
44 | {
|
---|
45 | NV_ASSERT_IMPL (assertion, file, line, function );
|
---|
46 | }
|
---|
47 | # endif
|
---|
48 |
|
---|
49 | #endif // NV_DEBUG
|
---|
50 |
|
---|
51 | NV_NORETURN void nv::detail::abort( const char * msg, const char * file, unsigned int line, const char * function )
|
---|
52 | {
|
---|
53 | NV_LOG_CRITICAL( "Abort called : ", msg );
|
---|
54 | NV_LOG_CRITICAL( " in ", file, ":", line, " (", function, ")" );
|
---|
55 | NV_LOG_CRITICAL( "Aborting..." );
|
---|
56 | exit( 1 );
|
---|
57 | }
|
---|
58 |
|
---|
59 | NV_NORETURN void nv::detail::assert_abort( const char * msg, const char * file, unsigned int line, const char * function )
|
---|
60 | {
|
---|
61 | NV_LOG_CRITICAL( "Assertion failed: (", msg, ")" );
|
---|
62 | NV_LOG_CRITICAL( " in ", file, ":", line, " (", function, ")" );
|
---|
63 | NV_LOG_CRITICAL( "Aborting..." );
|
---|
64 | exit( 1 );
|
---|
65 | }
|
---|