Changeset 403 for trunk/src/stl/assert.cc
- Timestamp:
- 06/14/15 14:31:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/stl/assert.cc
r402 r403 9 9 #include "nv/base/assert.hh" 10 10 #undef NV_BASE_COMMON_HH 11 #include "nv/core/logging.hh" 11 12 13 extern "C" { 12 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 } 13 20 14 # 15 21 #if NV_DEBUG 22 # if NV_COMPILER == NV_MSVC 16 23 extern "C" { 17 24 void __cdecl _wassert( const wchar_t * _Message, const wchar_t *_File, unsigned _Line ); 18 25 } 19 26 20 void nv _internal_assert( const wchar_t * message, const wchar_t* file, unsigned line )27 void nv::detail::assert_fail( const wchar_t * message, const wchar_t* file, unsigned line ) 21 28 { 22 29 _wassert( message, file, line ); 23 30 } 24 # else 25 void nv_internal_assert( const wchar_t *, const wchar_t*, unsigned ) {} 26 # endif // NV_DEBUG 27 #else // NV_COMPILER 28 29 # if NV_DEBUG 31 # else // NV_COMPILER 30 32 # if NV_COMPILER == NV_CLANG 31 33 extern "C" { 32 extern void __assert(const char *, const char *, unsigned int, const char *) 33 __attribute__ ((__noreturn__)); 34 extern void __assert(const char *, const char *, unsigned int, const char *) NV_NORETURN; 34 35 } 36 #define NV_ASSERT_IMPL __assert 35 37 # else 36 38 extern "C" { 37 extern void __assert_fail(const char *, const char *, unsigned int, const char *) 38 __attribute__ ((__noreturn__)); 39 extern void __assert_fail(const char *, const char *, unsigned int, const char *) NV_NORETURN; 39 40 } 41 #define NV_ASSERT_IMPL __assert_fail 40 42 # endif 41 __attribute__( ( __noreturn__ ) ) void nv_internal_assert( const char * assertion, const char * file, unsigned int line, const char * function )43 NV_NORETURN void nv::detail::assert_fail( const char * assertion, const char * file, unsigned int line, const char * function ) 42 44 { 43 # if NV_COMPILER == NV_CLANG 44 __assert(assertion, file, line, function ); 45 # else 46 __assert_fail(assertion, file, line, function ); 47 # endif 48 } 49 # else 50 void nv_internal_assert( const char * , const char * , unsigned int , const char * ) 51 { 45 NV_ASSERT_IMPL (assertion, file, line, function ); 52 46 } 53 47 # endif 54 48 55 #endif // NV_ COMPILER49 #endif // NV_DEBUG 56 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 }
Note: See TracChangeset
for help on using the changeset viewer.