summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-06-21 13:30:15 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-06-22 07:29:26 +0200
commit506bfc8580c365c48f2200772ddd0985e661ae34 (patch)
tree66f6c17573377ee1e14556d102df974db66e2a23
parentMake rtems/print.h independent of rtems/bspIo.h (diff)
downloadrtems-506bfc8580c365c48f2200772ddd0985e661ae34.tar.bz2
Move printer initialization to separate header
The RTEMS print user need to know nothing about a particular printer implementation. In particular get rid of the <stdio.h> include which would be visible via <rtems.h>.
-rw-r--r--c/src/lib/libbsp/shared/src/irq-info.c2
-rw-r--r--c/src/lib/libbsp/shared/src/irq-shell.c1
-rw-r--r--cpukit/Makefile.am1
-rw-r--r--cpukit/include/rtems/print.h83
-rw-r--r--cpukit/include/rtems/printer.h119
-rw-r--r--cpukit/libcsupport/src/print_fprintf.c4
-rw-r--r--cpukit/libcsupport/src/print_printf.c4
-rw-r--r--cpukit/libcsupport/src/printf_plugin.c4
-rw-r--r--cpukit/libcsupport/src/printk_plugin.c2
-rw-r--r--cpukit/libdl/rap.c1
-rw-r--r--cpukit/libmisc/cpuuse/cpuusagereport.c1
-rw-r--r--cpukit/libmisc/cpuuse/cpuusagetop.c1
-rw-r--r--cpukit/libmisc/fb/mw_print.c1
-rw-r--r--cpukit/libmisc/shell/main_blkstats.c1
-rw-r--r--cpukit/libmisc/shell/main_cpuinfo.c1
-rw-r--r--cpukit/libmisc/shell/main_cpuuse.c1
-rw-r--r--cpukit/libmisc/shell/main_perioduse.c1
-rw-r--r--cpukit/libmisc/shell/main_profreport.c1
-rw-r--r--cpukit/libmisc/shell/main_stackuse.c1
-rw-r--r--cpukit/libmisc/shell/main_top.c1
-rw-r--r--cpukit/libmisc/stackchk/check.c1
-rw-r--r--cpukit/libmisc/testsupport/test.h2
-rw-r--r--cpukit/mghttpd/mongoose.c2
-rw-r--r--cpukit/preinstall.am4
-rw-r--r--cpukit/rtems/src/ratemonreportstatistics.c2
-rw-r--r--cpukit/score/src/cpusetprintsupport.c4
-rw-r--r--testsuites/samples/hello/init.c1
27 files changed, 153 insertions, 94 deletions
diff --git a/c/src/lib/libbsp/shared/src/irq-info.c b/c/src/lib/libbsp/shared/src/irq-info.c
index f5f2323a01..ef965d3d07 100644
--- a/c/src/lib/libbsp/shared/src/irq-info.c
+++ b/c/src/lib/libbsp/shared/src/irq-info.c
@@ -21,7 +21,7 @@
#include <inttypes.h>
-#include <rtems/print.h>
+#include <rtems/printer.h>
#include <bsp/irq-generic.h>
#include <bsp/irq-info.h>
diff --git a/c/src/lib/libbsp/shared/src/irq-shell.c b/c/src/lib/libbsp/shared/src/irq-shell.c
index 512594c133..ca936f8038 100644
--- a/c/src/lib/libbsp/shared/src/irq-shell.c
+++ b/c/src/lib/libbsp/shared/src/irq-shell.c
@@ -21,6 +21,7 @@
#include <stdio.h>
+#include <rtems/printer.h>
#include <rtems/shell.h>
#include <bsp/irq-info.h>
diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am
index aa1111e99b..ac9753052d 100644
--- a/cpukit/Makefile.am
+++ b/cpukit/Makefile.am
@@ -98,6 +98,7 @@ endif
include_rtems_HEADERS += include/rtems/bspIo.h
include_rtems_HEADERS += include/rtems/print.h
+include_rtems_HEADERS += include/rtems/printer.h
include_rtems_HEADERS += include/rtems/userenv.h
include_rtems_HEADERS += include/rtems/fs.h
if !LIBPCI
diff --git a/cpukit/include/rtems/print.h b/cpukit/include/rtems/print.h
index 07e50d0948..2fd744e44c 100644
--- a/cpukit/include/rtems/print.h
+++ b/cpukit/include/rtems/print.h
@@ -21,53 +21,21 @@
#include <rtems/score/basedefs.h>
#include <stdarg.h>
-#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
+typedef struct rtems_printer rtems_printer;
+
/**
- * @defgroup RTEMS Print Support
+ * @defgroup RTEMSPrintSupport RTEMS Print Support
*
* This module contains all methods and support related to providing the user
* with an interface to the kernel level print support.
*/
/**
- * Type definition for function which can be plugged in to certain reporting
- * routines to redirect the output.
- *
- * Use the RTEMS Print interface to call these functions. Do not directly use
- * them.
- *
- * If the user provides their own printer, then they may redirect those reports
- * as they see fit.
- */
-typedef int (*rtems_print_printer)(void *, const char *format, va_list ap);
-
-/**
- * Type definition for the printer structure used to access the kernel print
- * support.
- */
-typedef struct rtems_printer {
- void *context;
- rtems_print_printer printer;
-} rtems_printer;
-
-/**
- * @brief check if the printer is valid.
- *
- * @param[in] printer Pointer to the printer structure.
- *
- * @return true The printer is valid else false is returned.
- */
-static inline bool rtems_print_printer_valid(const rtems_printer *printer)
-{
- return printer != NULL && printer->printer != NULL;
-}
-
-/**
* @brief Print to the kernel plugin handler. This has to be a macro because
* there is no vprint version of the plug in handlers.
*
@@ -95,51 +63,10 @@ extern int rtems_vprintf(const rtems_printer *printer,
const char *format,
va_list ap);
-/**
- * @brief Intiialise the rtems_printer struct to empty.
- *
- * An empty printer prints nothing. You can use this to implement an enable and
- * disable type print implementation.
- *
- * @param[in] printer Pointer to the printer structure.
- */
-static inline void rtems_print_printer_empty(rtems_printer *printer)
-{
- printer->context = NULL;
- printer->printer = NULL;
-}
-
-/**
- * @brief Intiialise the rtems_printer struct to printk
- *
- * The printer will output to the kernel printk support.
- *
- * @param[in] printer Pointer to the printer structure.
- */
-void rtems_print_printer_printk(rtems_printer *printer);
-
-/**
- * @brief Intiialise the rtems_printer struct to printf
- *
- * The printer will output to the libc printf support.
- *
- * @param[in] printer Pointer to the printer structure.
- */
-extern void rtems_print_printer_printf(rtems_printer *printer);
-
-/**
- * @brief Intiialise the rtems_printer struct to a fprintf device.
- *
- * The printer will output to the libc fprintf file provided.
- *
- * @param[in] printer Pointer to the printer structure.
- */
-extern void rtems_print_printer_fprintf(rtems_printer *printer, FILE *file);
-
-/**@}*/
+/** @} */
#ifdef __cplusplus
}
#endif
-#endif
+#endif /* _RTEMS_PRINT_H */
diff --git a/cpukit/include/rtems/printer.h b/cpukit/include/rtems/printer.h
new file mode 100644
index 0000000000..2ed6b6ac3f
--- /dev/null
+++ b/cpukit/include/rtems/printer.h
@@ -0,0 +1,119 @@
+/**
+ * @file rtems/print.h
+ *
+ * @brief User print interface to the bspIO print plug in.
+ *
+ * This include file defines the user interface to kernel print methods.
+ */
+
+/*
+ * Copyright (c) 2016 Chris Johns <chrisj@rtems.org>
+ * All rights reserved.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_PRINTER_H
+#define _RTEMS_PRINTER_H
+
+#include <rtems/print.h>
+
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup XXX
+ *
+ * @{
+ */
+
+/**
+ * @defgroup RTEMSPrintSupport
+ */
+
+/**
+ * Type definition for function which can be plugged in to certain reporting
+ * routines to redirect the output.
+ *
+ * Use the RTEMS Print interface to call these functions. Do not directly use
+ * them.
+ *
+ * If the user provides their own printer, then they may redirect those reports
+ * as they see fit.
+ */
+typedef int (*rtems_print_printer)(void *, const char *format, va_list ap);
+
+/**
+ * Type definition for the printer structure used to access the kernel print
+ * support.
+ */
+struct rtems_printer {
+ void *context;
+ rtems_print_printer printer;
+};
+
+/**
+ * @brief check if the printer is valid.
+ *
+ * @param[in] printer Pointer to the printer structure.
+ *
+ * @return true The printer is valid else false is returned.
+ */
+static inline bool rtems_print_printer_valid(const rtems_printer *printer)
+{
+ return printer != NULL && printer->printer != NULL;
+}
+
+/**
+ * @brief Initializes the rtems_printer struct to empty.
+ *
+ * An empty printer prints nothing. You can use this to implement an enable and
+ * disable type print implementation.
+ *
+ * @param[in] printer Pointer to the printer structure.
+ */
+static inline void rtems_print_printer_empty(rtems_printer *printer)
+{
+ printer->context = NULL;
+ printer->printer = NULL;
+}
+
+/**
+ * @brief Initializes the rtems_printer struct to printk
+ *
+ * The printer will output to the kernel printk support.
+ *
+ * @param[in] printer Pointer to the printer structure.
+ */
+void rtems_print_printer_printk(rtems_printer *printer);
+
+/**
+ * @brief Initializes the rtems_printer struct to printf
+ *
+ * The printer will output to the libc printf support.
+ *
+ * @param[in] printer Pointer to the printer structure.
+ */
+extern void rtems_print_printer_printf(rtems_printer *printer);
+
+/**
+ * @brief Initializes the rtems_printer struct to a fprintf device.
+ *
+ * The printer will output to the libc fprintf file provided.
+ *
+ * @param[in] printer Pointer to the printer structure.
+ */
+extern void rtems_print_printer_fprintf(rtems_printer *printer, FILE *file);
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTEMS_PRINTER_H */
diff --git a/cpukit/libcsupport/src/print_fprintf.c b/cpukit/libcsupport/src/print_fprintf.c
index 3ff80f7b2e..43ff4780d7 100644
--- a/cpukit/libcsupport/src/print_fprintf.c
+++ b/cpukit/libcsupport/src/print_fprintf.c
@@ -18,9 +18,7 @@
#include "config.h"
#endif
-#include <rtems/print.h>
-
-#include <stdio.h>
+#include <rtems/printer.h>
static int rtems_fprintf_plugin(void *context, const char *fmt, va_list ap)
{
diff --git a/cpukit/libcsupport/src/print_printf.c b/cpukit/libcsupport/src/print_printf.c
index c8695234c0..c9b273a3af 100644
--- a/cpukit/libcsupport/src/print_printf.c
+++ b/cpukit/libcsupport/src/print_printf.c
@@ -18,9 +18,7 @@
#include "config.h"
#endif
-#include <rtems/print.h>
-
-#include <stdio.h>
+#include <rtems/printer.h>
int rtems_vprintf(
const rtems_printer *printer,
diff --git a/cpukit/libcsupport/src/printf_plugin.c b/cpukit/libcsupport/src/printf_plugin.c
index 23ac9f693d..d8da6a0683 100644
--- a/cpukit/libcsupport/src/printf_plugin.c
+++ b/cpukit/libcsupport/src/printf_plugin.c
@@ -23,9 +23,7 @@
#include "config.h"
#endif
-#include <rtems/print.h>
-
-#include <stdio.h>
+#include <rtems/printer.h>
static int rtems_printf_plugin(void *context, const char *format, va_list ap)
{
diff --git a/cpukit/libcsupport/src/printk_plugin.c b/cpukit/libcsupport/src/printk_plugin.c
index 38214f8018..3b4a911eb2 100644
--- a/cpukit/libcsupport/src/printk_plugin.c
+++ b/cpukit/libcsupport/src/printk_plugin.c
@@ -18,7 +18,7 @@
#include "config.h"
#endif
-#include <rtems/print.h>
+#include <rtems/printer.h>
#include <rtems/bspIo.h>
static int printk_plugin(
diff --git a/cpukit/libdl/rap.c b/cpukit/libdl/rap.c
index 4e07c5472e..87b3bc36e5 100644
--- a/cpukit/libdl/rap.c
+++ b/cpukit/libdl/rap.c
@@ -19,6 +19,7 @@
#include "config.h"
#endif
+#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
diff --git a/cpukit/libmisc/cpuuse/cpuusagereport.c b/cpukit/libmisc/cpuuse/cpuusagereport.c
index 2a6eaf348b..370eb05596 100644
--- a/cpukit/libmisc/cpuuse/cpuusagereport.c
+++ b/cpukit/libmisc/cpuuse/cpuusagereport.c
@@ -25,6 +25,7 @@
#include <inttypes.h>
#include <rtems/cpuuse.h>
+#include <rtems/printer.h>
#include <rtems/score/objectimpl.h>
#include <rtems/score/threadimpl.h>
#include <rtems/score/todimpl.h>
diff --git a/cpukit/libmisc/cpuuse/cpuusagetop.c b/cpukit/libmisc/cpuuse/cpuusagetop.c
index e300ee785c..aa2b74c160 100644
--- a/cpukit/libmisc/cpuuse/cpuusagetop.c
+++ b/cpukit/libmisc/cpuuse/cpuusagetop.c
@@ -32,6 +32,7 @@
#include <inttypes.h>
#include <rtems/cpuuse.h>
+#include <rtems/printer.h>
#include <rtems/malloc.h>
#include <rtems/score/objectimpl.h>
#include <rtems/score/protectedheap.h>
diff --git a/cpukit/libmisc/fb/mw_print.c b/cpukit/libmisc/fb/mw_print.c
index 25a3456c80..c04f5a217a 100644
--- a/cpukit/libmisc/fb/mw_print.c
+++ b/cpukit/libmisc/fb/mw_print.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <rtems/mw_uid.h>
+#include <rtems/printer.h>
static const char *uid_buttons(
unsigned short btns,
diff --git a/cpukit/libmisc/shell/main_blkstats.c b/cpukit/libmisc/shell/main_blkstats.c
index d814df673c..69548cfa7d 100644
--- a/cpukit/libmisc/shell/main_blkstats.c
+++ b/cpukit/libmisc/shell/main_blkstats.c
@@ -17,6 +17,7 @@
#endif
#include <rtems/blkdev.h>
+#include <rtems/printer.h>
#include <rtems/shellconfig.h>
#include <string.h>
diff --git a/cpukit/libmisc/shell/main_cpuinfo.c b/cpukit/libmisc/shell/main_cpuinfo.c
index c5bc9a3f3f..9245c0f147 100644
--- a/cpukit/libmisc/shell/main_cpuinfo.c
+++ b/cpukit/libmisc/shell/main_cpuinfo.c
@@ -19,6 +19,7 @@
#include <rtems/shell.h>
#include <rtems/shellconfig.h>
#include <rtems/cpuuse.h>
+#include <rtems/printer.h>
static int rtems_shell_main_cpuinfo(int argc, char **argv)
{
diff --git a/cpukit/libmisc/shell/main_cpuuse.c b/cpukit/libmisc/shell/main_cpuuse.c
index 190fd039ff..726d907cba 100644
--- a/cpukit/libmisc/shell/main_cpuuse.c
+++ b/cpukit/libmisc/shell/main_cpuuse.c
@@ -18,6 +18,7 @@
#include <rtems.h>
#include <rtems/cpuuse.h>
+#include <rtems/printer.h>
#include <rtems/shell.h>
#include "internal.h"
diff --git a/cpukit/libmisc/shell/main_perioduse.c b/cpukit/libmisc/shell/main_perioduse.c
index 023e154cbc..6b74bb5f34 100644
--- a/cpukit/libmisc/shell/main_perioduse.c
+++ b/cpukit/libmisc/shell/main_perioduse.c
@@ -17,6 +17,7 @@
#include <string.h>
#include <rtems.h>
+#include <rtems/printer.h>
#include <rtems/shell.h>
#include "internal.h"
diff --git a/cpukit/libmisc/shell/main_profreport.c b/cpukit/libmisc/shell/main_profreport.c
index a98b8ba9aa..499e55d1aa 100644
--- a/cpukit/libmisc/shell/main_profreport.c
+++ b/cpukit/libmisc/shell/main_profreport.c
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <rtems/profiling.h>
+#include <rtems/printer.h>
#include <rtems/shell.h>
#include <rtems/shellconfig.h>
diff --git a/cpukit/libmisc/shell/main_stackuse.c b/cpukit/libmisc/shell/main_stackuse.c
index 40fc711f49..66ab863934 100644
--- a/cpukit/libmisc/shell/main_stackuse.c
+++ b/cpukit/libmisc/shell/main_stackuse.c
@@ -16,6 +16,7 @@
#include <stdio.h>
#include <rtems.h>
+#include <rtems/printer.h>
#include <rtems/stackchk.h>
#include <rtems/shell.h>
#include "internal.h"
diff --git a/cpukit/libmisc/shell/main_top.c b/cpukit/libmisc/shell/main_top.c
index aea50d80fb..1596ff04ff 100644
--- a/cpukit/libmisc/shell/main_top.c
+++ b/cpukit/libmisc/shell/main_top.c
@@ -18,6 +18,7 @@
#include <rtems.h>
#include <rtems/cpuuse.h>
+#include <rtems/printer.h>
#include <rtems/shell.h>
#include "internal.h"
diff --git a/cpukit/libmisc/stackchk/check.c b/cpukit/libmisc/stackchk/check.c
index 39650f50e7..a4b606a0e3 100644
--- a/cpukit/libmisc/stackchk/check.c
+++ b/cpukit/libmisc/stackchk/check.c
@@ -40,6 +40,7 @@
#include <stdlib.h>
#include <rtems/bspIo.h>
+#include <rtems/printer.h>
#include <rtems/stackchk.h>
#include <rtems/score/percpu.h>
#include "internal.h"
diff --git a/cpukit/libmisc/testsupport/test.h b/cpukit/libmisc/testsupport/test.h
index ce5172fb95..94f917faec 100644
--- a/cpukit/libmisc/testsupport/test.h
+++ b/cpukit/libmisc/testsupport/test.h
@@ -16,7 +16,7 @@
#define _RTEMS_TEST_H
#include <rtems.h>
-#include <rtems/print.h>
+#include <rtems/printer.h>
#include <rtems/score/atomic.h>
#include <rtems/score/smpbarrier.h>
diff --git a/cpukit/mghttpd/mongoose.c b/cpukit/mghttpd/mongoose.c
index a89fc56885..3dd0d4baab 100644
--- a/cpukit/mghttpd/mongoose.c
+++ b/cpukit/mghttpd/mongoose.c
@@ -5520,7 +5520,7 @@ struct mg_context *mg_start(const struct mg_callbacks *callbacks,
return ctx;
}
#ifdef __rtems__
-#include <rtems/print.h>
+#include <rtems/printer.h>
static int mg_printer_plugin(void *context, const char *fmt, va_list ap) {
return mg_vprintf(context, fmt, ap);
diff --git a/cpukit/preinstall.am b/cpukit/preinstall.am
index fdf2016ec5..5ba1ee4b97 100644
--- a/cpukit/preinstall.am
+++ b/cpukit/preinstall.am
@@ -228,6 +228,10 @@ $(PROJECT_INCLUDE)/rtems/print.h: include/rtems/print.h $(PROJECT_INCLUDE)/rtems
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/print.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/print.h
+$(PROJECT_INCLUDE)/rtems/printer.h: include/rtems/printer.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/printer.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/printer.h
+
$(PROJECT_INCLUDE)/rtems/userenv.h: include/rtems/userenv.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/userenv.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/userenv.h
diff --git a/cpukit/rtems/src/ratemonreportstatistics.c b/cpukit/rtems/src/ratemonreportstatistics.c
index 3f264df487..a1bab4a2f8 100644
--- a/cpukit/rtems/src/ratemonreportstatistics.c
+++ b/cpukit/rtems/src/ratemonreportstatistics.c
@@ -20,7 +20,7 @@
#include <rtems/rtems/ratemonimpl.h>
#include <rtems/rtems/object.h>
-#include <rtems/print.h>
+#include <rtems/printer.h>
#include <inttypes.h>
diff --git a/cpukit/score/src/cpusetprintsupport.c b/cpukit/score/src/cpusetprintsupport.c
index 83345d985c..13cffd9242 100644
--- a/cpukit/score/src/cpusetprintsupport.c
+++ b/cpukit/score/src/cpusetprintsupport.c
@@ -23,7 +23,7 @@
#include <stdio.h>
#include <ctype.h>
#include <inttypes.h>
-#include <rtems/print.h>
+#include <rtems/printer.h>
#include <rtems/score/cpusetimpl.h>
#ifdef __RTEMS_HAVE_SYS_CPUSET_H__
@@ -49,7 +49,7 @@
int i;
rtems_printf(printer ,"%s: ", description);
for(i=0; i<_NCPUWORDS; i++)
- rtems_printf(printer ,"%x", cpuset->__bits[i]);
+ rtems_printf(printer ,"%" PRIx32 "", cpuset->__bits[i]);
rtems_printf(printer ,"\n");
}
diff --git a/testsuites/samples/hello/init.c b/testsuites/samples/hello/init.c
index ea9af89940..acdabd8605 100644
--- a/testsuites/samples/hello/init.c
+++ b/testsuites/samples/hello/init.c
@@ -11,6 +11,7 @@
#include "config.h"
#endif
+#include <rtems/printer.h>
#include <rtems/test.h>
#include <bsp.h> /* for device driver prototypes */