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 | #include "nv/base/common.hh"
|
---|
8 | #include "nv/core/logging.hh"
|
---|
9 |
|
---|
10 | extern "C" {
|
---|
11 | #if NV_COMPILER == NV_MSVC
|
---|
12 | NV_NORETURN void __cdecl exit( int _Code );
|
---|
13 | #else
|
---|
14 | void exit( int status_code ) NV_NORETURN;
|
---|
15 | #endif
|
---|
16 | }
|
---|
17 |
|
---|
18 | #if NV_DEBUG
|
---|
19 | # if NV_COMPILER == NV_MSVC
|
---|
20 | extern "C" {
|
---|
21 | void __cdecl _wassert( const wchar_t * _Message, const wchar_t *_File, unsigned _Line );
|
---|
22 | }
|
---|
23 |
|
---|
24 | void nv::detail::assert_fail( const wchar_t * message, const wchar_t* file, unsigned line )
|
---|
25 | {
|
---|
26 | _wassert( message, file, line );
|
---|
27 | }
|
---|
28 | # else // NV_COMPILER
|
---|
29 | # if NV_COMPILER == NV_CLANG
|
---|
30 | extern "C" {
|
---|
31 | extern void __assert(const char *, const char *, unsigned int, const char *) NV_NORETURN;
|
---|
32 | }
|
---|
33 | #define NV_ASSERT_IMPL __assert
|
---|
34 | # else
|
---|
35 | extern "C" {
|
---|
36 | extern void __assert_fail(const char *, const char *, unsigned int, const char *) NV_NORETURN;
|
---|
37 | }
|
---|
38 | #define NV_ASSERT_IMPL __assert_fail
|
---|
39 | # endif
|
---|
40 | NV_NORETURN void nv::detail::assert_fail( const char * assertion, const char * file, unsigned int line, const char * function )
|
---|
41 | {
|
---|
42 | NV_ASSERT_IMPL (assertion, file, line, function );
|
---|
43 | }
|
---|
44 | # endif
|
---|
45 |
|
---|
46 | #endif // NV_DEBUG
|
---|
47 |
|
---|
48 | NV_NORETURN void nv::detail::abort( const char * msg, const char * file, unsigned int line, const char * function )
|
---|
49 | {
|
---|
50 | NV_LOG_CRITICAL( "Abort called : ", msg );
|
---|
51 | NV_LOG_CRITICAL( " in ", file, ":", line, " (", function, ")" );
|
---|
52 | NV_LOG_CRITICAL( "Aborting..." );
|
---|
53 | exit( 1 );
|
---|
54 | }
|
---|
55 |
|
---|
56 | NV_NORETURN void nv::detail::assert_abort( const char * msg, const char * file, unsigned int line, const char * function )
|
---|
57 | {
|
---|
58 | NV_LOG_CRITICAL( "Assertion failed: (", msg, ")" );
|
---|
59 | NV_LOG_CRITICAL( " in ", file, ":", line, " (", function, ")" );
|
---|
60 | NV_LOG_CRITICAL( "Aborting..." );
|
---|
61 | exit( 1 );
|
---|
62 | }
|
---|
63 |
|
---|
64 |
|
---|
65 | NV_NORETURN void nv::exit( int ret_val )
|
---|
66 | {
|
---|
67 | ::exit( ret_val );
|
---|
68 | }
|
---|