source: libcfa/src/assert.cfa @ 5f9c42b

ADTast-experimental
Last change on this file since 5f9c42b was 032234bd, checked in by Thierry Delisle <tdelisle@…>, 2 years ago

Visibility of the core libcfa files.

  • Property mode set to 100644
File size: 1.8 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 : Tue Feb  4 13:00:18 2020
13// Update Count     : 6
14//
15
16#include <assert.h>
17#include <stdarg.h>                                                             // varargs
18#include <stdio.h>                                                              // fprintf
19#include <unistd.h>                                                             // STDERR_FILENO
20#include "bits/debug.hfa"
21#include "bits/defs.hfa"
22
23extern "C" {
24        extern const char * __progname;                                         // global name of running executable (argv[0])
25
26        #define CFA_ASSERT_FMT "Cforall Assertion error \"%s\" from program \"%s\" in \"%s\" at line %d in file \"%s\""
27
28        // called by macro assert in assert.h
29        // would be cool to remove libcfa_public but it's needed for libcfathread
30        void __assert_fail( const char assertion[], const char file[], unsigned int line, const char function[] ) libcfa_public {
31                __cfaabi_bits_print_safe( STDERR_FILENO, CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file );
32                abort();
33        }
34
35        // called by macro assertf
36        // would be cool to remove libcfa_public but it's needed for libcfathread
37        void __assert_fail_f( const char assertion[], const char file[], unsigned int line, const char function[], const char fmt[], ... ) libcfa_public {
38                __cfaabi_bits_acquire();
39                __cfaabi_bits_print_nolock( STDERR_FILENO, CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file );
40
41                va_list args;
42                va_start( args, fmt );
43                __cfaabi_bits_print_vararg( STDERR_FILENO, fmt, args );
44                va_end( args );
45
46                __cfaabi_bits_print_nolock( STDERR_FILENO, "\n" );
47                __cfaabi_bits_release();
48                abort();
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.