From 759d3f3238fea6fd8635d9a7f9463007cf9509e3 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 20 Jun 2008 14:59:37 +0000 Subject: [PATCH] (cfsetspeed): New fun extracted from the code. (cfmakeraw): Move before first use. --- src/ChangeLog | 5 +++++ src/sysdep.c | 44 +++++++++++++++++++++++--------------------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 8acc50cccb..2133a063ce 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-06-20 Stefan Monnier + + * sysdep.c (cfsetspeed): New fun extracted from the code. + (cfmakeraw): Move before first use. + 2008-06-20 Angelo Graziosi (tiny change) * sysdep.c (cfmakeraw): Provide fallback implementation. diff --git a/src/sysdep.c b/src/sysdep.c index 38e4e0e95f..bac8a63818 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -244,10 +244,6 @@ void hft_reset P_ ((struct tty_display_info *)); SIGMASKTYPE sigprocmask_set; -#if !defined (HAVE_CFMAKERAW) -void cfmakeraw(struct termios *); -#endif /* !defined (HAVE_CFMAKERAW */ - #if !defined (HAVE_GET_CURRENT_DIR_NAME) || defined (BROKEN_GET_CURRENT_DIR_NAME) @@ -5420,6 +5416,29 @@ int serial_open (char *port) #endif /* TERMIOS */ #ifdef HAVE_TERMIOS + +#if !defined (HAVE_CFMAKERAW) +/* Workaround for targets which are missing cfmakeraw. */ +/* Pasted from man page. */ +static void cfmakeraw (struct termios *termios_p) +{ + termios_p->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); + termios_p->c_oflag &= ~OPOST; + termios_p->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); + termios_p->c_cflag &= ~(CSIZE|PARENB); + termios_p->c_cflag |= CS8; +} +#endif /* !defined (HAVE_CFMAKERAW */ + +#if !defined (HAVE_CFSETSPEED) +/* Workaround for targets which are missing cfsetspeed. */ +static int cfsetspeed (struct termios *termios_p, speed_t vitesse) +{ + return (cfsetispeed (termios_p, vitesse) + + cfsetospeed (termios_p, vitesse)); +} +#endif + /* For serial-process-configure */ void serial_configure (struct Lisp_Process *p, @@ -5451,12 +5470,7 @@ serial_configure (struct Lisp_Process *p, else tem = Fplist_get (p->childp, QCspeed); CHECK_NUMBER (tem); -#ifdef HAVE_CFSETSPEED err = cfsetspeed (&attr, XINT (tem)); -#else - err = cfsetispeed(&attr, XINT (tem)); - err = err + cfsetospeed(&attr, XINT (tem)); -#endif if (err != 0) error ("cfsetspeed(%d) failed: %s", XINT (tem), emacs_strerror (errno)); childp2 = Fplist_put (childp2, QCspeed, tem); @@ -5586,18 +5600,6 @@ serial_configure (struct Lisp_Process *p, p->childp = childp2; } -#if !defined (HAVE_CFMAKERAW) -/* Workaround for targets which are missing cfmakeraw */ -/* Pasted from man page; added in serial.c arbitrarily */ -void cfmakeraw(struct termios *termios_p) -{ - termios_p->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); - termios_p->c_oflag &= ~OPOST; - termios_p->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); - termios_p->c_cflag &= ~(CSIZE|PARENB); - termios_p->c_cflag |= CS8; -} -#endif /* !defined (HAVE_CFMAKERAW */ #endif /* TERMIOS */ /* arch-tag: edb43589-4e09-4544-b325-978b5b121dcf -- 2.20.1