sl@0
|
1 |
/*
|
sl@0
|
2 |
* LIBOIL - Library of Optimized Inner Loops
|
sl@0
|
3 |
* Copyright (c) 2003,2004 David A. Schleef <ds@schleef.org>
|
sl@0
|
4 |
* All rights reserved.
|
sl@0
|
5 |
*
|
sl@0
|
6 |
* Redistribution and use in source and binary forms, with or without
|
sl@0
|
7 |
* modification, are permitted provided that the following conditions
|
sl@0
|
8 |
* are met:
|
sl@0
|
9 |
* 1. Redistributions of source code must retain the above copyright
|
sl@0
|
10 |
* notice, this list of conditions and the following disclaimer.
|
sl@0
|
11 |
* 2. Redistributions in binary form must reproduce the above copyright
|
sl@0
|
12 |
* notice, this list of conditions and the following disclaimer in the
|
sl@0
|
13 |
* documentation and/or other materials provided with the distribution.
|
sl@0
|
14 |
*
|
sl@0
|
15 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
sl@0
|
16 |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
sl@0
|
17 |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
sl@0
|
18 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
sl@0
|
19 |
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
sl@0
|
20 |
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
sl@0
|
21 |
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
sl@0
|
22 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
sl@0
|
23 |
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
sl@0
|
24 |
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
sl@0
|
25 |
* POSSIBILITY OF SUCH DAMAGE.
|
sl@0
|
26 |
*/
|
sl@0
|
27 |
|
sl@0
|
28 |
#ifndef _LIBOIL_DEBUG_H_
|
sl@0
|
29 |
#define _LIBOIL_DEBUG_H_
|
sl@0
|
30 |
|
sl@0
|
31 |
#include <stdarg.h>
|
sl@0
|
32 |
#include <liboil/liboilutils.h>
|
sl@0
|
33 |
|
sl@0
|
34 |
OIL_BEGIN_DECLS
|
sl@0
|
35 |
|
sl@0
|
36 |
#ifdef OIL_ENABLE_UNSTABLE_API
|
sl@0
|
37 |
|
sl@0
|
38 |
/**
|
sl@0
|
39 |
* OilDebugPrintFunc:
|
sl@0
|
40 |
* @level: the debug level
|
sl@0
|
41 |
* @file: name of the file where the debug message occurs
|
sl@0
|
42 |
* @func: name of the function where the debug message occurs
|
sl@0
|
43 |
* @line: line in the file where the debug message occurs
|
sl@0
|
44 |
* @format: a printf format
|
sl@0
|
45 |
* @varargs: varargs for the printf format
|
sl@0
|
46 |
*
|
sl@0
|
47 |
* Typedef describing functions that can be registered using
|
sl@0
|
48 |
* oil_debug_set_print_function() so that it is called to
|
sl@0
|
49 |
* print debugging messages.
|
sl@0
|
50 |
*/
|
sl@0
|
51 |
typedef void (*OilDebugPrintFunc) (int level, const char *file,
|
sl@0
|
52 |
const char *func, int line, const char *format, va_list varargs);
|
sl@0
|
53 |
|
sl@0
|
54 |
/**
|
sl@0
|
55 |
* OilDebugLevel:
|
sl@0
|
56 |
*
|
sl@0
|
57 |
* Enumeration describing debug levels in Liboil.
|
sl@0
|
58 |
*/
|
sl@0
|
59 |
typedef enum {
|
sl@0
|
60 |
OIL_DEBUG_NONE = 0,
|
sl@0
|
61 |
OIL_DEBUG_ERROR,
|
sl@0
|
62 |
OIL_DEBUG_WARNING,
|
sl@0
|
63 |
OIL_DEBUG_INFO,
|
sl@0
|
64 |
OIL_DEBUG_DEBUG,
|
sl@0
|
65 |
OIL_DEBUG_LOG
|
sl@0
|
66 |
} OilDebugLevel;
|
sl@0
|
67 |
|
sl@0
|
68 |
/**
|
sl@0
|
69 |
* OIL_ERROR:
|
sl@0
|
70 |
*
|
sl@0
|
71 |
* Macro to call OIL_DEBUG_PRINT() with a level of #OIL_DEBUG_ERROR.
|
sl@0
|
72 |
*/
|
sl@0
|
73 |
#define OIL_ERROR(args...) OIL_DEBUG_PRINT(OIL_DEBUG_ERROR, ##args)
|
sl@0
|
74 |
/**
|
sl@0
|
75 |
* OIL_WARNING:
|
sl@0
|
76 |
*
|
sl@0
|
77 |
* Macro to call OIL_DEBUG_PRINT() with a level of #OIL_DEBUG_WARNING.
|
sl@0
|
78 |
*/
|
sl@0
|
79 |
#define OIL_WARNING(args...) OIL_DEBUG_PRINT(OIL_DEBUG_WARNING, ##args)
|
sl@0
|
80 |
/**
|
sl@0
|
81 |
* OIL_INFO:
|
sl@0
|
82 |
*
|
sl@0
|
83 |
* Macro to call OIL_DEBUG_PRINT() with a level of #OIL_DEBUG_INFO.
|
sl@0
|
84 |
*/
|
sl@0
|
85 |
#define OIL_INFO(args...) OIL_DEBUG_PRINT(OIL_DEBUG_INFO, ##args)
|
sl@0
|
86 |
/**
|
sl@0
|
87 |
* OIL_DEBUG:
|
sl@0
|
88 |
*
|
sl@0
|
89 |
* Macro to call OIL_DEBUG_PRINT() with a level of #OIL_DEBUG_DEBUG.
|
sl@0
|
90 |
*/
|
sl@0
|
91 |
#define OIL_DEBUG(args...) OIL_DEBUG_PRINT(OIL_DEBUG_DEBUG, ##args)
|
sl@0
|
92 |
/**
|
sl@0
|
93 |
* OIL_LOG:
|
sl@0
|
94 |
*
|
sl@0
|
95 |
* Macro to call OIL_DEBUG_PRINT() with a level of #OIL_DEBUG_LOG.
|
sl@0
|
96 |
*/
|
sl@0
|
97 |
#define OIL_LOG(args...) OIL_DEBUG_PRINT(OIL_DEBUG_LOG, ##args)
|
sl@0
|
98 |
|
sl@0
|
99 |
/**
|
sl@0
|
100 |
* OIL_FUNCTION:
|
sl@0
|
101 |
*
|
sl@0
|
102 |
* Internal macro that points to __PRETTY_FUNCTION__ or __func__
|
sl@0
|
103 |
* if the former is not available.
|
sl@0
|
104 |
*/
|
sl@0
|
105 |
#if defined (__GNUC__) || defined (__PRETTY_FUNCTION__)
|
sl@0
|
106 |
#define OIL_FUNCTION __PRETTY_FUNCTION__
|
sl@0
|
107 |
#elif defined(__func__)
|
sl@0
|
108 |
#define OIL_FUNCTION __func__
|
sl@0
|
109 |
#else
|
sl@0
|
110 |
#define OIL_FUNCTION ""
|
sl@0
|
111 |
#endif
|
sl@0
|
112 |
|
sl@0
|
113 |
/**
|
sl@0
|
114 |
* OIL_DEBUG_PRINT:
|
sl@0
|
115 |
* @level:
|
sl@0
|
116 |
* @...:
|
sl@0
|
117 |
*
|
sl@0
|
118 |
* Macro to call oil_debug_print() with the correct values for
|
sl@0
|
119 |
* the name of the source file, line of source file, and function.
|
sl@0
|
120 |
*/
|
sl@0
|
121 |
#define OIL_DEBUG_PRINT(level, args...) do { \
|
sl@0
|
122 |
oil_debug_print((level), __FILE__, OIL_FUNCTION, __LINE__, ##args); \
|
sl@0
|
123 |
}while(0)
|
sl@0
|
124 |
|
sl@0
|
125 |
IMPORT_C void oil_debug_set_print_function (OilDebugPrintFunc func);
|
sl@0
|
126 |
IMPORT_C int oil_debug_get_level (void);
|
sl@0
|
127 |
IMPORT_C void oil_debug_set_level (int level);
|
sl@0
|
128 |
|
sl@0
|
129 |
void _oil_debug_init (void);
|
sl@0
|
130 |
|
sl@0
|
131 |
IMPORT_C void oil_debug_print (int level, const char *file, const char *func,
|
sl@0
|
132 |
int line, const char *format, ...);
|
sl@0
|
133 |
|
sl@0
|
134 |
#endif
|
sl@0
|
135 |
|
sl@0
|
136 |
OIL_END_DECLS
|
sl@0
|
137 |
|
sl@0
|
138 |
#endif
|
sl@0
|
139 |
|