/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to pcilib/debug.h

  • Committer: Suren A. Chilingaryan
  • Date: 2015-05-08 18:06:36 UTC
  • Revision ID: csa@suren.me-20150508180636-x3vsolbme4uot0ox
Prevent excessive calling of getenv by debugging code for better performance

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
#define _PCILIB_DEBUG_H
3
3
 
4
4
#include <stdarg.h>
 
5
#include <pcilib/env.h>
5
6
 
6
7
#define PCILIB_DEBUG
7
8
 
12
13
 
13
14
 
14
15
#ifdef PCILIB_DEBUG_DMA
15
 
# define PCILIB_DEBUG_DMA_MESSAGE(function, ...) pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__) 
16
 
# define PCILIB_DEBUG_DMA_BUFFER(function, ...) pcilib_debug_data_buffer (#function, __VA_ARGS__) 
 
16
# define PCILIB_DEBUG_DMA_MESSAGE(function, ...) if (pcilib_getenv(function##_ENV, #function)) { pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__); }
 
17
# define PCILIB_DEBUG_DMA_BUFFER(function, ...) if (pcilib_getenv(function##_ENV, #function)) { pcilib_debug_data_buffer (#function, __VA_ARGS__); }
17
18
#else /* PCILIB_DEBUG_DMA */
18
19
# define PCILIB_DEBUG_DMA_MESSAGE(function, ...)
19
20
# define PCILIB_DEBUG_DMA_BUFFER(function, ...)
20
21
#endif /* PCILIB_DEBUG_DMA */
21
22
 
22
23
#ifdef PCILIB_DEBUG_MISSING_EVENTS
23
 
# define PCILIB_DEBUG_MISSING_EVENTS_MESSAGE(function, ...) pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__) 
24
 
# define PCILIB_DEBUG_MISSING_EVENTS_BUFFER(function, ...) pcilib_debug_data_buffer (#function, __VA_ARGS__) 
 
24
# define PCILIB_DEBUG_MISSING_EVENTS_MESSAGE(function, ...) if (pcilib_getenv(function##_ENV, #function)) { pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__); }
 
25
# define PCILIB_DEBUG_MISSING_EVENTS_BUFFER(function, ...) if (pcilib_getenv(function##_ENV #function)) { pcilib_debug_data_buffer (#function, __VA_ARGS__); }
25
26
#else /* PCILIB_DEBUG_MISSING_EVENTS */
26
27
# define PCILIB_DEBUG_MISSING_EVENTS_MESSAGE(function, ...)
27
28
# define PCILIB_DEBUG_MISSING_EVENTS_BUFFER(function, ...)
33
34
#define pcilib_debug_buffer(function, ...) \
34
35
    PCILIB_DEBUG_##function##_BUFFER(PCILIB_DEBUG_##function, __VA_ARGS__)
35
36
 
 
37
 
36
38
typedef enum {
37
39
    PCILIB_DEBUG_BUFFER_APPEND = 1,
38
40
    PCILIB_DEBUG_BUFFER_MKDIR = 2