mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-19 04:49:25 +08:00
Cygwin: drop macro and code for CYGWIN_VERSION_DLL_IS_OLD_TERMIOS
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
2902b3a09e
commit
02b273a688
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user