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