This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] add cfsetspeed


This patchset adds cfsetspeed(3), a BSD extension also available in
glibc:

http://man7.org/linux/man-pages/man3/termios.3.html

Per the description, cfsetspeed() is the equivalent of cfsetospeed() and
cfsetispeed() with the same baud rate.  Patch for winsup/cygwin
attached.


Yaakov

2012-11-21  Yaakov Selkowitz  <yselkowitz@...>

	* termios.cc (cfsetspeed): New function.
	* cygwin.din (cfsetspeed): Export.
	* posix.sgml (std-bsd): Add cfsetspeed.
	* include/sys/termios.h (cfsetspeed): Declare.
	* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.

Index: cygwin.din
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/cygwin.din,v
retrieving revision 1.256
diff -u -p -r1.256 cygwin.din
--- cygwin.din	18 Jul 2012 11:17:24 -0000	1.256
+++ cygwin.din	21 Nov 2012 10:19:11 -0000
@@ -208,6 +208,7 @@ cfgetospeed NOSIGFE
 cfmakeraw NOSIGFE
 cfsetispeed SIGFE
 cfsetospeed SIGFE
+cfsetspeed SIGFE
 chdir SIGFE
 _chdir = chdir SIGFE
 chmod SIGFE
Index: posix.sgml
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/posix.sgml,v
retrieving revision 1.79
diff -u -p -r1.79 posix.sgml
--- posix.sgml	18 Jul 2012 11:17:25 -0000	1.79
+++ posix.sgml	21 Nov 2012 10:19:11 -0000
@@ -957,6 +957,7 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008)
     bindresvport
     bindresvport_sa
     cfmakeraw
+    cfsetspeed
     daemon
     dn_comp
     dn_expand
Index: termios.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/termios.cc,v
retrieving revision 1.41
diff -u -p -r1.41 termios.cc
--- termios.cc	28 Feb 2012 14:03:02 -0000	1.41
+++ termios.cc	21 Nov 2012 10:19:10 -0000
@@ -328,6 +328,20 @@ cfsetispeed (struct termios *in_tp, spee
   return res;
 }
 
+/* cfsetspeed: 4.4BSD */
+extern "C" int
+cfsetspeed (struct termios *in_tp, speed_t speed)
+{
+  struct termios *tp = __tonew_termios (in_tp);
+  int res;
+  /* errors come only from unsupported baud rates, so setspeed() would return
+     identical results in both calls */
+  if ((res = setspeed (tp->c_ospeed, speed)) == 0)
+    setspeed (tp->c_ispeed, speed);
+  __toapp_termios (in_tp, tp);
+  return res;
+}
+
 extern "C" void
 cfmakeraw(struct termios *tp)
 {
Index: include/cygwin/version.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/version.h,v
retrieving revision 1.373
diff -u -p -r1.373 version.h
--- include/cygwin/version.h	21 Oct 2012 10:20:53 -0000	1.373
+++ include/cygwin/version.h	21 Nov 2012 10:19:11 -0000
@@ -431,12 +431,13 @@ details. */
       260: Export scandirat.
       261: Export memrchr.
       262: Export getmntent_r.
+      263: Export cfsetspeed.
      */
 
      /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
 
 #define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 262
+#define CYGWIN_VERSION_API_MINOR 263
 
      /* There is also a compatibity version number associated with the
 	shared memory regions.  It is incremented when incompatible
Index: include/sys/termios.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/include/sys/termios.h,v
retrieving revision 1.23
diff -u -p -r1.23 termios.h
--- include/sys/termios.h	5 Nov 2012 03:19:28 -0000	1.23
+++ include/sys/termios.h	21 Nov 2012 10:19:12 -0000
@@ -345,6 +345,7 @@ speed_t cfgetispeed(const struct termios
 speed_t cfgetospeed(const struct termios *);
 int cfsetispeed (struct termios *, speed_t);
 int cfsetospeed (struct termios *, speed_t);
+int cfsetspeed (struct termios *, speed_t);
 
 #ifdef __cplusplus
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]