diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-05-07 18:27:19 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-05-07 18:27:19 +0200 |
commit | b97bc8bc71a6dac6dafc2afe7c4cbe2085fa2d55 (patch) | |
tree | 214363b3119d883de81534c8c156d5a06c1d5c76 /testsuites/support/src | |
parent | rtems: Fix ASR SMP support (diff) | |
download | rtems-b97bc8bc71a6dac6dafc2afe7c4cbe2085fa2d55.tar.bz2 |
tests: Add locked_printf_plugin()
Add locked_vprintf(). Return an int just like printf(), etc.
Diffstat (limited to 'testsuites/support/src')
-rw-r--r-- | testsuites/support/src/locked_print.c | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/testsuites/support/src/locked_print.c b/testsuites/support/src/locked_print.c index 86cddde2f6..8414479061 100644 --- a/testsuites/support/src/locked_print.c +++ b/testsuites/support/src/locked_print.c @@ -11,12 +11,7 @@ #include "config.h" #endif -#include <rtems.h> -#include <rtems/system.h> -#include <sys/types.h> -#include <string.h> -#include <stdarg.h> - +#include "test_support.h" #include "tmacros.h" static rtems_id locked_print_semaphore; /* synchronisation semaphore */ @@ -45,8 +40,9 @@ void locked_print_initialize(void) directive_failed( sc, "rtems_semaphore_create" ); } -void locked_printf(const char *fmt, ...) { - va_list ap; /* points to each unnamed argument in turn */ +int locked_vprintf(const char *fmt, va_list ap) +{ + int rv; rtems_status_code sc; locked_print_initialize(); @@ -56,16 +52,42 @@ void locked_printf(const char *fmt, ...) { sc = rtems_semaphore_obtain( locked_print_semaphore, RTEMS_NO_WAIT, 0 ); } while (sc != RTEMS_SUCCESSFUL ); + rv = vprintf(fmt, ap); + + /* Release the semaphore */ + rtems_semaphore_release( locked_print_semaphore ); + + return rv; +} + +int locked_printf_plugin(void *context, const char *fmt, ...) +{ + int rv; + va_list ap; + + (void) context; + + va_start(ap, fmt); + rv = locked_vprintf(fmt, ap); + va_end(ap); + + return rv; +} + +int locked_printf(const char *fmt, ...) +{ + int rv; + va_list ap; /* points to each unnamed argument in turn */ va_start(ap, fmt); /* make ap point to 1st unnamed arg */ - vprintf(fmt, ap); + rv = locked_vprintf(fmt, ap); va_end(ap); /* clean up when done */ - /* Release the semaphore */ - sc = rtems_semaphore_release( locked_print_semaphore ); -} + return rv; +} -void locked_printk(const char *fmt, ...) { +void locked_printk(const char *fmt, ...) +{ va_list ap; /* points to each unnamed argument in turn */ rtems_status_code sc; @@ -82,5 +104,5 @@ void locked_printk(const char *fmt, ...) { va_end(ap); /* clean up when done */ /* Release the semaphore */ - sc = rtems_semaphore_release( locked_print_semaphore ); -} + rtems_semaphore_release( locked_print_semaphore ); +} |