4 #include "git-compat-util.h"
8 const char * const key
;
10 unsigned int initialized
: 1;
11 unsigned int need_close
: 1;
14 #define TRACE_KEY_INIT(name) { "GIT_TRACE_" #name, 0, 0, 0 }
16 extern void trace_repo_setup(const char *prefix
);
17 extern int trace_want(struct trace_key
*key
);
18 extern void trace_disable(struct trace_key
*key
);
19 extern uint64_t getnanotime(void);
21 #ifndef HAVE_VARIADIC_MACROS
23 __attribute__((format (printf
, 1, 2)))
24 extern void trace_printf(const char *format
, ...);
26 __attribute__((format (printf
, 2, 3)))
27 extern void trace_printf_key(struct trace_key
*key
, const char *format
, ...);
29 __attribute__((format (printf
, 2, 3)))
30 extern void trace_argv_printf(const char **argv
, const char *format
, ...);
32 extern void trace_strbuf(struct trace_key
*key
, const struct strbuf
*data
);
37 * Macros to add file:line - see above for C-style declarations of how these
42 * TRACE_CONTEXT may be set to __FUNCTION__ if the compiler supports it. The
43 * default is __FILE__, as it is consistent with assert(), and static function
44 * names are not necessarily unique.
46 * __FILE__ ":" __FUNCTION__ doesn't work with GNUC, as __FILE__ is supplied
47 * by the preprocessor as a string literal, and __FUNCTION__ is filled in by
48 * the compiler as a string constant.
51 # define TRACE_CONTEXT __FILE__
55 * Note: with C99 variadic macros, __VA_ARGS__ must include the last fixed
56 * parameter ('format' in this case). Otherwise, a call without variable
57 * arguments will have a surplus ','. E.g.:
59 * #define foo(format, ...) bar(format, __VA_ARGS__)
66 * which is invalid (note the ',)'). With GNUC, '##__VA_ARGS__' drops the
67 * comma, but this is non-standard.
70 #define trace_printf(...) \
71 trace_printf_key_fl(TRACE_CONTEXT, __LINE__, NULL, __VA_ARGS__)
73 #define trace_printf_key(key, ...) \
74 trace_printf_key_fl(TRACE_CONTEXT, __LINE__, key, __VA_ARGS__)
76 #define trace_argv_printf(argv, ...) \
77 trace_argv_printf_fl(TRACE_CONTEXT, __LINE__, argv, __VA_ARGS__)
79 #define trace_strbuf(key, data) \
80 trace_strbuf_fl(TRACE_CONTEXT, __LINE__, key, data)
82 /* backend functions, use non-*fl macros instead */
83 __attribute__((format (printf
, 4, 5)))
84 extern void trace_printf_key_fl(const char *file
, int line
, struct trace_key
*key
,
85 const char *format
, ...);
86 __attribute__((format (printf
, 4, 5)))
87 extern void trace_argv_printf_fl(const char *file
, int line
, const char **argv
,
88 const char *format
, ...);
89 extern void trace_strbuf_fl(const char *file
, int line
, struct trace_key
*key
,
90 const struct strbuf
*data
);
92 #endif /* HAVE_VARIADIC_MACROS */