ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 0a4c59b was
9d944b2,
checked in by Thierry Delisle <tdelisle@…>, 8 years ago
|
Implemented interposing for abort and exit, implemented safer debug output
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Rev | Line | |
---|
[f773f67] | 1 | // |
---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo |
---|
| 3 | // |
---|
| 4 | // The contents of this file are covered under the licence agreement in the |
---|
| 5 | // file "LICENCE" distributed with Cforall. |
---|
| 6 | // |
---|
| 7 | // assert.c -- |
---|
| 8 | // |
---|
| 9 | // Author : Thierry Delisle |
---|
| 10 | // Created On : Mon Nov 28 12:27:26 2016 |
---|
| 11 | // Last Modified By : Thierry Delisle |
---|
| 12 | // Last Modified On : Mon Nov 28 12:27:26 2016 |
---|
| 13 | // Update Count : 0 |
---|
| 14 | // |
---|
| 15 | |
---|
| 16 | #include "assert" |
---|
| 17 | #include "stdlib" // abort |
---|
| 18 | |
---|
[9d944b2] | 19 | #include "libhdr/libdebug.h" |
---|
| 20 | |
---|
[f773f67] | 21 | extern "C" { |
---|
| 22 | #include <stdarg.h> // varargs |
---|
| 23 | #include <stdio.h> // fprintf |
---|
| 24 | |
---|
| 25 | extern const char * __progname; // global name of running executable (argv[0]) |
---|
| 26 | |
---|
[9d944b2] | 27 | #define CFA_ASSERT_FMT "Cforall Assertion error from program \"%s\" in \"%s\" at line %d in file \"%s\"" |
---|
[f773f67] | 28 | |
---|
| 29 | // called by macro assert in assert.h |
---|
| 30 | void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) { |
---|
[9d944b2] | 31 | __lib_debug_print_safe( CFA_ASSERT_FMT ".\n", __progname, function, line, file ); |
---|
[f773f67] | 32 | abort(); |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | // called by macro assertf |
---|
| 36 | void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) { |
---|
[9d944b2] | 37 | __lib_debug_acquire(); |
---|
| 38 | __lib_debug_print_nolock( CFA_ASSERT_FMT ": ", __progname, function, line, file ); |
---|
| 39 | |
---|
[f773f67] | 40 | va_list args; |
---|
| 41 | va_start( args, fmt ); |
---|
[9d944b2] | 42 | __lib_debug_print_vararg( fmt, args ); |
---|
[57f408e] | 43 | va_end( args ); |
---|
[9d944b2] | 44 | |
---|
| 45 | __lib_debug_print_nolock( "\n" ); |
---|
| 46 | __lib_debug_release(); |
---|
[f773f67] | 47 | abort(); |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | // Local Variables: // |
---|
| 53 | // mode: c // |
---|
| 54 | // tab-width: 4 // |
---|
| 55 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.