Back to index

glibc  2.9
Functions | Variables
speed.c File Reference
#include <stddef.h>
#include <errno.h>
#include <termios.h>

Go to the source code of this file.

Functions

speed_t cfgetospeed (struct termios *termios_p) const
speed_t cfgetispeed (struct termios *termios_p) const
int cfsetospeed (struct termios *termios_p, speed_t speed)
 libc_hidden_def (cfsetospeed)

Variables

static const speed_t speeds []

Function Documentation

speed_t cfgetispeed ( struct termios termios_p) const

Definition at line 55 of file speed.c.

{
  return (termios_p->c_cflag & CIBAUD) >> IBSHIFT;
}
speed_t cfgetospeed ( struct termios termios_p) const

Definition at line 47 of file speed.c.

{
  return termios_p->c_cflag & CBAUD;
}
int cfsetospeed ( struct termios termios_p,
speed_t  speed 
)

Definition at line 63 of file speed.c.

{
  register unsigned int i;

  if (termios_p == NULL)
    {
      __set_errno (EINVAL);
      return -1;
    }

  /* This allows either B1200 or 1200 to work.   XXX
     Do we really want to try to support this, given that
     fetching the speed must return one or the other?  */

  for (i = 0; i < sizeof (speeds) / sizeof (speeds[0]); ++i)
    if (i == speed || speeds[i] == speed)
      {
       termios_p->c_cflag &= ~CBAUD;
       termios_p->c_cflag |= i;
       return 0;
      }

  __set_errno (EINVAL);
  return -1;
}

Here is the caller graph for this function:

Definition at line 90 of file speed.c.

{
  register unsigned int i;

  if (termios_p == NULL)
    {
      __set_errno (EINVAL);
      return -1;
    }

  /* See comment in cfsetospeed (above).  */
  for (i = 0; i < sizeof (speeds) / sizeof (speeds[0]); ++i)
    if (i == speed || speeds[i] == speed)
      {
       termios_p->c_cflag &= ~CIBAUD;
       termios_p->c_cflag |= i << IBSHIFT;
       return 0;
      }

  __set_errno (EINVAL);
  return -1;
}

Variable Documentation

const speed_t speeds[] [static]
Initial value:
  {
    0,
    50,
    75,
    110,
    134,
    150,
    200,
    300,
    600,
    1200,
    1800,
    2400,
    4800,
    9600,
    19200,
    38400,
  }

Definition at line 24 of file speed.c.