[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 |
---|
[91c389a] | 11 | // Last Modified By : Peter A. Buhr |
---|
| 12 | // Last Modified On : Thu Jul 20 15:10:26 2017 |
---|
| 13 | // Update Count : 2 |
---|
[f773f67] | 14 | // |
---|
| 15 | |
---|
[91c389a] | 16 | #include <assert.h> |
---|
| 17 | #include <stdarg.h> // varargs |
---|
| 18 | #include <stdio.h> // fprintf |
---|
[875a72f] | 19 | #include "bits/debug.h" |
---|
[9d944b2] | 20 | |
---|
[f773f67] | 21 | extern "C" { |
---|
| 22 | extern const char * __progname; // global name of running executable (argv[0]) |
---|
| 23 | |
---|
[f5883bd] | 24 | #define CFA_ASSERT_FMT "Cforall Assertion error \"%s\" from program \"%s\" in \"%s\" at line %d in file \"%s\"" |
---|
[f773f67] | 25 | |
---|
| 26 | // called by macro assert in assert.h |
---|
| 27 | void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) { |
---|
[f5883bd] | 28 | __cfaabi_dbg_bits_print_safe( CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file ); |
---|
[f773f67] | 29 | abort(); |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | // called by macro assertf |
---|
| 33 | void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) { |
---|
[36982fc] | 34 | __cfaabi_dbg_bits_acquire(); |
---|
[f5883bd] | 35 | __cfaabi_dbg_bits_print_nolock( CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file ); |
---|
[9d944b2] | 36 | |
---|
[f773f67] | 37 | va_list args; |
---|
| 38 | va_start( args, fmt ); |
---|
[36982fc] | 39 | __cfaabi_dbg_bits_print_vararg( fmt, args ); |
---|
[57f408e] | 40 | va_end( args ); |
---|
[9d944b2] | 41 | |
---|
[36982fc] | 42 | __cfaabi_dbg_bits_print_nolock( "\n" ); |
---|
| 43 | __cfaabi_dbg_bits_release(); |
---|
[f773f67] | 44 | abort(); |
---|
| 45 | } |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | // Local Variables: // |
---|
| 49 | // mode: c // |
---|
| 50 | // tab-width: 4 // |
---|
| 51 | // End: // |
---|