summaryrefslogtreecommitdiff
path: root/src/wrapper/verbose.h
blob: 06ee681e5dc38814997f9b79b39e756e473ee923 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#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(...)
#endif