| [a922e34] | 1 | // | 
|---|
|  | 2 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo | 
|---|
|  | 3 | // | 
|---|
|  | 4 | // The contents of this file are covered under the licence agreement in the | 
|---|
|  | 5 | // file "LICENCE" distributed with Cforall. | 
|---|
| [0cf5b79] | 6 | // | 
|---|
|  | 7 | // assert.h -- | 
|---|
|  | 8 | // | 
|---|
| [a922e34] | 9 | // Author           : Peter A. Buhr | 
|---|
|  | 10 | // Created On       : Mon Jul  4 23:25:26 2016 | 
|---|
|  | 11 | // Last Modified By : Peter A. Buhr | 
|---|
| [301071a] | 12 | // Last Modified On : Sun Oct  9 21:28:22 2022 | 
|---|
|  | 13 | // Update Count     : 16 | 
|---|
| [0cf5b79] | 14 | // | 
|---|
| [a922e34] | 15 |  | 
|---|
| [0cf5b79] | 16 | #ifdef __cforall | 
|---|
| [a922e34] | 17 | extern "C" { | 
|---|
| [0cf5b79] | 18 | #endif //__cforall | 
|---|
| [d9c44c3] | 19 |  | 
|---|
|  | 20 | #include_next <assert.h> | 
|---|
|  | 21 |  | 
|---|
| [dfa66dc] | 22 | #ifdef NDEBUG | 
|---|
| [921fe6a] | 23 | #define assertf( expr, fmt, ... ) ((void)0) | 
|---|
| [dfa66dc] | 24 | #else | 
|---|
|  | 25 | #define __STRINGIFY__(str) #str | 
|---|
|  | 26 | #define __VSTRINGIFY__(str) __STRINGIFY__(str) | 
|---|
| [d6c1dd0] | 27 | #define assertf( expr, fmt, ... ) ((expr) ? ((void)0) : __assert_fail_f(__VSTRINGIFY__(expr), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, ## __VA_ARGS__ )) | 
|---|
|  | 28 |  | 
|---|
| [77125cc] | 29 | void __assert_warn_f( const char assertion[], const char file[], unsigned int line, const char function[], const char fmt[], ... ) __attribute__((format( printf, 5, 6) )); | 
|---|
| [e3fea42] | 30 | void __assert_fail_f( const char assertion[], const char file[], unsigned int line, const char function[], const char fmt[], ... ) __attribute__((noreturn, format( printf, 5, 6) )); | 
|---|
| [dfa66dc] | 31 | #endif | 
|---|
|  | 32 |  | 
|---|
| [301071a] | 33 | #if ! defined(NDEBUG) && (defined(__CFA_DEBUG__) || defined(__CFA_VERIFY__)) | 
|---|
| [77125cc] | 34 | #define __CFA_WITH_VERIFY__ | 
|---|
| [36982fc] | 35 | #define verify(x) assert(x) | 
|---|
|  | 36 | #define verifyf(x, ...) assertf(x, __VA_ARGS__) | 
|---|
| [dca5802] | 37 | #define verifyfail(...) | 
|---|
| [77125cc] | 38 | #define warnf( expr, fmt, ... ) ({ static bool check_once##__LINE__ = false; if( false == check_once##__LINE__ && false == (expr)) { check_once##__LINE__ = true; __assert_warn_f(__VSTRINGIFY__(expr), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, ## __VA_ARGS__ ); } }) | 
|---|
| [36982fc] | 39 | #else | 
|---|
|  | 40 | #define verify(x) | 
|---|
|  | 41 | #define verifyf(x, ...) | 
|---|
| [dca5802] | 42 | #define verifyfail(...) | 
|---|
| [77125cc] | 43 | #define warnf( expr, fmt, ... ) | 
|---|
| [36982fc] | 44 | #endif | 
|---|
|  | 45 |  | 
|---|
| [0cf5b79] | 46 | #ifdef __cforall | 
|---|
| [a922e34] | 47 | } // extern "C" | 
|---|
| [0cf5b79] | 48 | #endif //__cforall | 
|---|
| [a922e34] | 49 |  | 
|---|
|  | 50 | // Local Variables: // | 
|---|
|  | 51 | // tab-width: 4 // | 
|---|
|  | 52 | // mode: c++ // | 
|---|
|  | 53 | // compile-command: "make install" // | 
|---|
|  | 54 | // End: // | 
|---|