summaryrefslogtreecommitdiffstats
path: root/pcilib/debug.h
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2015-05-08 20:06:36 +0200
committerSuren A. Chilingaryan <csa@suren.me>2015-05-08 20:06:36 +0200
commit79d9b2924d7b67ba08e022792adb92770f64e0c8 (patch)
treedc2ce5058978bfe88de1613291f21aa2ca7d9b0c /pcilib/debug.h
parenta1889bc2f45b3d944652be6436569980f189922d (diff)
downloadpcitool-79d9b2924d7b67ba08e022792adb92770f64e0c8.tar.gz
pcitool-79d9b2924d7b67ba08e022792adb92770f64e0c8.tar.bz2
pcitool-79d9b2924d7b67ba08e022792adb92770f64e0c8.tar.xz
pcitool-79d9b2924d7b67ba08e022792adb92770f64e0c8.zip
Prevent excessive calling of getenv by debugging code for better performance
Diffstat (limited to 'pcilib/debug.h')
-rw-r--r--pcilib/debug.h10
1 files changed, 6 insertions, 4 deletions
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 <stdarg.h>
+#include <pcilib/env.h>
#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