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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [libc/] [termios/] [tcgetattr.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/* Copyright (C) 1992, 1995, 1997, 1998 Free Software Foundation, Inc.
2
   This file is part of the GNU C Library.
3
 
4
   The GNU C Library is free software; you can redistribute it and/or
5
   modify it under the terms of the GNU Lesser General Public
6
   License as published by the Free Software Foundation; either
7
   version 2.1 of the License, or (at your option) any later version.
8
 
9
   The GNU C Library is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Lesser General Public License for more details.
13
 
14
   You should have received a copy of the GNU Lesser General Public
15
   License along with the GNU C Library; if not, write to the Free
16
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17
   02111-1307 USA.  */
18
 
19
#include <features.h>
20
#define __USE_GNU
21
#include <string.h>
22
#include <termios.h>
23
#include <unistd.h>
24
#include <sys/ioctl.h>
25
#include <sys/types.h>
26
 
27
/* The difference here is that the termios structure used in the
28
   kernel is not the same as we use in the libc.  Therefore we must
29
   translate it here.  */
30
#include "kernel_termios.h"
31
 
32
/* Put the state of FD into *TERMIOS_P.  */
33
int tcgetattr (int fd, struct termios *termios_p)
34
{
35
    struct __kernel_termios k_termios;
36
    int retval;
37
 
38
    retval = ioctl (fd, TCGETS, &k_termios);
39
 
40
    termios_p->c_iflag = k_termios.c_iflag;
41
    termios_p->c_oflag = k_termios.c_oflag;
42
    termios_p->c_cflag = k_termios.c_cflag;
43
    termios_p->c_lflag = k_termios.c_lflag;
44
    termios_p->c_line = k_termios.c_line;
45
#ifdef _HAVE_C_ISPEED
46
    termios_p->c_ispeed = k_termios.c_ispeed;
47
#endif
48
#ifdef _HAVE_C_OSPEED
49
    termios_p->c_ospeed = k_termios.c_ospeed;
50
#endif
51
 
52
 
53
    if (sizeof (cc_t) == 1 || _POSIX_VDISABLE == 0
54
            || (unsigned char) _POSIX_VDISABLE == (unsigned char) -1)
55
    {
56
        memset (mempcpy (&termios_p->c_cc[0], &k_termios.c_cc[0],
57
                    __KERNEL_NCCS * sizeof (cc_t)),
58
                _POSIX_VDISABLE, (NCCS - __KERNEL_NCCS) * sizeof (cc_t));
59
#if 0   
60
        memset ( (memcpy (&termios_p->c_cc[0], &k_termios.c_cc[0],
61
                        __KERNEL_NCCS * sizeof (cc_t)) + (__KERNEL_NCCS * sizeof (cc_t))) ,
62
                _POSIX_VDISABLE, (NCCS - __KERNEL_NCCS) * sizeof (cc_t));
63
#endif
64
    } else {
65
        size_t cnt;
66
 
67
        memcpy (&termios_p->c_cc[0], &k_termios.c_cc[0],
68
                __KERNEL_NCCS * sizeof (cc_t));
69
 
70
        for (cnt = __KERNEL_NCCS; cnt < NCCS; ++cnt)
71
            termios_p->c_cc[cnt] = _POSIX_VDISABLE;
72
    }
73
 
74
    return retval;
75
}
76
 

powered by: WebSVN 2.1.0

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