OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [sys/] [linux/] [cfspeed.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/* `struct termios' speed frobnication functions.  Linux version.
2
   Copyright (C) 1991, 92, 93, 95, 96, 97, 98, 2000 Free Software Foundation, Inc.
3
   This file is part of the GNU C Library.
4
 
5
   The GNU C Library is free software; you can redistribute it and/or
6
   modify it under the terms of the GNU Lesser General Public
7
   License as published by the Free Software Foundation; either
8
   version 2.1 of the License, or (at your option) any later version.
9
 
10
   The GNU C Library is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
   Lesser General Public License for more details.
14
 
15
   You should have received a copy of the GNU Lesser General Public
16
   License along with the GNU C Library; if not, write to the Free
17
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18
   02111-1307 USA.  */
19
 
20
/* Modified by Jeff Johnston, May 27, 2002 to remove kernel hack
21
   as we simply ignore a cfisetspeed of 0 instead of treating it specially */
22
 
23
#include <stddef.h>
24
#include <errno.h>
25
#include <termios.h>
26
 
27
/* Return the output baud rate stored in *TERMIOS_P.  */
28
speed_t
29
cfgetospeed (termios_p)
30
     const struct termios *termios_p;
31
{
32
  return termios_p->c_cflag & (CBAUD | CBAUDEX);
33
}
34
 
35
/* Return the input baud rate stored in *TERMIOS_P.
36
   For Linux there is no difference between input and output
37
   speed. */
38
speed_t
39
cfgetispeed (termios_p)
40
     const struct termios *termios_p;
41
{
42
  return termios_p->c_cflag & (CBAUD | CBAUDEX);
43
}
44
 
45
/* Set the output baud rate stored in *TERMIOS_P to SPEED.  */
46
int
47
cfsetospeed  (termios_p, speed)
48
     struct termios *termios_p;
49
     speed_t speed;
50
{
51
  if ((speed & ~CBAUD) != 0
52
      && (speed < B57600 || speed > __MAX_BAUD))
53
    {
54
      errno = (EINVAL);
55
      return -1;
56
    }
57
 
58
  termios_p->c_cflag &= ~(CBAUD | CBAUDEX);
59
  termios_p->c_cflag |= speed;
60
 
61
  return 0;
62
}
63
 
64
/* Set the input baud rate stored in *TERMIOS_P to SPEED.
65
   Although for Linux there is no difference between input and output
66
   speed, the numerical 0 is a special case for the input baud rate.  It
67
   should set the input baud rate to the output baud rate so we do
68
   nothing. */
69
int
70
cfsetispeed (termios_p, speed)
71
     struct termios *termios_p;
72
     speed_t speed;
73
{
74
  if ((speed & ~CBAUD) != 0
75
      && (speed < B57600 || speed > __MAX_BAUD))
76
    {
77
      errno = (EINVAL);
78
      return -1;
79
    }
80
 
81
  if (speed != 0)
82
    {
83
      termios_p->c_cflag &= ~(CBAUD | CBAUDEX);
84
      termios_p->c_cflag |= speed;
85
    }
86
 
87
  return 0;
88
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.