aboutsummaryrefslogtreecommitdiffstats
path: root/src/debug.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/debug.h')
-rw-r--r--src/debug.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/debug.h b/src/debug.h
index 1883101..661c299 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -1,5 +1,5 @@
/*
- Copyright 2006,2007,2008 Martin Pärtel <martin.partel@gmail.com>
+ Copyright 2006,2007,2008,2012 Martin Pärtel <martin.partel@gmail.com>
This file is part of bindfs.
@@ -21,10 +21,20 @@
#define INC_BINDFS_DEBUG_H
#include <config.h>
+#include <string.h>
+#include <stdio.h>
+#include <pthread.h>
+
+/* Handier to lock and use strerror() than allocate buffer for strerror_r(). */
+extern pthread_mutex_t strerror_lock;
#if BINDFS_DEBUG
#include <stdio.h>
-#define DPRINTF(fmt, ...) fprintf(stderr, "DEBUG: " fmt "\n", __VA_ARGS__)
+#define DPRINTF(fmt, ...) do { \
+ pthread_mutex_lock(&strerror_lock); \
+ fprintf(stderr, "DEBUG: " fmt "\n", __VA_ARGS__); \
+ pthread_mutex_unlock(&strerror_lock); \
+ } while (0)
#else
#define DPRINTF(...)
#endif