public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: drop macro and code for CYGWIN_VERSION_DLL_IS_OLD_TERMIOS Date: Wed, 3 Aug 2022 14:05:29 +0000 (GMT) [thread overview] Message-ID: <20220803140529.E469A385828D@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=02b273a6880b551a7ca29be244c7653b56cc2c10 commit 02b273a6880b551a7ca29be244c7653b56cc2c10 Author: Corinna Vinschen <corinna@vinschen.de> Date: Wed Aug 3 15:33:58 2022 +0200 Cygwin: drop macro and code for CYGWIN_VERSION_DLL_IS_OLD_TERMIOS Signed-off-by: Corinna Vinschen <corinna@vinschen.de> Diff: --- winsup/cygwin/include/cygwin/version.h | 6 ----- winsup/cygwin/include/sys/termios.h | 47 ---------------------------------- winsup/cygwin/termios.cc | 32 ++++++++--------------- 3 files changed, 11 insertions(+), 74 deletions(-) diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index a5d38f37a..d32da2856 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -34,12 +34,6 @@ details. */ #define CYGWIN_VERSION_USER_API_VERSION_COMBINED \ CYGWIN_VERSION_PER_PROCESS_API_VERSION_COMBINED (user_data) -/* API versions <= this had a termios structure whose members were too small - to accomodate modern settings. */ -#define CYGWIN_VERSION_DLL_OLD_TERMIOS 5 -#define CYGWIN_VERSION_DLL_IS_OLD_TERMIOS \ - (CYGWIN_VERSION_USER_API_VERSION_COMBINED <= CYGWIN_VERSION_DLL_OLD_TERMIOS) - #define CYGWIN_VERSION_DLL_MALLOC_ENV 28 /* Old APIs had getc/putc macros that conflict with new CR/LF handling in the diff --git a/winsup/cygwin/include/sys/termios.h b/winsup/cygwin/include/sys/termios.h index e4465fca3..d701e2f72 100644 --- a/winsup/cygwin/include/sys/termios.h +++ b/winsup/cygwin/include/sys/termios.h @@ -282,53 +282,6 @@ struct termios speed_t c_ospeed; }; -#ifdef CYGWIN_VERSION_DLL_IS_OLD_TERMIOS -#ifdef __GNUC__ -# define __tonew_termios(ti) \ - ({ \ - struct termios *__newti; \ - \ - if (!CYGWIN_VERSION_DLL_IS_OLD_TERMIOS) \ - __newti = (struct termios *) ti; \ - else \ - { \ - __newti = (struct termios *) alloca(sizeof(struct termios)); \ - __newti->c_iflag = ((struct __oldtermios *)ti)->c_iflag; \ - __newti->c_oflag = ((struct __oldtermios *)ti)->c_oflag; \ - __newti->c_cflag = ((struct __oldtermios *)ti)->c_cflag; \ - __newti->c_lflag = ((struct __oldtermios *)ti)->c_lflag; \ - __newti->c_line = ((struct __oldtermios *)ti)->c_line; \ - __newti->c_ispeed = ((struct __oldtermios *)ti)->c_ispeed; \ - __newti->c_ospeed = ((struct __oldtermios *)ti)->c_ospeed; \ - memcpy (__newti->c_cc, ((struct __oldtermios *)ti)->c_cc, sizeof(__newti->c_cc)); \ - } \ - __newti; \ - }) - -# define __makenew_termios(ti) \ - (CYGWIN_VERSION_DLL_IS_OLD_TERMIOS ? \ - (struct termios *) alloca (sizeof (struct termios)) : (ti)) - -# define __toapp_termios(toti, fromti) \ - ({ \ - if (!CYGWIN_VERSION_DLL_IS_OLD_TERMIOS) \ - toti = fromti; \ - else \ - { \ - ((struct __oldtermios *)toti)->c_iflag = fromti->c_iflag; \ - ((struct __oldtermios *)toti)->c_oflag = fromti->c_oflag; \ - ((struct __oldtermios *)toti)->c_cflag = fromti->c_cflag; \ - ((struct __oldtermios *)toti)->c_lflag = fromti->c_lflag; \ - ((struct __oldtermios *)toti)->c_line = fromti->c_line; \ - ((struct __oldtermios *)toti)->c_ispeed = fromti->c_ispeed; \ - ((struct __oldtermios *)toti)->c_ospeed = fromti->c_ospeed; \ - memcpy (((struct __oldtermios*)toti)->c_cc, fromti->c_cc, sizeof(fromti->c_cc)); \ - } \ - toti; \ - }) -#endif /*__GNUC__*/ -#endif - #define termio termios #ifdef __cplusplus diff --git a/winsup/cygwin/termios.cc b/winsup/cygwin/termios.cc index ee9cd23b7..1dfd57079 100644 --- a/winsup/cygwin/termios.cc +++ b/winsup/cygwin/termios.cc @@ -112,7 +112,6 @@ extern "C" int tcsetattr (int fd, int a, const struct termios *t) { int res; - t = __tonew_termios (t); int e = get_errno (); while (1) @@ -165,21 +164,20 @@ tcsetattr (int fd, int a, const struct termios *t) /* tcgetattr: POSIX 7.2.1.1 */ extern "C" int -tcgetattr (int fd, struct termios *in_t) +tcgetattr (int fd, struct termios *t) { int res = -1; - struct termios *t = __makenew_termios (in_t); cygheap_fdget cfd (fd); if (cfd < 0) /* saw an error */; else if (!cfd->is_tty ()) set_errno (ENOTTY); - else if ((res = cfd->tcgetattr (t)) == 0) - __toapp_termios (in_t, t); + else + res = cfd->tcgetattr (t); if (res) - termios_printf ("%R = tcgetattr(%d, %p)", res, fd, in_t); + termios_printf ("%R = tcgetattr(%d, %p)", res, fd, t); else termios_printf ("iflag %y, oflag %y, cflag %y, lflag %y, VMIN %d, VTIME %d", t->c_iflag, t->c_oflag, t->c_cflag, t->c_lflag, t->c_cc[VMIN], @@ -247,14 +245,14 @@ tcsetpgrp (int fd, pid_t pgid) extern "C" speed_t cfgetospeed (const struct termios *tp) { - return __tonew_termios (tp)->c_ospeed; + return tp->c_ospeed; } /* cfgetispeed: POSIX96 7.1.3.1 */ extern "C" speed_t cfgetispeed (const struct termios *tp) { - return __tonew_termios (tp)->c_ispeed; + return tp->c_ispeed; } static inline int @@ -307,22 +305,16 @@ setspeed (speed_t &set_speed, speed_t from_speed) /* cfsetospeed: POSIX96 7.1.3.1 */ extern "C" int -cfsetospeed (struct termios *in_tp, speed_t speed) +cfsetospeed (struct termios *tp, speed_t speed) { - struct termios *tp = __tonew_termios (in_tp); - int res = setspeed (tp->c_ospeed, speed); - __toapp_termios (in_tp, tp); - return res; + return setspeed (tp->c_ospeed, speed); } /* cfsetispeed: POSIX96 7.1.3.1 */ extern "C" int -cfsetispeed (struct termios *in_tp, speed_t speed) +cfsetispeed (struct termios *tp, speed_t speed) { - struct termios *tp = __tonew_termios (in_tp); - int res = setspeed (tp->c_ispeed, speed); - __toapp_termios (in_tp, tp); - return res; + return setspeed (tp->c_ispeed, speed); } struct speed_struct @@ -384,9 +376,8 @@ convert_speed (speed_t speed) /* cfsetspeed: 4.4BSD */ /* Following Linux (undocumented), allow speed to be a numerical baud rate. */ extern "C" int -cfsetspeed (struct termios *in_tp, speed_t speed) +cfsetspeed (struct termios *tp, speed_t speed) { - struct termios *tp = __tonew_termios (in_tp); int res; speed = convert_speed (speed); @@ -394,7 +385,6 @@ cfsetspeed (struct termios *in_tp, speed_t speed) 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; }
reply other threads:[~2022-08-03 14:05 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220803140529.E469A385828D@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).