]> git.vpit.fr Git - perl/modules/indirect.git/blobdiff - xsh/debug.h
The Big Boilerplate Factorization
[perl/modules/indirect.git] / xsh / debug.h
diff --git a/xsh/debug.h b/xsh/debug.h
new file mode 100644 (file)
index 0000000..707c760
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef XSH_DEBUG_H
+#define XSH_DEBUG_H 1
+
+#include "util.h" /* XSH_PACKAGE, STMT_* */
+
+#ifndef XSH_DEBUG
+# define XSH_DEBUG 0
+#endif
+
+#if XSH_DEBUG
+# define XSH_D(X) STMT_START X STMT_END
+static void xsh_debug_log(const char *fmt, ...) {
+ va_list va;
+ SV *sv;
+ dTHX;
+ va_start(va, fmt);
+ sv = get_sv(XSH_PACKAGE "::DEBUG", 0);
+ if (sv && SvTRUE(sv))
+  PerlIO_vprintf(Perl_debug_log, fmt, va);
+ va_end(va);
+ return;
+}
+#else
+# define XSH_D(X)
+#endif
+
+#endif /* XSH_DEBUG_H */