summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri
diff options
context:
space:
mode:
authorPauli Nieminen <suokkos@gmail.com>2009-09-10 16:41:59 +0300
committerPauli Nieminen <suokkos@gmail.com>2009-09-10 16:53:08 +0300
commit3d1324a66a3b8927a400d167ba92f851b464c57a (patch)
tree5ae577a8900795f23021be6fa409d510f6a0f56c /src/mesa/drivers/dri
parent2b692cd6d6f42d4e7a7f8100383759d49a907f1d (diff)
radeon: Change debugging code to use macros instead of inline functions.
Variadic functions can't be inlined which makes debugging to have quite large function overead. Only aleternative method is to use variadic macros which are inlined so compiler can optimize debugging to minimize overhead.
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_debug.c10
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_debug.h60
2 files changed, 27 insertions, 43 deletions
diff --git a/src/mesa/drivers/dri/radeon/radeon_debug.c b/src/mesa/drivers/dri/radeon/radeon_debug.c
index a1ed39683f..3b6f003803 100644
--- a/src/mesa/drivers/dri/radeon/radeon_debug.c
+++ b/src/mesa/drivers/dri/radeon/radeon_debug.c
@@ -32,6 +32,9 @@
#include "radeon_debug.h"
#include "radeon_common_context.h"
+#include <stdarg.h>
+#include <stdio.h>
+
static const struct dri_debug_control debug_control[] = {
{"fall", RADEON_FALLBACKS},
{"tex", RADEON_TEXTURE},
@@ -85,10 +88,10 @@ void _radeon_debug_remove_indent(void)
}
}
-extern void _radeon_print(const radeon_debug_type_t type,
+void _radeon_print(const radeon_debug_type_t type,
const radeon_debug_level_t level,
const char* message,
- va_list values)
+ ...)
{
GET_CURRENT_CONTEXT(ctx);
if (ctx) {
@@ -97,5 +100,8 @@ extern void _radeon_print(const radeon_debug_type_t type,
if (radeon->debug.indent_depth)
fprintf(stderr, "%s", radeon->debug.indent);
}
+ va_list values;
+ va_start( values, message );
vfprintf(stderr, message, values);
+ va_end( values );
}
diff --git a/src/mesa/drivers/dri/radeon/radeon_debug.h b/src/mesa/drivers/dri/radeon/radeon_debug.h
index 132e27351d..2a8302293b 100644
--- a/src/mesa/drivers/dri/radeon/radeon_debug.h
+++ b/src/mesa/drivers/dri/radeon/radeon_debug.h
@@ -30,8 +30,7 @@
#ifndef RADEON_DEBUG_H_INCLUDED
#define RADEON_DEBUG_H_INCLUDED
-#include <stdarg.h>
-#include <stdio.h>
+#include <stdlib.h>
typedef enum radeon_debug_levels {
RADEON_CRITICAL = 0, /* Only errors */
@@ -102,57 +101,36 @@ static inline int radeon_is_debug_enabled(const radeon_debug_type_t type,
extern void _radeon_print(const radeon_debug_type_t type,
const radeon_debug_level_t level,
const char* message,
- va_list values);
-/**
- * Format attribute requires declaration for setting it. Don't ask me why!
- */
-static inline void radeon_print(const radeon_debug_type_t type,
- const radeon_debug_level_t level,
- const char* message,
- ...) __attribute__((format(printf,3,4)));
-
+ ...) __attribute__((format(printf,3,4)));
/**
* Print out debug message if channel specified by type is enabled
* and compile time debugging level is at least as high as level parameter
*/
-static inline void radeon_print(const radeon_debug_type_t type,
- const radeon_debug_level_t level,
- const char* message,
- ...)
-{
- /* Compile out if level of message is too high */
- if (radeon_is_debug_enabled(type, level)) {
-
- va_list values;
- va_start( values, message );
- _radeon_print(type, level, message, values);
- va_end( values );
- }
-}
+#define radeon_print(type, level, message, ...) do { \
+ const radeon_debug_level_t _debug_level = (level); \
+ const radeon_debug_type_t _debug_type = (type); \
+ /* Compile out if level of message is too high */ \
+ if (radeon_is_debug_enabled(type, level)) { \
+ _radeon_print(_debug_type, _debug_level, \
+ (message), ## __VA_ARGS__); \
+ } \
+} while(0)
-static inline void radeon_error(const char* message, ...) __attribute__((format(printf,1,2)));
/**
* printf style function for writing error messages.
*/
-static inline void radeon_error(const char* message, ...)
-{
- va_list values;
- va_start( values, message );
- radeon_print(RADEON_GENERAL, RADEON_CRITICAL, message, values);
- va_end( values );
-}
+#define radeon_error(message, ...) do { \
+ radeon_print(RADEON_GENERAL, RADEON_CRITICAL, \
+ (message), ## __VA_ARGS__); \
+} while(0)
-static inline void radeon_warning(const char* message, ...) __attribute__((format(printf,1,2)));
/**
* printf style function for writing warnings.
*/
-static inline void radeon_warning(const char* message, ...)
-{
- va_list values;
- va_start( values, message );
- radeon_print(RADEON_GENERAL, RADEON_IMPORTANT, message, values);
- va_end( values );
-}
+#define radeon_warning(message, ...) do { \
+ radeon_print(RADEON_GENERAL, RADEON_IMPORTANT, \
+ (message), ## __VA_ARGS__); \
+} while(0)
extern void radeon_init_debug(void);
extern void _radeon_debug_add_indent(void);