From f38c62e199adb377791e05452b10b55e40edb08a Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Sun, 11 Mar 2018 18:22:16 +0200 Subject: verbose: Move implementation to wrapper.c Static header implementation is not thread safe as mutex is of course duplicated to each version... --- src/wrapper/verbose.h | 25 +++---------------------- src/wrapper/wrapper.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/wrapper/verbose.h b/src/wrapper/verbose.h index 3f54795..9a91906 100644 --- a/src/wrapper/verbose.h +++ b/src/wrapper/verbose.h @@ -1,27 +1,8 @@ #pragma once -#include -#include -#include - -#ifdef VERBOSE_FUNCTIONS -// Don't inline to get warnings from files that don't log at all -static void -#else -static inline void -#endif -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); -} +void +__attribute__((format(printf, 1, 2))) +verbose_log(const char *fmt, ...); #ifdef VERBOSE_FUNCTIONS # define verbose verbose_log 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 +#include #include #include #include @@ -9,6 +10,21 @@ #include #include #include "verbose.h" +#include + +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 -- cgit v1.2.3-70-g09d2