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(x) x
|
---|
21 | #define LIB_NO_DEBUG_DO(x) ((void)0)
|
---|
22 | #else
|
---|
23 | #define LIB_DEBUG_DO(x) ((void)0)
|
---|
24 | #define LIB_NO_DEBUG_DO(x) x
|
---|
25 | #endif
|
---|
26 |
|
---|
27 | #if !defined(NDEBUG) && (defined(__CFA_DEBUG__) || defined(__CFA_VERIFY__))
|
---|
28 | #define verify(x) assert(x)
|
---|
29 | #define verifyf(x, ...) assertf(x, __VA_ARGS__)
|
---|
30 | #else
|
---|
31 | #define verify(x)
|
---|
32 | #define verifyf(x, ...)
|
---|
33 | #endif
|
---|
34 |
|
---|
35 |
|
---|
36 | #ifdef __cforall
|
---|
37 | extern "C" {
|
---|
38 | #endif
|
---|
39 | #include <stdarg.h>
|
---|
40 |
|
---|
41 | extern void __lib_debug_write( int fd, const char *buffer, int len );
|
---|
42 | extern void __lib_debug_acquire();
|
---|
43 | extern void __lib_debug_release();
|
---|
44 | extern void __lib_debug_print_safe ( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) ));
|
---|
45 | extern void __lib_debug_print_nolock( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) ));
|
---|
46 | extern void __lib_debug_print_vararg( const char fmt[], va_list arg );
|
---|
47 | extern void __lib_debug_print_buffer( char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format (printf, 3, 4) ));
|
---|
48 | #ifdef __cforall
|
---|
49 | }
|
---|
50 | #endif
|
---|
51 |
|
---|
52 | #ifdef __CFA_DEBUG_PRINT__
|
---|
53 | #define LIB_DEBUG_WRITE( fd, buffer, len ) __lib_debug_write( fd, buffer, len )
|
---|
54 | #define LIB_DEBUG_ACQUIRE() __lib_debug_acquire()
|
---|
55 | #define LIB_DEBUG_RELEASE() __lib_debug_release()
|
---|
56 | #define LIB_DEBUG_PRINT_SAFE(...) __lib_debug_print_safe (__VA_ARGS__)
|
---|
57 | #define LIB_DEBUG_PRINT_NOLOCK(...) __lib_debug_print_nolock (__VA_ARGS__)
|
---|
58 | #define LIB_DEBUG_PRINT_BUFFER(...) __lib_debug_print_buffer (__VA_ARGS__)
|
---|
59 | #else
|
---|
60 | #define LIB_DEBUG_WRITE(...) ((void)0)
|
---|
61 | #define LIB_DEBUG_ACQUIRE() ((void)0)
|
---|
62 | #define LIB_DEBUG_RELEASE() ((void)0)
|
---|
63 | #define LIB_DEBUG_PRINT_SAFE(...) ((void)0)
|
---|
64 | #define LIB_DEBUG_PRINT_NOLOCK(...) ((void)0)
|
---|
65 | #define LIB_DEBUG_PRINT_BUFFER(...) ((void)0)
|
---|
66 | #endif
|
---|
67 |
|
---|
68 | #endif //__LIB_DEBUG_H__
|
---|
69 |
|
---|
70 | // Local Variables: //
|
---|
71 | // mode: c //
|
---|
72 | // tab-width: 4 //
|
---|
73 | // End: //
|
---|