[rtems commit] libcsupport: Add and use rtems_putc()

Sebastian Huber sebh at rtems.org
Mon Aug 20 08:08:29 UTC 2012


Module:    rtems
Branch:    master
Commit:    bd5a138629771ae174927791fcc7515232a0e4fa
Changeset: http://git.rtems.org/rtems/commit/?id=bd5a138629771ae174927791fcc7515232a0e4fa

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Aug 13 11:29:13 2012 +0200

libcsupport: Add and use rtems_putc()

This reduces code size and provides a function similar to fputc().

---

 cpukit/include/rtems/bspIo.h        |    1 +
 cpukit/libcsupport/Makefile.am      |    1 +
 cpukit/libcsupport/src/rtems_putc.c |   24 ++++++++++++++++++++++++
 cpukit/libcsupport/src/vprintk.c    |   18 +++++++++---------
 4 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/cpukit/include/rtems/bspIo.h b/cpukit/include/rtems/bspIo.h
index d5a004a..dc5f304 100644
--- a/cpukit/include/rtems/bspIo.h
+++ b/cpukit/include/rtems/bspIo.h
@@ -53,6 +53,7 @@ extern int getchark(void);
 extern void vprintk(const char *fmt, va_list ap);
 extern void printk(const char *fmt, ...);
 extern void putk(const char *s);
+extern void rtems_putc(char c);
 
 /*
  *  This routine is passed into RTEMS reporting functions
diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am
index ae23338..04d2455 100644
--- a/cpukit/libcsupport/Makefile.am
+++ b/cpukit/libcsupport/Makefile.am
@@ -120,6 +120,7 @@ BSD_LIBC_C_FILES = src/strlcpy.c src/strlcat.c src/issetugid.c
 
 libcsupport_a_SOURCES = src/gxx_wrappers.c src/getchark.c src/printk.c \
     src/printk_plugin.c src/putk.c src/vprintk.c \
+    src/rtems_putc.c \
     src/printf_plugin.c \
     src/sup_fs_location.c \
     src/sup_fs_eval_path.c \
diff --git a/cpukit/libcsupport/src/rtems_putc.c b/cpukit/libcsupport/src/rtems_putc.c
new file mode 100644
index 0000000..8a2b022
--- /dev/null
+++ b/cpukit/libcsupport/src/rtems_putc.c
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2012 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Obere Lagerstr. 30
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems at embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+  #include "config.h"
+#endif
+
+#include <rtems/bspIo.h>
+
+void rtems_putc(char c)
+{
+  (*BSP_output_char)(c);
+}
diff --git a/cpukit/libcsupport/src/vprintk.c b/cpukit/libcsupport/src/vprintk.c
index 1a8d5dd..2524e88 100644
--- a/cpukit/libcsupport/src/vprintk.c
+++ b/cpukit/libcsupport/src/vprintk.c
@@ -55,7 +55,7 @@ void vprintk(
     char c;
 
     if (*fmt != '%') {
-      BSP_output_char(*fmt);
+      rtems_putc(*fmt);
       continue;
     }
     fmt++;
@@ -80,7 +80,7 @@ void vprintk(
     if ( c == 'c' ) {
       /* need a cast here since va_arg() only takes fully promoted types */
       char chr = (char) va_arg(ap, int);
-      BSP_output_char(chr);
+      rtems_putc(chr);
       continue;
     }
     if ( c == 's' ) {
@@ -100,7 +100,7 @@ void vprintk(
       /* leading spaces */
       if ( !minus )
         for ( i=len ; i<width ; i++ )
-          BSP_output_char(' ');
+          rtems_putc(' ');
 
       /* no width option */
       if (width == 0) {
@@ -109,12 +109,12 @@ void vprintk(
 
       /* output the string */
       for ( i=0 ; i<width && *str ; str++ )
-        BSP_output_char(*str);
+        rtems_putc(*str);
 
       /* trailing spaces */
       if ( minus )
         for ( i=len ; i<width ; i++ )
-          BSP_output_char(' ');
+          rtems_putc(' ');
 
       continue;
     }
@@ -132,7 +132,7 @@ void vprintk(
     } else if ( c == 'p' ) {
       base = 16; sign = false; lflag = true;
     } else {
-      BSP_output_char(c);
+      rtems_putc(c);
       continue;
     }
 
@@ -166,7 +166,7 @@ static void printNum(
   char toPrint[20];
 
   if ( sign && (num <  0) ) {
-    BSP_output_char('-');
+    rtems_putc('-');
     unsigned_num = (unsigned long) -num;
     if (maxwidth) maxwidth--;
   } else {
@@ -181,9 +181,9 @@ static void printNum(
   toPrint[count++] = (char) unsigned_num;
 
   for (n=maxwidth ; n > count; n-- )
-    BSP_output_char(lead);
+    rtems_putc(lead);
 
   for (n = 0; n < count; n++) {
-    BSP_output_char("0123456789ABCDEF"[(int)(toPrint[count-(n+1)])]);
+    rtems_putc("0123456789ABCDEF"[(int)(toPrint[count-(n+1)])]);
   }
 }




More information about the vc mailing list