Rev 2229 | Rev 2479 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2229 | Rev 2230 | ||
---|---|---|---|
Line 34... | Line 34... | ||
34 | 34 | ||
35 | #include <stdarg.h> |
35 | #include <stdarg.h> |
36 | #include <stdio.h> |
36 | #include <stdio.h> |
37 | #include <unistd.h> |
37 | #include <unistd.h> |
38 | #include <io/printf_core.h> |
38 | #include <io/printf_core.h> |
- | 39 | #include <futex.h> |
|
- | 40 | #include <async.h> |
|
- | 41 | ||
- | 42 | static atomic_t printf_futex = FUTEX_INITIALIZER; |
|
39 | 43 | ||
40 | static int vprintf_write(const char *str, size_t count, void *unused) |
44 | static int vprintf_write(const char *str, size_t count, void *unused) |
41 | { |
45 | { |
42 | return write(1, str, count); |
46 | return write(1, str, count); |
43 | } |
47 | } |
Line 47... | Line 51... | ||
47 | * @param ap format parameters |
51 | * @param ap format parameters |
48 | * \see For more details about format string see printf_core. |
52 | * \see For more details about format string see printf_core. |
49 | */ |
53 | */ |
50 | int vprintf(const char *fmt, va_list ap) |
54 | int vprintf(const char *fmt, va_list ap) |
51 | { |
55 | { |
- | 56 | struct printf_spec ps = { |
|
52 | struct printf_spec ps = {(int(*)(void *, size_t, void *)) vprintf_write, NULL}; |
57 | (int (*)(void *, size_t, void *)) vprintf_write, |
- | 58 | NULL |
|
- | 59 | }; |
|
- | 60 | /* |
|
- | 61 | * Prevent other threads to execute printf_core() |
|
- | 62 | */ |
|
- | 63 | futex_down(&printf_futex); |
|
53 | 64 | /* |
|
- | 65 | * Prevent other pseudo threads of the same thread |
|
- | 66 | * to execute printf_core() |
|
- | 67 | */ |
|
- | 68 | async_serialize_start(); |
|
54 | int ret = printf_core(fmt, &ps, ap); |
69 | int ret = printf_core(fmt, &ps, ap); |
55 | 70 | async_serialize_end(); |
|
- | 71 | futex_up(&printf_futex); |
|
56 | return ret; |
72 | return ret; |
57 | } |
73 | } |
58 | 74 | ||
59 | /** @} |
75 | /** @} |
60 | */ |
76 | */ |