Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2306 → Rev 2307

/branches/rcu/uspace/libc/generic/io/vprintf.c
36,10 → 36,12
#include <stdio.h>
#include <unistd.h>
#include <io/printf_core.h>
#include <futex.h>
#include <async.h>
 
int vprintf_write(const char *str, size_t count, void *unused);
static atomic_t printf_futex = FUTEX_INITIALIZER;
 
int vprintf_write(const char *str, size_t count, void *unused)
static int vprintf_write(const char *str, size_t count, void *unused)
{
return write(1, str, count);
}
51,9 → 53,23
*/
int vprintf(const char *fmt, va_list ap)
{
struct printf_spec ps = {(int(*)(void *, size_t, void *))vprintf_write, NULL};
return printf_core(fmt, &ps, ap);
 
struct printf_spec ps = {
(int (*)(void *, size_t, void *)) vprintf_write,
NULL
};
/*
* Prevent other threads to execute printf_core()
*/
futex_down(&printf_futex);
/*
* Prevent other pseudo threads of the same thread
* to execute printf_core()
*/
async_serialize_start();
int ret = printf_core(fmt, &ps, ap);
async_serialize_end();
futex_up(&printf_futex);
return ret;
}
 
/** @}