* src/fileio.c:
[bpt/emacs.git] / src / sysdep.c
index 6c3e0e4..4e9631d 100644 (file)
@@ -135,18 +135,10 @@ extern int errno;
 #include "systty.h"
 #include "syswait.h"
 
-#ifdef BROKEN_TIOCGWINSZ
-#undef TIOCGWINSZ
-#undef TIOCSWINSZ
-#endif
-
 #if defined (USG)
 #include <sys/utsname.h>
 #include <memory.h>
 #if defined (TIOCGWINSZ)
-#ifdef NEED_SIOCTL
-#include <sys/sioctl.h>
-#endif
 #ifdef NEED_PTEM_H
 #include <sys/stream.h>
 #include <sys/ptem.h>
@@ -166,12 +158,17 @@ extern int quit_char;
 #include "process.h"
 #include "cm.h"  /* for reset_sys_modes */
 
+/* For serial_configure and serial_open.  */
+extern Lisp_Object QCport, QCspeed, QCprocess;
+extern Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven;
+extern Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary;
+
 #ifdef WINDOWSNT
 #include <direct.h>
 /* In process.h which conflicts with the local copy.  */
 #define _P_WAIT 0
-int _CRTAPI1 _spawnlp (int, const char *, const char *, ...);
-int _CRTAPI1 _getpid (void);
+int _cdecl _spawnlp (int, const char *, const char *, ...);
+int _cdecl _getpid (void);
 extern char *getwd (char *);
 #endif
 
@@ -201,10 +198,6 @@ struct utimbuf {
 #define LPASS8 0
 #endif
 
-#ifdef BSD4_1
-#define LNOFLSH 0100000
-#endif
-
 static int baud_convert[] =
 #ifdef BAUD_CONVERT
   BAUD_CONVERT;
@@ -230,11 +223,6 @@ int emacs_ospeed;
 
 void croak P_ ((char *)) NO_RETURN;
 
-#ifdef AIXHFT
-void hft_init P_ ((struct tty_display_info *));
-void hft_reset P_ ((struct tty_display_info *));
-#endif
-
 /* Temporary used by `sigblock' when defined in terms of signprocmask.  */
 
 SIGMASKTYPE sigprocmask_set;
@@ -478,7 +466,7 @@ wait_for_termination (pid)
       status = SYS$FORCEX (&pid, 0, 0);
       break;
 #else /* not VMS */
-#if defined (BSD_SYSTEM) || (defined (HPUX) && !defined (HPUX_5))
+#if defined (BSD_SYSTEM) || defined (HPUX)
       /* Note that kill returns -1 even if the process is just a zombie now.
         But inevitably a SIGCHLD interrupt should be generated
         and child_sig will do wait3 and make the process go away. */
@@ -537,16 +525,9 @@ wait_for_termination (pid)
 #if __DJGPP__ > 1
       break;
 #else /* not __DJGPP__ > 1 */
-#ifndef BSD4_1
       if (kill (pid, 0) < 0)
        break;
       wait (0);
-#else /* BSD4_1 */
-      int status;
-      status = wait (0);
-      if (status == pid || status == -1)
-       break;
-#endif /* BSD4_1 */
 #endif /* not __DJGPP__ > 1*/
 #endif /* not subprocesses */
     }
@@ -690,10 +671,6 @@ child_setup_tty (out)
 
   EMACS_SET_TTY (out, &s, 0);
 
-#ifdef BSD4_1
-  if (interrupt_input)
-    reset_sigio (0);
-#endif /* BSD4_1 */
 #endif /* not DOS_NT */
 }
 #endif /* not VMS */
@@ -1262,12 +1239,6 @@ emacs_set_tty (fd, settings, flushp)
 
 \f
 
-#ifdef BSD4_1
-/* BSD 4.1 needs to keep track of the lmode bits in order to start
-   sigio.  */
-int lmode;
-#endif
-
 #ifdef F_SETOWN
 int old_fcntl_owner[MAXDESC];
 #endif /* F_SETOWN */
@@ -1276,15 +1247,11 @@ int old_fcntl_owner[MAXDESC];
    but if so, this does no harm,
    and using the same name avoids wasting the other one's space.  */
 
-#ifdef nec_ews_svr4
-extern char *_sobuf ;
-#else
 #if defined (USG) || defined (DGUX)
 unsigned char _sobuf[BUFSIZ+8];
 #else
 char _sobuf[BUFSIZ];
 #endif
-#endif
 
 #ifdef HAVE_LTCHARS
 static struct ltchars new_ltchars = {-1,-1,-1,-1,-1,-1};
@@ -1490,11 +1457,6 @@ init_sys_modes (tty_out)
     }
 #endif /* mips or HAVE_TCATTR */
 
-#ifdef SET_LINE_DISCIPLINE
-  /* Need to explicitly request TERMIODISC line discipline or
-     Ultrix's termios does not work correctly.  */
-  tty.main.c_line = SET_LINE_DISCIPLINE;
-#endif
 #ifdef AIX
 #ifndef IBMR2AIX
   /* AIX enhanced edit loses NULs, so disable it.  */
@@ -1561,16 +1523,7 @@ init_sys_modes (tty_out)
     }
   
   tty.lmode = LDECCTQ | LLITOUT | LPASS8 | LNOFLSH | tty_out->old_tty.lmode;
-#ifdef ultrix
-  /* Under Ultrix 4.2a, leaving this out doesn't seem to hurt
-     anything, and leaving it in breaks the meta key.  Go figure.  */
-  tty.lmode &= ~LLITOUT;
-#endif
   
-#ifdef BSD4_1
-  lmode = tty.lmode;
-#endif
-
 #endif /* HAVE_TCHARS */
 #endif /* not HAVE_TERMIO */
 
@@ -1595,26 +1548,12 @@ init_sys_modes (tty_out)
   if (!tty_out->flow_control) ioctl (fileno (tty_out->input), TIOCSTART, 0);
 #endif
 
-#if defined (HAVE_TERMIOS) || defined (HPUX9)
+#if defined (HAVE_TERMIOS) || defined (HPUX)
 #ifdef TCOON
   if (!tty_out->flow_control) tcflow (fileno (tty_out->input), TCOON);
 #endif
 #endif
 
-#ifdef AIXHFT
-  hft_init (tty_out);
-#ifdef IBMR2AIX
-  {
-    /* IBM's HFT device usually thinks a ^J should be LF/CR.  We need it
-       to be only LF.  This is the way that is done. */
-    struct termio tty;
-    
-    if (ioctl (1, HFTGETID, &tty) != -1)
-      write (1, "\033[20l", 5);
-  }
-#endif
-#endif /* AIXHFT */
-
 #ifdef VMS
 /*  Appears to do nothing when in PASTHRU mode.
       SYS$QIOW (0, fileno (tty_out->input), IO$_SETMODE|IO$M_OUTBAND, 0, 0, 0,
@@ -1644,11 +1583,6 @@ init_sys_modes (tty_out)
 #endif /* F_GETOWN */
 #endif /* F_SETFL */
 
-#ifdef BSD4_1
-  if (interrupt_input)
-    init_sigio (fileno (tty_out->input));
-#endif
-
 #ifdef VMS  /* VMS sometimes has this symbol but lacks setvbuf.  */
 #undef _IOFBF
 #endif
@@ -1863,26 +1797,13 @@ reset_sys_modes (tty_out)
   cmgoto (tty_out, FrameRows (tty_out) - 1, 0);
   fflush (tty_out->output);
   
-#if defined (IBMR2AIX) && defined (AIXHFT)
-  {
-    /* HFT devices normally use ^J as a LF/CR.  We forced it to
-       do the LF only.  Now, we need to reset it. */
-    struct termio tty;
-
-    if (ioctl (1, HFTGETID, &tty) != -1)
-      write (1, "\033[20h", 5);
-  }
-#endif
-
   if (tty_out->terminal->reset_terminal_modes_hook)
     tty_out->terminal->reset_terminal_modes_hook (tty_out->terminal);
 
 #ifdef BSD_SYSTEM
-#ifndef BSD4_1
   /* Avoid possible loss of output when changing terminal modes.  */
   fsync (fileno (tty_out->output));
 #endif
-#endif
 
 #ifdef F_SETFL
 #ifdef F_SETOWN                /* F_SETFL does not imply existence of F_SETOWN */
@@ -1898,10 +1819,6 @@ reset_sys_modes (tty_out)
          fcntl (fileno (tty_out->input), F_GETFL, 0) & ~O_NDELAY);
 #endif
 #endif /* F_SETFL */
-#ifdef BSD4_1
-  if (interrupt_input)
-    reset_sigio (fileno (tty_out->input));
-#endif /* BSD4_1 */
 
   if (tty_out->old_tty)
     while (EMACS_SET_TTY (fileno (tty_out->input),
@@ -1912,17 +1829,6 @@ reset_sys_modes (tty_out)
   dos_ttcooked ();
 #endif
 
-#ifdef SET_LINE_DISCIPLINE
-  /* Ultrix's termios *ignores* any line discipline except TERMIODISC.
-     A different old line discipline is therefore not restored, yet.
-     Restore the old line discipline by hand.  */
-  ioctl (0, TIOCSETD, &tty_out->old_tty.main.c_line);
-#endif
-
-#ifdef AIXHFT
-  hft_reset ();
-#endif
-
 #ifdef BSD_PGRPS
   widen_foreground_group (fileno (tty_out->input));
 #endif
@@ -2313,20 +2219,14 @@ start_of_data ()
 /* init_system_name sets up the string for the Lisp function
    system-name to return. */
 
-#ifdef BSD4_1
-#include <whoami.h>
-#endif
-
 extern Lisp_Object Vsystem_name;
 
-#ifndef BSD4_1
 #ifndef VMS
 #ifdef HAVE_SOCKETS
 #include <sys/socket.h>
 #include <netdb.h>
 #endif /* HAVE_SOCKETS */
 #endif /* not VMS */
-#endif /* not BSD4_1 */
 
 #ifdef TRY_AGAIN
 #ifndef HAVE_H_ERRNO
@@ -2337,9 +2237,6 @@ extern int h_errno;
 void
 init_system_name ()
 {
-#ifdef BSD4_1
-  Vsystem_name = build_string (sysname);
-#else
 #ifdef VMS
   char *sp, *end;
   if ((sp = egetenv ("SYS$NODE")) == 0)
@@ -2520,7 +2417,6 @@ init_system_name ()
   Vsystem_name = build_string (hostname);
 #endif /* HAVE_GETHOSTNAME */
 #endif /* VMS */
-#endif /* BSD4_1 */
   {
     unsigned char *p;
     for (p = SDATA (Vsystem_name); *p; p++)
@@ -2562,11 +2458,7 @@ SIGTYPE
 select_alarm ()
 {
   select_alarmed = 1;
-#ifdef BSD4_1
-  sigrelse (SIGALRM);
-#else /* not BSD4_1 */
   signal (SIGALRM, SIG_IGN);
-#endif /* not BSD4_1 */
   SIGNAL_THREAD_CHECK (SIGALRM);
   if (read_alarm_should_throw)
     longjmp (read_alarm_throw, 1);
@@ -2777,93 +2669,6 @@ read_input_waiting ()
 #endif /* not VMS */
 #endif /* not MSDOS */
 \f
-#ifdef BSD4_1
-void
-init_sigio (fd)
-     int fd;
-{
-  if (noninteractive)
-    return;
-  lmode = LINTRUP | lmode;
-  ioctl (fd, TIOCLSET, &lmode);
-}
-
-void
-reset_sigio (fd)
-     int fd;
-{
-  if (noninteractive)
-    return;
-  lmode = ~LINTRUP & lmode;
-  ioctl (fd, TIOCLSET, &lmode);
-}
-
-void
-request_sigio ()
-{
-  if (noninteractive)
-    return;
-  sigrelse (SIGTINT);
-
-  interrupts_deferred = 0;
-}
-
-void
-unrequest_sigio ()
-{
-  if (noninteractive)
-    return;
-  sighold (SIGTINT);
-
-  interrupts_deferred = 1;
-}
-
-/* still inside #ifdef BSD4_1 */
-#ifdef subprocesses
-
-int sigheld; /* Mask of held signals */
-
-void
-sigholdx (signum)
-     int signum;
-{
-  sigheld |= sigbit (signum);
-  sighold (signum);
-}
-
-void
-sigisheld (signum)
-     int signum;
-{
-  sigheld |= sigbit (signum);
-}
-
-void
-sigunhold (signum)
-     int signum;
-{
-  sigheld &= ~sigbit (signum);
-  sigrelse (signum);
-}
-
-void
-sigfree ()    /* Free all held signals */
-{
-  int i;
-  for (i = 0; i < NSIG; i++)
-    if (sigheld & sigbit (i))
-      sigrelse (i);
-  sigheld = 0;
-}
-
-int
-sigbit (i)
-{
-  return 1 << (i - 1);
-}
-#endif /* subprocesses */
-#endif /* BSD4_1 */
-\f
 /* POSIX signals support - DJB */
 /* Anyone with POSIX signals should have ANSI C declarations */
 
@@ -3322,11 +3127,6 @@ emacs_open (path, oflag, mode)
 {
   register int rtnval;
 
-#ifdef BSD4_1
-  if (oflag & O_CREAT)
-    return creat (path, mode);
-#endif
-
   while ((rtnval = open (path, oflag, mode)) == -1
         && (errno == EINTR))
     QUIT;
@@ -5184,100 +4984,6 @@ srandom (seed)
 }
 #endif /* VMS */
 \f
-#ifdef AIXHFT
-
-/* Called from init_sys_modes.  */
-void
-hft_init (struct tty_display_info *tty_out)
-{
-  int junk;
-
-  /* If we're not on an HFT we shouldn't do any of this.  We determine
-     if we are on an HFT by trying to get an HFT error code.  If this
-     call fails, we're not on an HFT. */
-#ifdef IBMR2AIX
-  if (ioctl (0, HFQERROR, &junk) < 0)
-    return;
-#else /* not IBMR2AIX */
-  if (ioctl (0, HFQEIO, 0) < 0)
-    return;
-#endif /* not IBMR2AIX */
-
-  /* On AIX the default hft keyboard mapping uses backspace rather than delete
-     as the rubout key's ASCII code.  Here this is changed.  The bug is that
-     there's no way to determine the old mapping, so in reset_sys_modes
-     we need to assume that the normal map had been present.  Of course, this
-     code also doesn't help if on a terminal emulator which doesn't understand
-     HFT VTD's.  */
-  {
-    struct hfbuf buf;
-    struct hfkeymap keymap;
-
-    buf.hf_bufp = (char *)&keymap;
-    buf.hf_buflen = sizeof (keymap);
-    keymap.hf_nkeys = 2;
-    keymap.hfkey[0].hf_kpos = 15;
-    keymap.hfkey[0].hf_kstate = HFMAPCHAR | HFSHFNONE;
-#ifdef IBMR2AIX
-    keymap.hfkey[0].hf_keyidh = '<';
-#else /* not IBMR2AIX */
-    keymap.hfkey[0].hf_page = '<';
-#endif /* not IBMR2AIX */
-    keymap.hfkey[0].hf_char = 127;
-    keymap.hfkey[1].hf_kpos = 15;
-    keymap.hfkey[1].hf_kstate = HFMAPCHAR | HFSHFSHFT;
-#ifdef IBMR2AIX
-    keymap.hfkey[1].hf_keyidh = '<';
-#else /* not IBMR2AIX */
-    keymap.hfkey[1].hf_page = '<';
-#endif /* not IBMR2AIX */
-    keymap.hfkey[1].hf_char = 127;
-    hftctl (0, HFSKBD, &buf);
-  }
-}
-
-/* Reset the rubout key to backspace.  */
-
-void
-hft_reset (struct tty_display_info *tty_out)
-{
-  struct hfbuf buf;
-  struct hfkeymap keymap;
-  int junk;
-
-#ifdef IBMR2AIX
-  if (ioctl (0, HFQERROR, &junk) < 0)
-    return;
-#else /* not IBMR2AIX */
-  if (ioctl (0, HFQEIO, 0) < 0)
-    return;
-#endif /* not IBMR2AIX */
-
-  buf.hf_bufp = (char *)&keymap;
-  buf.hf_buflen = sizeof (keymap);
-  keymap.hf_nkeys = 2;
-  keymap.hfkey[0].hf_kpos = 15;
-  keymap.hfkey[0].hf_kstate = HFMAPCHAR | HFSHFNONE;
-#ifdef IBMR2AIX
-  keymap.hfkey[0].hf_keyidh = '<';
-#else /* not IBMR2AIX */
-  keymap.hfkey[0].hf_page = '<';
-#endif /* not IBMR2AIX */
-  keymap.hfkey[0].hf_char = 8;
-  keymap.hfkey[1].hf_kpos = 15;
-  keymap.hfkey[1].hf_kstate = HFMAPCHAR | HFSHFSHFT;
-#ifdef IBMR2AIX
-  keymap.hfkey[1].hf_keyidh = '<';
-#else /* not IBMR2AIX */
-  keymap.hfkey[1].hf_page = '<';
-#endif /* not IBMR2AIX */
-  keymap.hfkey[1].hf_char = 8;
-  hftctl (0, HFSKBD, &buf);
-}
-
-#endif /* AIXHFT */
-
-\f
 #ifndef BSTRING
 
 #ifndef bzero
@@ -5379,6 +5085,223 @@ strsignal (code)
   return signame;
 }
 #endif /* HAVE_STRSIGNAL */
+\f
+#ifdef HAVE_TERMIOS
+/* For make-serial-process  */
+int serial_open (char *port)
+{
+  int fd = -1;
+
+  fd = emacs_open ((char*) port,
+                  O_RDWR
+#ifdef O_NONBLOCK
+                  | O_NONBLOCK
+#else
+                  | O_NDELAY
+#endif
+#ifdef O_NOCTTY
+                  | O_NOCTTY
+#endif
+                  , 0);
+  if (fd < 0)
+    {
+      error ("Could not open %s: %s",
+            port, emacs_strerror (errno));
+    }
+#ifdef TIOCEXCL
+  ioctl (fd, TIOCEXCL, (char *) 0);
+#endif
+
+  return fd;
+}
+#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,
+                     Lisp_Object contact)
+{
+  Lisp_Object childp2 = Qnil;
+  Lisp_Object tem = Qnil;
+  struct termios attr;
+  int err = -1;
+  char summary[4] = "???"; /* This usually becomes "8N1".  */
+
+  childp2 = Fcopy_sequence (p->childp);
+
+  /* Read port attributes and prepare default configuration.  */
+  err = tcgetattr (p->outfd, &attr);
+  if (err != 0)
+    error ("tcgetattr() failed: %s", emacs_strerror (errno));
+  cfmakeraw (&attr);
+#if defined (CLOCAL)
+  attr.c_cflag |= CLOCAL;
+#endif
+#if defined (CREAD)
+  attr.c_cflag | CREAD;
+#endif
+
+  /* Configure speed.  */
+  if (!NILP (Fplist_member (contact, QCspeed)))
+    tem = Fplist_get (contact, QCspeed);
+  else
+    tem = Fplist_get (p->childp, QCspeed);
+  CHECK_NUMBER (tem);
+  err = cfsetspeed (&attr, XINT (tem));
+  if (err != 0)
+    error ("cfsetspeed(%d) failed: %s", XINT (tem), emacs_strerror (errno));
+  childp2 = Fplist_put (childp2, QCspeed, tem);
+
+  /* Configure bytesize.  */
+  if (!NILP (Fplist_member (contact, QCbytesize)))
+    tem = Fplist_get (contact, QCbytesize);
+  else
+    tem = Fplist_get (p->childp, QCbytesize);
+  if (NILP (tem))
+    tem = make_number (8);
+  CHECK_NUMBER (tem);
+  if (XINT (tem) != 7 && XINT (tem) != 8)
+    error (":bytesize must be nil (8), 7, or 8");
+  summary[0] = XINT(tem) + '0';
+#if defined (CSIZE) && defined (CS7) && defined (CS8)
+  attr.c_cflag &= ~CSIZE;
+  attr.c_cflag |= ((XINT (tem) == 7) ? CS7 : CS8);
+#else
+  /* Don't error on bytesize 8, which should be set by cfmakeraw.  */
+  if (XINT (tem) != 8)
+    error ("Bytesize cannot be changed");
+#endif
+  childp2 = Fplist_put (childp2, QCbytesize, tem);
+
+  /* Configure parity.  */
+  if (!NILP (Fplist_member (contact, QCparity)))
+    tem = Fplist_get (contact, QCparity);
+  else
+    tem = Fplist_get (p->childp, QCparity);
+  if (!NILP (tem) && !EQ (tem, Qeven) && !EQ (tem, Qodd))
+    error (":parity must be nil (no parity), `even', or `odd'");
+#if defined (PARENB) && defined (PARODD) && defined (IGNPAR) && defined (INPCK)
+  attr.c_cflag &= ~(PARENB | PARODD);
+  attr.c_iflag &= ~(IGNPAR | INPCK);
+  if (NILP (tem))
+    {
+      summary[1] = 'N';
+    }
+  else if (EQ (tem, Qeven))
+    {
+      summary[1] = 'E';
+      attr.c_cflag |= PARENB;
+      attr.c_iflag |= (IGNPAR | INPCK);
+    }
+  else if (EQ (tem, Qodd))
+    {
+      summary[1] = 'O';
+      attr.c_cflag |= (PARENB | PARODD);
+      attr.c_iflag |= (IGNPAR | INPCK);
+    }
+#else
+  /* Don't error on no parity, which should be set by cfmakeraw.  */
+  if (!NILP (tem))
+    error ("Parity cannot be configured");
+#endif
+  childp2 = Fplist_put (childp2, QCparity, tem);
+
+  /* Configure stopbits.  */
+  if (!NILP (Fplist_member (contact, QCstopbits)))
+    tem = Fplist_get (contact, QCstopbits);
+  else
+    tem = Fplist_get (p->childp, QCstopbits);
+  if (NILP (tem))
+    tem = make_number (1);
+  CHECK_NUMBER (tem);
+  if (XINT (tem) != 1 && XINT (tem) != 2)
+    error (":stopbits must be nil (1 stopbit), 1, or 2");
+  summary[2] = XINT (tem) + '0';
+#if defined (CSTOPB)
+  attr.c_cflag &= ~CSTOPB;
+  if (XINT (tem) == 2)
+    attr.c_cflag |= CSTOPB;
+#else
+  /* Don't error on 1 stopbit, which should be set by cfmakeraw.  */
+  if (XINT (tem) != 1)
+    error ("Stopbits cannot be configured");
+#endif
+  childp2 = Fplist_put (childp2, QCstopbits, tem);
+
+  /* Configure flowcontrol.  */
+  if (!NILP (Fplist_member (contact, QCflowcontrol)))
+    tem = Fplist_get (contact, QCflowcontrol);
+  else
+    tem = Fplist_get (p->childp, QCflowcontrol);
+  if (!NILP (tem) && !EQ (tem, Qhw) && !EQ (tem, Qsw))
+    error (":flowcontrol must be nil (no flowcontrol), `hw', or `sw'");
+#if defined (CRTSCTS)
+  attr.c_cflag &= ~CRTSCTS;
+#endif
+#if defined (CNEW_RTSCTS)
+  attr.c_cflag &= ~CNEW_RTSCTS;
+#endif
+#if defined (IXON) && defined (IXOFF)
+  attr.c_iflag &= ~(IXON | IXOFF);
+#endif
+  if (NILP (tem))
+    {
+      /* Already configured.  */
+    }
+  else if (EQ (tem, Qhw))
+    {
+#if defined (CRTSCTS)
+      attr.c_cflag |= CRTSCTS;
+#elif defined (CNEW_RTSCTS)
+      attr.c_cflag |= CNEW_RTSCTS;
+#else
+      error ("Hardware flowcontrol (RTS/CTS) not supported");
+#endif
+    }
+  else if (EQ (tem, Qsw))
+    {
+#if defined (IXON) && defined (IXOFF)
+      attr.c_iflag |= (IXON | IXOFF);
+#else
+      error ("Software flowcontrol (XON/XOFF) not supported");
+#endif
+    }
+  childp2 = Fplist_put (childp2, QCflowcontrol, tem);
+
+  /* Activate configuration.  */
+  err = tcsetattr (p->outfd, TCSANOW, &attr);
+  if (err != 0)
+    error ("tcsetattr() failed: %s", emacs_strerror (errno));
+
+  childp2 = Fplist_put (childp2, QCsummary, build_string (summary));
+  p->childp = childp2;
+
+}
+#endif /* TERMIOS  */
 
 /* arch-tag: edb43589-4e09-4544-b325-978b5b121dcf
    (do not change this comment) */