change log for rtems (2010-07-24)

rtems-vc at rtems.org rtems-vc at rtems.org
Sat Jul 24 17:10:18 UTC 2010


 *joel*:
2010-07-24	Joel Sherrill <joel.sherrill at oarcorp.com>

	* libcsupport/Makefile.am, libcsupport/src/termios_baud2num.c,
	libcsupport/src/termios_num2baud.c: Use RTEMS associations to
	simplify code and make easier for coverage.
	* libcsupport/src/termios_baudtable.c: New file.

M 1.2517  cpukit/ChangeLog
M  1.128  cpukit/libcsupport/Makefile.am
M    1.5  cpukit/libcsupport/src/termios_baud2num.c
A    1.1  cpukit/libcsupport/src/termios_baudtable.c
M    1.4  cpukit/libcsupport/src/termios_num2baud.c

diff -u rtems/cpukit/ChangeLog:1.2516 rtems/cpukit/ChangeLog:1.2517
--- rtems/cpukit/ChangeLog:1.2516	Thu Jul 22 19:11:32 2010
+++ rtems/cpukit/ChangeLog	Sat Jul 24 11:12:48 2010
@@ -1,3 +1,10 @@
+2010-07-24	Joel Sherrill <joel.sherrill at oarcorp.com>
+
+	* libcsupport/Makefile.am, libcsupport/src/termios_baud2num.c,
+	libcsupport/src/termios_num2baud.c: Use RTEMS associations to
+	simplify code and make easier for coverage.
+	* libcsupport/src/termios_baudtable.c: New file.
+
 2010-07-22	Joel Sherrill <joel.sherrill at oarcorp.com>
 
 	PR 1627/testing

diff -u rtems/cpukit/libcsupport/Makefile.am:1.127 rtems/cpukit/libcsupport/Makefile.am:1.128
--- rtems/cpukit/libcsupport/Makefile.am:1.127	Thu Jul 15 03:46:06 2010
+++ rtems/cpukit/libcsupport/Makefile.am	Sat Jul 24 11:12:49 2010
@@ -57,7 +57,7 @@
     src/tcflow.c src/tcflush.c src/tcgetpgrp.c src/tcsendbreak.c \
     src/tcsetpgrp.c src/termios.c src/termiosinitialize.c \
     src/termios_baud2index.c src/termios_baud2num.c src/termios_num2baud.c \
-    src/termios_setinitialbaud.c
+    src/termios_setinitialbaud.c src/termios_baudtable.c
 
 SYSTEM_CALL_C_FILES = src/open.c src/close.c src/read.c src/write.c \
     src/write_r.c \

diff -u rtems/cpukit/libcsupport/src/termios_baud2num.c:1.4 rtems/cpukit/libcsupport/src/termios_baud2num.c:1.5
--- rtems/cpukit/libcsupport/src/termios_baud2num.c:1.4	Sat Mar 27 00:36:47 2010
+++ rtems/cpukit/libcsupport/src/termios_baud2num.c	Sat Jul 24 11:12:49 2010
@@ -15,36 +15,19 @@
 
 #include <sys/termios.h>
 #include <rtems/termiostypes.h>
+#include <rtems/assoc.h>
+
+extern rtems_assoc_t termios_assoc_table[];
 
 int32_t rtems_termios_baud_to_number(
   int termios_baud
 )
 {
-  int32_t baud;
+  int baud;
 
-  switch (termios_baud) {
-    case B0:        baud =      0;  break;
-    case B50:       baud =     50;  break;
-    case B75:       baud =     75;  break;
-    case B110:      baud =    110;  break;
-    case B134:      baud =    134;  break;
-    case B150:      baud =    150;  break;
-    case B200:      baud =    200;  break;
-    case B300:      baud =    300;  break;
-    case B600:      baud =    600;  break;
-    case B1200:     baud =   1200;  break;
-    case B1800:     baud =   1800;  break;
-    case B2400:     baud =   2400;  break;
-    case B4800:     baud =   4800;  break;
-    case B9600:     baud =   9600;  break;
-    case B19200:    baud =  19200;  break;
-    case B38400:    baud =  38400;  break;
-    case B57600:    baud =  57600;  break;
-    case B115200:   baud = 115200;  break;
-    case B230400:   baud = 230400;  break;
-    case B460800:   baud = 460800;  break;
-    default:        baud =     -1;  break;
-  }
+  baud = rtems_assoc_local_by_remote( termios_assoc_table, termios_baud );
+  if ( baud == 0 && termios_baud != 0 )
+    return -1;
 
   return baud;
 }

diff -u /dev/null rtems/cpukit/libcsupport/src/termios_baudtable.c:1.1
--- /dev/null	Sat Jul 24 12:10:18 2010
+++ rtems/cpukit/libcsupport/src/termios_baudtable.c	Sat Jul 24 11:12:49 2010
@@ -0,0 +1,42 @@
+/*
+ *  COPYRIGHT (c) 1989-2010.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  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.
+ *
+ *  $Id$
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/termios.h>
+#include <rtems/termiostypes.h>
+#include <rtems/assoc.h>
+
+rtems_assoc_t termios_assoc_table[] = {
+  { "B0",      0,      B0 },
+  { "B50",     50,     B50 },
+  { "B75",     75,     B75 },
+  { "B110",    110,    B110 },
+  { "B134",    134,    B134 },
+  { "B150",    150,    B150 },
+  { "B200",    200,    B200 },
+  { "B300",    300,    B300 },
+  { "B600",    600,    B600 },
+  { "B1200",   1200,   B1200 },
+  { "B1800",   1800,   B1800 },
+  { "B2400",   2400,   B2400 },
+  { "B4800",   4800,   B4800 },
+  { "B9600",   9600,   B9600 },
+  { "B19200",  19200,  B19200 },
+  { "B38400",  38400,  B38400 },
+  { "B57600",  57600,  B57600 },
+  { "B115200", 115200, B115200 },
+  { "B230400", 230400, B230400 },
+  { "B460800", 460800, B460800 },
+  { NULL,      0,      0 }
+};

diff -u rtems/cpukit/libcsupport/src/termios_num2baud.c:1.3 rtems/cpukit/libcsupport/src/termios_num2baud.c:1.4
--- rtems/cpukit/libcsupport/src/termios_num2baud.c:1.3	Sat Mar 27 00:36:47 2010
+++ rtems/cpukit/libcsupport/src/termios_num2baud.c	Sat Jul 24 11:12:49 2010
@@ -15,6 +15,9 @@
 
 #include <sys/termios.h>
 #include <rtems/termiostypes.h>
+#include <rtems/assoc.h>
+
+extern rtems_assoc_t termios_assoc_table[];
 
 int rtems_termios_number_to_baud(
   int32_t baud
@@ -22,29 +25,8 @@
 {
   int termios_baud;
 
-  switch (baud) {
-    case 0:       termios_baud = B0;      break;
-    case 50:      termios_baud = B50;     break;
-    case 75:      termios_baud = B75;     break;
-    case 110:     termios_baud = B110;    break;
-    case 134:     termios_baud = B134;    break;
-    case 150:     termios_baud = B150;    break;
-    case 200:     termios_baud = B200;    break;
-    case 300:     termios_baud = B300;    break;
-    case 600:     termios_baud = B600;    break;
-    case 1200:    termios_baud = B1200;   break;
-    case 1800:    termios_baud = B1800;   break;
-    case 2400:    termios_baud = B2400;   break;
-    case 4800:    termios_baud = B4800;   break;
-    case 9600:    termios_baud = B9600;   break;
-    case 19200:   termios_baud = B19200;  break;
-    case 38400:   termios_baud = B38400;  break;
-    case 57600:   termios_baud = B57600;  break;
-    case 115200:  termios_baud = B115200; break;
-    case 230400:  termios_baud = B230400; break;
-    case 460800:  termios_baud = B460800; break;
-    default:      termios_baud = -1;      break;
-  }
-
+  termios_baud = rtems_assoc_remote_by_local( termios_assoc_table, baud );
+  if ( termios_baud == 0 && baud != 0 )
+    return -1;
   return termios_baud;
 }



--

Generated by Deluxe Loginfo [http://www.codewiz.org/projects/index.html#loginfo] 2.122 by Bernardo Innocenti <bernie at develer.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/vc/attachments/20100724/b26c12b9/attachment.html>


More information about the vc mailing list