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