summaryrefslogtreecommitdiffstats
path: root/testsuites/support/src/locked_print.c
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2016-05-20 18:39:50 +1000
committerChris Johns <chrisj@rtems.org>2016-05-25 15:47:34 +1000
commit24d0ee57a4d95f99be6e7e60bd162a30daf0638d (patch)
tree94239c8cc6b21813ca44b6ca89da73f9038914cc /testsuites/support/src/locked_print.c
parentpsxtests/psxmsgq01: Fix typo (diff)
downloadrtems-24d0ee57a4d95f99be6e7e60bd162a30daf0638d.tar.bz2
cpukit, testsuite: Add rtems_printf and rtems_printer support.
This change adds rtems_printf and related functions and wraps the RTEMS print plugin support into a user API. All references to the plugin are removed and replaced with the rtems_printer interface. Printk and related functions are made to return a valid number of characters formatted and output. The function attribute to check printf functions has been added to rtems_printf and printk. No changes to remove warrnings are part of this patch set. The testsuite has been moved over to the rtems_printer. The testsuite has a mix of rtems_printer access and direct print control via the tmacros.h header file. The support for begink/endk has been removed as it served no purpose and only confused the code base. The testsuite has not been refactored to use rtems_printf. This is future work.
Diffstat (limited to '')
-rw-r--r--testsuites/support/src/locked_print.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/testsuites/support/src/locked_print.c b/testsuites/support/src/locked_print.c
index 8414479061..7c0df667f8 100644
--- a/testsuites/support/src/locked_print.c
+++ b/testsuites/support/src/locked_print.c
@@ -1,4 +1,4 @@
-/*
+/*
* COPYRIGHT (c) 1989-2011.
* On-Line Applications Research Corporation (OAR).
*
@@ -14,7 +14,23 @@
#include "test_support.h"
#include "tmacros.h"
-static rtems_id locked_print_semaphore; /* synchronisation semaphore */
+static rtems_id locked_print_semaphore; /* synchronisation semaphore */
+
+rtems_printer rtems_test_printer;
+
+static 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;
+}
void locked_print_initialize(void)
{
@@ -29,7 +45,7 @@ void locked_print_initialize(void)
/* Create/verify synchronisation semaphore */
sc = rtems_semaphore_create(
rtems_build_name ('S', 'E', 'M', '1'),
- 1,
+ 1,
RTEMS_LOCAL |
RTEMS_BINARY_SEMAPHORE |
RTEMS_PRIORITY_CEILING |
@@ -38,6 +54,12 @@ void locked_print_initialize(void)
&locked_print_semaphore
);
directive_failed( sc, "rtems_semaphore_create" );
+
+ /*
+ * Set up the printer to use the locked printf printer.
+ */
+ rtems_test_printer.context = NULL;
+ rtems_test_printer.context = locked_printf_plugin;
}
int locked_vprintf(const char *fmt, va_list ap)
@@ -60,20 +82,6 @@ int locked_vprintf(const char *fmt, va_list ap)
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;