Update contrib.
2 * LIBOIL - Library of Optimized Inner Loops
3 * Copyright (c) 2003,2004 David A. Schleef <ds@schleef.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
28 #ifndef _LIBOIL_DEBUG_H_
29 #define _LIBOIL_DEBUG_H_
32 #include <liboil/liboilutils.h>
36 #ifdef OIL_ENABLE_UNSTABLE_API
40 * @level: the debug level
41 * @file: name of the file where the debug message occurs
42 * @func: name of the function where the debug message occurs
43 * @line: line in the file where the debug message occurs
44 * @format: a printf format
45 * @varargs: varargs for the printf format
47 * Typedef describing functions that can be registered using
48 * oil_debug_set_print_function() so that it is called to
49 * print debugging messages.
51 typedef void (*OilDebugPrintFunc) (int level, const char *file,
52 const char *func, int line, const char *format, va_list varargs);
57 * Enumeration describing debug levels in Liboil.
71 * Macro to call OIL_DEBUG_PRINT() with a level of #OIL_DEBUG_ERROR.
73 #define OIL_ERROR(args...) OIL_DEBUG_PRINT(OIL_DEBUG_ERROR, ##args)
77 * Macro to call OIL_DEBUG_PRINT() with a level of #OIL_DEBUG_WARNING.
79 #define OIL_WARNING(args...) OIL_DEBUG_PRINT(OIL_DEBUG_WARNING, ##args)
83 * Macro to call OIL_DEBUG_PRINT() with a level of #OIL_DEBUG_INFO.
85 #define OIL_INFO(args...) OIL_DEBUG_PRINT(OIL_DEBUG_INFO, ##args)
89 * Macro to call OIL_DEBUG_PRINT() with a level of #OIL_DEBUG_DEBUG.
91 #define OIL_DEBUG(args...) OIL_DEBUG_PRINT(OIL_DEBUG_DEBUG, ##args)
95 * Macro to call OIL_DEBUG_PRINT() with a level of #OIL_DEBUG_LOG.
97 #define OIL_LOG(args...) OIL_DEBUG_PRINT(OIL_DEBUG_LOG, ##args)
102 * Internal macro that points to __PRETTY_FUNCTION__ or __func__
103 * if the former is not available.
105 #if defined (__GNUC__) || defined (__PRETTY_FUNCTION__)
106 #define OIL_FUNCTION __PRETTY_FUNCTION__
107 #elif defined(__func__)
108 #define OIL_FUNCTION __func__
110 #define OIL_FUNCTION ""
118 * Macro to call oil_debug_print() with the correct values for
119 * the name of the source file, line of source file, and function.
121 #define OIL_DEBUG_PRINT(level, args...) do { \
122 oil_debug_print((level), __FILE__, OIL_FUNCTION, __LINE__, ##args); \
125 IMPORT_C void oil_debug_set_print_function (OilDebugPrintFunc func);
126 IMPORT_C int oil_debug_get_level (void);
127 IMPORT_C void oil_debug_set_level (int level);
129 void _oil_debug_init (void);
131 IMPORT_C void oil_debug_print (int level, const char *file, const char *func,
132 int line, const char *format, ...);