1 /* Copyright (C) 1992, 1995, 1997, 1998 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
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
22 #include <sys/ioctl.h>
23 #include <sys/types.h>
25 /* The difference here is that the termios structure used in the
26 kernel is not the same as we use in the libc. Therefore we must
28 #include <kernel_termios.h>
30 /* Put the state of FD into *TERMIOS_P. */
32 __tcgetattr (fd
, termios_p
)
34 struct termios
*termios_p
;
36 struct __kernel_termios k_termios
;
39 retval
= __ioctl (fd
, TCGETS
, &k_termios
);
41 termios_p
->c_iflag
= k_termios
.c_iflag
;
42 termios_p
->c_oflag
= k_termios
.c_oflag
;
43 termios_p
->c_cflag
= k_termios
.c_cflag
;
44 termios_p
->c_lflag
= k_termios
.c_lflag
;
45 termios_p
->c_line
= k_termios
.c_line
;
47 termios_p
->c_ispeed
= k_termios
.c_ispeed
;
50 termios_p
->c_ospeed
= k_termios
.c_ospeed
;
52 if (sizeof (cc_t
) == 1 || _POSIX_VDISABLE
== 0
53 || (unsigned char) _POSIX_VDISABLE
== (unsigned char) -1)
54 memset (__mempcpy (&termios_p
->c_cc
[0], &k_termios
.c_cc
[0],
55 __KERNEL_NCCS
* sizeof (cc_t
)),
56 _POSIX_VDISABLE
, (NCCS
- __KERNEL_NCCS
) * sizeof (cc_t
));
61 memcpy (&termios_p
->c_cc
[0], &k_termios
.c_cc
[0],
62 __KERNEL_NCCS
* sizeof (cc_t
));
64 for (cnt
= __KERNEL_NCCS
; cnt
< NCCS
; ++cnt
)
65 termios_p
->c_cc
[cnt
] = _POSIX_VDISABLE
;
71 weak_alias (__tcgetattr
, tcgetattr
)