source: src/libcfa/assert.c @ bc03be3

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumwith_gc
Last change on this file since bc03be3 was f5883bd, checked in by Rob Schluntz <rschlunt@…>, 7 years ago

Fix CFA assert functions to use the assertion string

  • Property mode set to 100644
File size: 1.5 KB
Line 
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.h"
20
21extern "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: //
Note: See TracBrowser for help on using the repository browser.