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

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 ef6851a was 2ac095d, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

Added macros for parameters only present in debug

  • Property mode set to 100644
File size: 3.1 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 : Thierry Delisle
12// Last Modified On : Mon Nov 28 12:27:26 2016
13// Update Count     : 0
14//
15
16#ifndef __LIB_DEBUG_H__
17#define __LIB_DEBUG_H__
18
19#ifdef __CFA_DEBUG__
20        #define LIB_DEBUG_DO(...) __VA_ARGS__
21        #define LIB_NO_DEBUG_DO(...)
22        #define DEBUG_CTX __PRETTY_FUNCTION__
23        #define DEBUG_CTX2 , __PRETTY_FUNCTION__
24        #define DEBUG_CTX_PARAM const char * caller
25        #define DEBUG_CTX_PARAM2 , const char * caller
26#else
27        #define LIB_DEBUG_DO(...)
28        #define LIB_NO_DEBUG_DO(...) __VA_ARGS__
29        #define DEBUG_CTX
30        #define DEBUG_CTX2
31        #define DEBUG_CTX_PARAM
32        #define DEBUG_CTX_PARAM2
33#endif
34
35#if !defined(NDEBUG) && (defined(__CFA_DEBUG__) || defined(__CFA_VERIFY__))
36        #define verify(x) assert(x)
37        #define verifyf(x, ...) assertf(x, __VA_ARGS__)
38#else
39        #define verify(x)
40        #define verifyf(x, ...)
41#endif
42
43
44#ifdef __cforall
45extern "C" {
46#endif
47      #include <stdarg.h>
48
49      extern void __lib_debug_write( int fd, 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( fd, buffer, len )     __lib_debug_write( fd, 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(fd, ...)   char text[256]; int len = snprintf( text, 256, __VA_ARGS__ ); __lib_debug_write( fd, text, len );
68        #define LIB_DEBUG_PRINT_BUFFER_LOCAL(fd, ...)  len = snprintf( text, 256, __VA_ARGS__ ); __lib_debug_write( fd, text, 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#endif //__LIB_DEBUG_H__
81
82// Local Variables: //
83// mode: c //
84// tab-width: 4 //
85// End: //
Note: See TracBrowser for help on using the repository browser.