#include <errno.h>
#include <string.h>
#include <sys/uio.h>
+#include <pthread.h>
static const char *appname;
static const char chars[] = { '\n', '?', ':', ' ', '[', ',', ']' };
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+
static void _vverbose_(int loglevel, const char *file, int line, const char *function, const char *fmt, va_list args)
{
char buffer[4000];
n = 2;
if (fmt) {
iov[n].iov_base = buffer;
+ errno = saverr;
rc = vsnprintf(buffer, sizeof buffer, fmt, args);
if (rc < 0)
rc = 0;
iov[n].iov_base = (void*)&chars[0];
iov[n++].iov_len = 1;
+ pthread_mutex_lock(&mutex);
writev(STDERR_FILENO, iov, n);
+ pthread_mutex_unlock(&mutex);
errno = saverr;
}