source: src/libcfa/assert.c @ cf0b892

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 cf0b892 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
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 : 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
19#include "libhdr/libdebug.h"
20
21extern "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
27        #define CFA_ASSERT_FMT "Cforall Assertion error from program \"%s\" in \"%s\" at line %d in file \"%s\""
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 ) {
31                __lib_debug_print_safe( CFA_ASSERT_FMT ".\n", __progname, function, line, file );
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, ... ) {
37                __lib_debug_acquire();
38                __lib_debug_print_nolock( CFA_ASSERT_FMT ": ", __progname, function, line, file );
39
40                va_list args;
41                va_start( args, fmt );
42                __lib_debug_print_vararg( fmt, args );
43                va_end( args );
44
45                __lib_debug_print_nolock( "\n" );
46                __lib_debug_release();
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.