From b3c841834bc4edfb78ad32cad58fb1d69e5beb4d Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Sun, 25 Feb 2018 15:25:56 +0200 Subject: verboase: Mutex logging We have threading in apps now. --- src/wrapper/verbose.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/wrapper') 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 # include +# include 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(...) -- cgit v1.2.3