Ignore:
Timestamp:
06/14/15 14:31:00 (10 years ago)
Author:
epyon
Message:
  • got rid of exceptions
  • assert enhancements
  • lots of minor cleanup
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/stl/assert.cc

    r402 r403  
    99#include "nv/base/assert.hh"
    1010#undef NV_BASE_COMMON_HH
     11#include "nv/core/logging.hh"
    1112
     13extern "C" {
    1214#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}
    1320
    14 #       if NV_DEBUG
    15 
     21#if NV_DEBUG
     22#       if NV_COMPILER == NV_MSVC
    1623extern "C" {
    1724        void __cdecl _wassert( const wchar_t * _Message, const wchar_t *_File, unsigned _Line );
    1825}
    1926
    20 void nv_internal_assert( const wchar_t * message, const wchar_t* file, unsigned line )
     27void nv::detail::assert_fail( const wchar_t * message, const wchar_t* file, unsigned line )
    2128{
    2229        _wassert( message, file, line );
    2330}
    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
    3032#       if NV_COMPILER == NV_CLANG
    3133extern "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;
    3435}
     36#define NV_ASSERT_IMPL __assert
    3537#       else
    3638extern "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;
    3940}
     41#define NV_ASSERT_IMPL __assert_fail
    4042#       endif
    41 __attribute__( ( __noreturn__ ) ) void nv_internal_assert( const char * assertion, const char * file, unsigned int line, const char * function )
     43NV_NORETURN void nv::detail::assert_fail( const char * assertion, const char * file, unsigned int line, const char * function )
    4244{
    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 );
    5246}
    5347#       endif
    5448
    55 #endif // NV_COMPILER
     49#endif // NV_DEBUG
    5650
     51NV_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
     59NV_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.