This source file includes following definitions.
- hwloc_debug_enabled
- hwloc_debug
1
2
3
4
5
6
7
8
9
10
11 #ifndef HWLOC_DEBUG_H
12 #define HWLOC_DEBUG_H
13
14 #include <private/autogen/config.h>
15 #include <private/misc.h>
16
17 #ifdef HWLOC_DEBUG
18 #include <stdarg.h>
19 #include <stdio.h>
20 #endif
21
22
23 #define HWLOC_BUILD_ASSERT(condition) ((void)sizeof(char[1 - 2*!(condition)]))
24
25 #ifdef HWLOC_DEBUG
26 static __hwloc_inline int hwloc_debug_enabled(void)
27 {
28 static int checked = 0;
29 static int enabled = 1;
30 if (!checked) {
31 const char *env = getenv("HWLOC_DEBUG_VERBOSE");
32 if (env)
33 enabled = atoi(env);
34 if (enabled)
35 fprintf(stderr, "hwloc verbose debug enabled, may be disabled with HWLOC_DEBUG_VERBOSE=0 in the environment.\n");
36 checked = 1;
37 }
38 return enabled;
39 }
40 #endif
41
42 static __hwloc_inline void hwloc_debug(const char *s __hwloc_attribute_unused, ...) __hwloc_attribute_format(printf, 1, 2);
43 static __hwloc_inline void hwloc_debug(const char *s __hwloc_attribute_unused, ...)
44 {
45 #ifdef HWLOC_DEBUG
46 if (hwloc_debug_enabled()) {
47 va_list ap;
48 va_start(ap, s);
49 vfprintf(stderr, s, ap);
50 va_end(ap);
51 }
52 #endif
53 }
54
55 #ifdef HWLOC_DEBUG
56 #define hwloc_debug_bitmap(fmt, bitmap) do { \
57 if (hwloc_debug_enabled()) { \
58 char *s; \
59 hwloc_bitmap_asprintf(&s, bitmap); \
60 fprintf(stderr, fmt, s); \
61 free(s); \
62 } } while (0)
63 #define hwloc_debug_1arg_bitmap(fmt, arg1, bitmap) do { \
64 if (hwloc_debug_enabled()) { \
65 char *s; \
66 hwloc_bitmap_asprintf(&s, bitmap); \
67 fprintf(stderr, fmt, arg1, s); \
68 free(s); \
69 } } while (0)
70 #define hwloc_debug_2args_bitmap(fmt, arg1, arg2, bitmap) do { \
71 if (hwloc_debug_enabled()) { \
72 char *s; \
73 hwloc_bitmap_asprintf(&s, bitmap); \
74 fprintf(stderr, fmt, arg1, arg2, s); \
75 free(s); \
76 } } while (0)
77 #else
78 #define hwloc_debug_bitmap(s, bitmap) do { } while(0)
79 #define hwloc_debug_1arg_bitmap(s, arg1, bitmap) do { } while(0)
80 #define hwloc_debug_2args_bitmap(s, arg1, arg2, bitmap) do { } while(0)
81 #endif
82
83 #endif