summaryrefslogtreecommitdiff
path: root/src/wrapper/wrapper.c
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-03-11 18:22:16 +0200
committerJari Vetoniemi <mailroxas@gmail.com>2018-03-11 18:22:16 +0200
commitf38c62e199adb377791e05452b10b55e40edb08a (patch)
tree2e505bec40747852b4c8fd27c74d1c5659583870 /src/wrapper/wrapper.c
parent3c82c28052cd138c1228065dacc019ba66ed664e (diff)
verbose: Move implementation to wrapper.c
Static header implementation is not thread safe as mutex is of course duplicated to each version...
Diffstat (limited to 'src/wrapper/wrapper.c')
-rw-r--r--src/wrapper/wrapper.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/wrapper/wrapper.c b/src/wrapper/wrapper.c
index d7feff5..2d61519 100644
--- a/src/wrapper/wrapper.c
+++ b/src/wrapper/wrapper.c
@@ -1,5 +1,6 @@
#include "wrapper.h"
#include <stdio.h>
+#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
@@ -9,6 +10,21 @@
#include <assert.h>
#include <sys/mman.h>
#include "verbose.h"
+#include <pthread.h>
+
+void
+verbose_log(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);
+}
#ifdef VERBOSE_FUNCTIONS
# ifdef ANDROID_X86_LINKER