This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

General termios


termios only depends on ioctl and the various TCxxx and TIOCxxx ioctl
defines. If each function were wrapped in an ifdef Txxx, it should be
possible to move termios to a general source.

Is it better to leave the function undefined, or define the function
to return ENOSYS? Is posix or unix a better home for termios?

Cheers,
Shaun

Index: libc/sys/linux/termios.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/linux/termios.c,v
retrieving revision 1.3
diff -u -r1.3 termios.c
--- libc/sys/linux/termios.c	26 Aug 2002 18:56:08 -0000	1.3
+++ libc/sys/linux/termios.c	2 Jun 2006 16:12:51 -0000
@@ -12,7 +12,12 @@
int
 tcgetattr(int fd,struct termios *termios_p)
{
+#ifdef TCGETS
  return ioctl(fd,TCGETS,termios_p);
+#else
+	errno = ENOSYS;
+	return -1;
+#endif
}


@@ -22,15 +27,21 @@ int cmd;

  switch (optional_actions) {
+#ifdef TCSETS
    case TCSANOW:
      cmd = TCSETS;
    break;
+#endif
+#ifdef TCSETSW
    case TCSADRAIN:
      cmd = TCSETSW;
    break;
+#endif
+#ifdef TCSETSF
    case TCSAFLUSH:
      cmd = TCSETSF;
    break;
+#endif
    default:
      errno = EINVAL;
      return -1;
@@ -44,29 +55,49 @@
{
  int p;

+#ifdef TIOCGPGRP
  if (ioctl(fd,TIOCGPGRP,&p) < 0)
    return (pid_t)-1;
  return (pid_t)p;
+#else
+	errno = ENOSYS;
+	return -1;
+#endif
}


int tcsetpgrp(int fd, pid_t pid) { +#ifdef TIOCSPGRP int p = (int)pid; return ioctl(fd,TIOCSPGRP,&p); +#else + errno = ENOSYS; + return -1; +#endif } #endif /* !_ELIX_LEVEL || _ELIX_LEVEL >= 4 */

int
 tcflow (int fd, int action)
{
+#ifdef TCXONC
  return ioctl (fd, TCXONC, action);
+#else
+	errno = ENOSYS;
+	return -1;
+#endif
}

int
 tcflush (int fd, int queue_selector)
{
+#ifdef TCFLSH
  return ioctl (fd, TCFLSH, queue_selector);
+#else
+	errno = ENOSYS;
+	return -1;
+#endif
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]