summaryrefslogtreecommitdiff
path: root/src/wrapper
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-02-25 15:25:56 +0200
committerJari Vetoniemi <mailroxas@gmail.com>2018-02-25 15:25:56 +0200
commitb3c841834bc4edfb78ad32cad58fb1d69e5beb4d (patch)
tree9157ce090d0ce5372def069ba97fcaa56d2cddb1 /src/wrapper
parent1805da1c85dffe2f8e018a5a9278d6af35276147 (diff)
verboase: Mutex logging
We have threading in apps now.
Diffstat (limited to 'src/wrapper')
-rw-r--r--src/wrapper/verbose.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/wrapper/verbose.h b/src/wrapper/verbose.h
index 719edc7..06ee681 100644
--- a/src/wrapper/verbose.h
+++ b/src/wrapper/verbose.h
@@ -1,15 +1,21 @@
#pragma once
#ifdef VERBOSE_FUNCTIONS
+# include <stdio.h>
# include <stdarg.h>
+# include <pthread.h>
static void
verbose(const char *fmt, ...)
{
+ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+ pthread_mutex_lock(&mutex);
+ fprintf(stderr, "%lu: ", pthread_self());
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
fputc('\n', stderr);
+ pthread_mutex_unlock(&mutex);
}
#else
# define verbose(...)