From 79d9b2924d7b67ba08e022792adb92770f64e0c8 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Fri, 8 May 2015 20:06:36 +0200 Subject: Prevent excessive calling of getenv by debugging code for better performance --- pcilib/debug.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'pcilib/debug.h') diff --git a/pcilib/debug.h b/pcilib/debug.h index bff3ab0..ec10467 100644 --- a/pcilib/debug.h +++ b/pcilib/debug.h @@ -2,6 +2,7 @@ #define _PCILIB_DEBUG_H #include +#include #define PCILIB_DEBUG @@ -12,16 +13,16 @@ #ifdef PCILIB_DEBUG_DMA -# define PCILIB_DEBUG_DMA_MESSAGE(function, ...) pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__) -# define PCILIB_DEBUG_DMA_BUFFER(function, ...) pcilib_debug_data_buffer (#function, __VA_ARGS__) +# define PCILIB_DEBUG_DMA_MESSAGE(function, ...) if (pcilib_getenv(function##_ENV, #function)) { pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__); } +# define PCILIB_DEBUG_DMA_BUFFER(function, ...) if (pcilib_getenv(function##_ENV, #function)) { pcilib_debug_data_buffer (#function, __VA_ARGS__); } #else /* PCILIB_DEBUG_DMA */ # define PCILIB_DEBUG_DMA_MESSAGE(function, ...) # define PCILIB_DEBUG_DMA_BUFFER(function, ...) #endif /* PCILIB_DEBUG_DMA */ #ifdef PCILIB_DEBUG_MISSING_EVENTS -# define PCILIB_DEBUG_MISSING_EVENTS_MESSAGE(function, ...) pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__) -# define PCILIB_DEBUG_MISSING_EVENTS_BUFFER(function, ...) pcilib_debug_data_buffer (#function, __VA_ARGS__) +# define PCILIB_DEBUG_MISSING_EVENTS_MESSAGE(function, ...) if (pcilib_getenv(function##_ENV, #function)) { pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__); } +# define PCILIB_DEBUG_MISSING_EVENTS_BUFFER(function, ...) if (pcilib_getenv(function##_ENV #function)) { pcilib_debug_data_buffer (#function, __VA_ARGS__); } #else /* PCILIB_DEBUG_MISSING_EVENTS */ # define PCILIB_DEBUG_MISSING_EVENTS_MESSAGE(function, ...) # define PCILIB_DEBUG_MISSING_EVENTS_BUFFER(function, ...) @@ -33,6 +34,7 @@ #define pcilib_debug_buffer(function, ...) \ PCILIB_DEBUG_##function##_BUFFER(PCILIB_DEBUG_##function, __VA_ARGS__) + typedef enum { PCILIB_DEBUG_BUFFER_APPEND = 1, PCILIB_DEBUG_BUFFER_MKDIR = 2 -- cgit v1.2.3