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.cc -- |
---|
8 | // |
---|
9 | // Author : Peter A. Buhr |
---|
10 | // Created On : Thu Aug 18 13:26:59 2016 |
---|
11 | // Last Modified By : Peter A. Buhr |
---|
12 | // Last Modified On : Fri Aug 19 17:07:08 2016 |
---|
13 | // Update Count : 10 |
---|
14 | // |
---|
15 | |
---|
16 | #include <assert.h> |
---|
17 | #include <cstdarg> // varargs |
---|
18 | #include <cstdio> // fprintf |
---|
19 | #include <cstdlib> // abort |
---|
20 | |
---|
21 | extern const char * __progname; // global name of running executable (argv[0]) |
---|
22 | |
---|
23 | #define CFA_ASSERT_FMT "*CFA assertion error* from program \"%s\" in \"%s\" at line %d in file \"%s\"" |
---|
24 | |
---|
25 | // called by macro assert in assert.h |
---|
26 | void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) { |
---|
27 | fprintf( stderr, CFA_ASSERT_FMT ".\n", __progname, function, line, file ); |
---|
28 | abort(); |
---|
29 | } |
---|
30 | |
---|
31 | // called by macro assertf |
---|
32 | void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) { |
---|
33 | fprintf( stderr, CFA_ASSERT_FMT ": ", __progname, function, line, file ); |
---|
34 | va_list args; |
---|
35 | va_start( args, fmt ); |
---|
36 | vfprintf( stderr, fmt, args ); |
---|
37 | abort(); |
---|
38 | } |
---|
39 | |
---|
40 | // Local Variables: // |
---|
41 | // tab-width: 4 // |
---|
42 | // mode: c++ // |
---|
43 | // compile-command: "make install" // |
---|
44 | // End: // |
---|
45 | |
---|