source: src/libcfa/libhdr/libdebug.h @ dd9b59e

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 dd9b59e was 6a5be52, checked in by Thierry Delisle <tdelisle@…>, 6 years ago

Modified waitfor to sort monitors

  • Property mode set to 100644
File size: 3.0 KB
Line 
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.
6//
7// libdebug.h --
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 : Sat Jul 22 10:02:24 2017
13// Update Count     : 1
14//
15
16#pragma once
17
18#ifdef __CFA_DEBUG__
19        #define LIB_DEBUG_DO(...) __VA_ARGS__
20        #define LIB_NO_DEBUG_DO(...)
21        #define DEBUG_CTX __PRETTY_FUNCTION__
22        #define DEBUG_CTX2 , __PRETTY_FUNCTION__
23        #define DEBUG_CTX_PARAM const char * caller
24        #define DEBUG_CTX_PARAM2 , const char * caller
25#else
26        #define LIB_DEBUG_DO(...)
27        #define LIB_NO_DEBUG_DO(...) __VA_ARGS__
28        #define DEBUG_CTX
29        #define DEBUG_CTX2
30        #define DEBUG_CTX_PARAM
31        #define DEBUG_CTX_PARAM2
32#endif
33
34#if !defined(NDEBUG) && (defined(__CFA_DEBUG__) || defined(__CFA_VERIFY__))
35        #define verify(x) assert(x)
36        #define verifyf(x, ...) assertf(x, __VA_ARGS__)
37#else
38        #define verify(x)
39        #define verifyf(x, ...)
40#endif
41
42
43#ifdef __cforall
44extern "C" {
45#endif
46        #include <stdarg.h>
47        #include <stdio.h>
48
49      extern void __lib_debug_write( const char *buffer, int len );
50      extern void __lib_debug_acquire();
51      extern void __lib_debug_release();
52      extern void __lib_debug_print_safe  ( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) ));
53      extern void __lib_debug_print_nolock( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) ));
54      extern void __lib_debug_print_vararg( const char fmt[], va_list arg );
55      extern void __lib_debug_print_buffer( char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format (printf, 3, 4) ));
56#ifdef __cforall
57}
58#endif
59
60#ifdef __CFA_DEBUG_PRINT__
61        #define LIB_DEBUG_WRITE( buffer, len )         __lib_debug_write( buffer, len )
62        #define LIB_DEBUG_ACQUIRE()                    __lib_debug_acquire()
63        #define LIB_DEBUG_RELEASE()                    __lib_debug_release()
64        #define LIB_DEBUG_PRINT_SAFE(...)              __lib_debug_print_safe   (__VA_ARGS__)
65        #define LIB_DEBUG_PRINT_NOLOCK(...)            __lib_debug_print_nolock (__VA_ARGS__)
66        #define LIB_DEBUG_PRINT_BUFFER(...)            __lib_debug_print_buffer (__VA_ARGS__)
67        #define LIB_DEBUG_PRINT_BUFFER_DECL(...)       char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __lib_debug_write( __dbg_text, __dbg_len );
68        #define LIB_DEBUG_PRINT_BUFFER_LOCAL(...)      __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __lib_debug_write( __dbg_text, __dbg_len );
69#else
70        #define LIB_DEBUG_WRITE(...)               ((void)0)
71        #define LIB_DEBUG_ACQUIRE()                ((void)0)
72        #define LIB_DEBUG_RELEASE()                ((void)0)
73        #define LIB_DEBUG_PRINT_SAFE(...)          ((void)0)
74        #define LIB_DEBUG_PRINT_NOLOCK(...)        ((void)0)
75        #define LIB_DEBUG_PRINT_BUFFER(...)        ((void)0)
76        #define LIB_DEBUG_PRINT_BUFFER_DECL(...)   ((void)0)
77        #define LIB_DEBUG_PRINT_BUFFER_LOCAL(...)  ((void)0)
78#endif
79
80// Local Variables: //
81// mode: c //
82// tab-width: 4 //
83// End: //
Note: See TracBrowser for help on using the repository browser.