summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libc/cfiospeed.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1998-05-22 14:51:11 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1998-05-22 14:51:11 +0000
commit119bced0fd63d7651a27cdf2f738b7cb4b0d9c10 (patch)
tree576d37ede74625e54a227c09e67ae4d6db7b3f0a /c/src/lib/libc/cfiospeed.c
parentAdded tcdrain(), cfgetospeed(), cfsetospeed(), cfgetispeed(), and cfsetispeed(). (diff)
downloadrtems-119bced0fd63d7651a27cdf2f738b7cb4b0d9c10.tar.bz2
Added tcdrain(), cfgetospeed(0, cfsetospeed(), cfgetispeed(), and
cfsetispeed().
Diffstat (limited to 'c/src/lib/libc/cfiospeed.c')
-rw-r--r--c/src/lib/libc/cfiospeed.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/c/src/lib/libc/cfiospeed.c b/c/src/lib/libc/cfiospeed.c
new file mode 100644
index 0000000000..772d6083c9
--- /dev/null
+++ b/c/src/lib/libc/cfiospeed.c
@@ -0,0 +1,54 @@
+/*
+ * This file contains the RTEMS implementation of the POSIX API
+ * routines cfgetispeed, cfgetospeed, cfsetispeed and cfsetospeed.
+ *
+ * $Id$
+ *
+ */
+
+#include <rtems.h>
+#if defined(RTEMS_NEWLIB)
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <termios.h>
+
+#include "internal.h"
+#include "libio.h"
+
+speed_t
+cfgetospeed(const struct termios *tp)
+{
+ return tp->c_cflag & CBAUD;
+}
+
+int
+cfsetospeed(struct termios *tp, speed_t speed)
+{
+ if (speed & ~CBAUD) {
+ errno = EINVAL;
+ return -1;
+ }
+ tp->c_cflag = (tp->c_cflag & ~CBAUD) | speed;
+ return 0;
+}
+
+speed_t
+cfgetispeed(const struct termios *tp)
+{
+ return (tp->c_cflag / (CIBAUD / CBAUD)) & CBAUD;
+}
+
+int
+cfsetispeed(struct termios *tp, speed_t speed)
+{
+ if (speed & ~CBAUD) {
+ errno = EINVAL;
+ return -1;
+ }
+ tp->c_cflag = (tp->c_cflag & ~CBAUD) | (speed * (CIBAUD / CBAUD));
+ return 0;
+}
+
+#endif