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 | |
parent | 0960fee4067febf90823778a118f9ed2d7c1a8a5 (diff) |
tests: Add locked_printf_plugin()
Add locked_vprintf(). Return an int just like printf(), etc.
Diffstat (limited to 'testsuites')
-rw-r--r-- | testsuites/support/include/test_support.h | 15 | ||||
-rw-r--r-- | testsuites/support/src/locked_print.c | 52 |
2 files changed, 49 insertions, 18 deletions
diff --git a/testsuites/support/include/test_support.h b/testsuites/support/include/test_support.h index 1950388bc1..7c459ff1d9 100644 --- a/testsuites/support/include/test_support.h +++ b/testsuites/support/include/test_support.h @@ -10,6 +10,8 @@ #ifndef __TEST_SUPPORT_h #define __TEST_SUPPORT_h +#include <stdarg.h> + #ifdef __cplusplus extern "C" { #endif @@ -65,9 +67,16 @@ void rtems_time_test_measure_operation( /************** TEST SUPPORT **************/ /*********************************************************************/ /*********************************************************************/ -extern void locked_print_initialize(void); -extern void locked_printf(const char *fmt, ...); -extern void locked_printk(const char *fmt, ...); + +void locked_print_initialize(void); + +int locked_printf(const char *fmt, ...); + +int locked_vprintf(const char *fmt, va_list ap); + +int locked_printf_plugin(void *context, const char *fmt, ...); + +void locked_printk(const char *fmt, ...); #ifdef __cplusplus }; 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 ); +} |