source: libcfa/src/assert.cfa @ 746157e

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 746157e was 1c40091, checked in by Peter A. Buhr <pabuhr@…>, 4 years ago

rename cfaabi_dbg_bits_* to cfaabi_bits_*, add fd parameter to cfaabi_bits_* routines

  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[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
[1c40091]12// Last Modified On : Thu Nov 21 17:09:26 2019
13// Update Count     : 5
[f773f67]14//
15
[91c389a]16#include <assert.h>
17#include <stdarg.h>                                                             // varargs
18#include <stdio.h>                                                              // fprintf
[1c40091]19#include <unistd.h>                                                             // STDERR_FILENO
[73abe95]20#include "bits/debug.hfa"
[9d944b2]21
[f773f67]22extern "C" {
23        extern const char * __progname;                                         // global name of running executable (argv[0])
24
[f5883bd]25        #define CFA_ASSERT_FMT "Cforall Assertion error \"%s\" from program \"%s\" in \"%s\" at line %d in file \"%s\""
[f773f67]26
27        // called by macro assert in assert.h
28        void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) {
[1c40091]29                __cfaabi_bits_print_safe( STDERR_FILENO, CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file );
[f773f67]30                abort();
31        }
32
33        // called by macro assertf
34        void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) {
[1c40091]35                __cfaabi_bits_acquire();
36                __cfaabi_bits_print_nolock( STDERR_FILENO, CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file );
[9d944b2]37
[f773f67]38                va_list args;
39                va_start( args, fmt );
[1c40091]40                __cfaabi_bits_print_vararg( STDERR_FILENO, fmt, args );
[57f408e]41                va_end( args );
[9d944b2]42
[1c40091]43                __cfaabi_bits_print_nolock( STDERR_FILENO, "\n" );
44                __cfaabi_bits_release();
[f773f67]45                abort();
46        }
47}
48
49// Local Variables: //
50// mode: c //
51// tab-width: 4 //
52// End: //
Note: See TracBrowser for help on using the repository browser.