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 \
|
#define CYGWIN_VERSION_USER_API_VERSION_COMBINED \
|
||||||
CYGWIN_VERSION_PER_PROCESS_API_VERSION_COMBINED (user_data)
|
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
|
#define CYGWIN_VERSION_DLL_MALLOC_ENV 28
|
||||||
|
|
||||||
/* Old APIs had getc/putc macros that conflict with new CR/LF handling in the
|
/* 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;
|
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
|
#define termio termios
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -112,7 +112,6 @@ extern "C" int
|
||||||
tcsetattr (int fd, int a, const struct termios *t)
|
tcsetattr (int fd, int a, const struct termios *t)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
t = __tonew_termios (t);
|
|
||||||
int e = get_errno ();
|
int e = get_errno ();
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
|
@ -165,21 +164,20 @@ tcsetattr (int fd, int a, const struct termios *t)
|
||||||
|
|
||||||
/* tcgetattr: POSIX 7.2.1.1 */
|
/* tcgetattr: POSIX 7.2.1.1 */
|
||||||
extern "C" int
|
extern "C" int
|
||||||
tcgetattr (int fd, struct termios *in_t)
|
tcgetattr (int fd, struct termios *t)
|
||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
struct termios *t = __makenew_termios (in_t);
|
|
||||||
|
|
||||||
cygheap_fdget cfd (fd);
|
cygheap_fdget cfd (fd);
|
||||||
if (cfd < 0)
|
if (cfd < 0)
|
||||||
/* saw an error */;
|
/* saw an error */;
|
||||||
else if (!cfd->is_tty ())
|
else if (!cfd->is_tty ())
|
||||||
set_errno (ENOTTY);
|
set_errno (ENOTTY);
|
||||||
else if ((res = cfd->tcgetattr (t)) == 0)
|
else
|
||||||
__toapp_termios (in_t, t);
|
res = cfd->tcgetattr (t);
|
||||||
|
|
||||||
if (res)
|
if (res)
|
||||||
termios_printf ("%R = tcgetattr(%d, %p)", res, fd, in_t);
|
termios_printf ("%R = tcgetattr(%d, %p)", res, fd, t);
|
||||||
else
|
else
|
||||||
termios_printf ("iflag %y, oflag %y, cflag %y, lflag %y, VMIN %d, VTIME %d",
|
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],
|
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
|
extern "C" speed_t
|
||||||
cfgetospeed (const struct termios *tp)
|
cfgetospeed (const struct termios *tp)
|
||||||
{
|
{
|
||||||
return __tonew_termios (tp)->c_ospeed;
|
return tp->c_ospeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cfgetispeed: POSIX96 7.1.3.1 */
|
/* cfgetispeed: POSIX96 7.1.3.1 */
|
||||||
extern "C" speed_t
|
extern "C" speed_t
|
||||||
cfgetispeed (const struct termios *tp)
|
cfgetispeed (const struct termios *tp)
|
||||||
{
|
{
|
||||||
return __tonew_termios (tp)->c_ispeed;
|
return tp->c_ispeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
|
@ -307,22 +305,16 @@ setspeed (speed_t &set_speed, speed_t from_speed)
|
||||||
|
|
||||||
/* cfsetospeed: POSIX96 7.1.3.1 */
|
/* cfsetospeed: POSIX96 7.1.3.1 */
|
||||||
extern "C" int
|
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);
|
return setspeed (tp->c_ospeed, speed);
|
||||||
int res = setspeed (tp->c_ospeed, speed);
|
|
||||||
__toapp_termios (in_tp, tp);
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cfsetispeed: POSIX96 7.1.3.1 */
|
/* cfsetispeed: POSIX96 7.1.3.1 */
|
||||||
extern "C" int
|
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);
|
return setspeed (tp->c_ispeed, speed);
|
||||||
int res = setspeed (tp->c_ispeed, speed);
|
|
||||||
__toapp_termios (in_tp, tp);
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct speed_struct
|
struct speed_struct
|
||||||
|
@ -384,9 +376,8 @@ convert_speed (speed_t speed)
|
||||||
/* cfsetspeed: 4.4BSD */
|
/* cfsetspeed: 4.4BSD */
|
||||||
/* Following Linux (undocumented), allow speed to be a numerical baud rate. */
|
/* Following Linux (undocumented), allow speed to be a numerical baud rate. */
|
||||||
extern "C" int
|
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;
|
int res;
|
||||||
|
|
||||||
speed = convert_speed (speed);
|
speed = convert_speed (speed);
|
||||||
|
@ -394,7 +385,6 @@ cfsetspeed (struct termios *in_tp, speed_t speed)
|
||||||
identical results in both calls */
|
identical results in both calls */
|
||||||
if ((res = setspeed (tp->c_ospeed, speed)) == 0)
|
if ((res = setspeed (tp->c_ospeed, speed)) == 0)
|
||||||
setspeed (tp->c_ispeed, speed);
|
setspeed (tp->c_ispeed, speed);
|
||||||
__toapp_termios (in_tp, tp);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue