1 /* Copyright (C) 2000 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
21 #include "aix-termios.h"
24 tcsetattr (fd
, optional_actions
, linuxtermios_p
)
27 const struct termios
*linuxtermios_p
;
29 struct aixtermios aixtermios
;
32 /* `optional_actions' does not have to be changed, AIX uses the
33 same values as Linux. */
35 aixtermios
.c_cc
[AIX_VINTR
] = linuxtermios_p
->c_cc
[VINTR
];
36 aixtermios
.c_cc
[AIX_VQUIT
] = linuxtermios_p
->c_cc
[VQUIT
];
37 aixtermios
.c_cc
[AIX_VERASE
] = linuxtermios_p
->c_cc
[VERASE
];
38 aixtermios
.c_cc
[AIX_VKILL
] = linuxtermios_p
->c_cc
[VKILL
];
39 aixtermios
.c_cc
[AIX_VEOF
] = linuxtermios_p
->c_cc
[VEOF
];
40 // XXX VMIN has the same value as VEOF !?
41 aixtermios
.c_cc
[AIX_VEOL
] = linuxtermios_p
->c_cc
[VEOL
];
42 // XXX VTIME has the same value as VEOL !?
43 aixtermios
.c_cc
[AIX_VEOL2
] = linuxtermios_p
->c_cc
[VEOL2
];
44 aixtermios
.c_cc
[AIX_VSTART
] = linuxtermios_p
->c_cc
[VSTART
];
45 aixtermios
.c_cc
[AIX_VSTOP
] = linuxtermios_p
->c_cc
[VSTOP
];
46 aixtermios
.c_cc
[AIX_VSUSP
] = linuxtermios_p
->c_cc
[VSUSP
];
47 aixtermios
.c_cc
[AIX_VDSUSP
] = 0; // XXX No Linux equivalent !?
48 aixtermios
.c_cc
[AIX_VREPRINT
] = linuxtermios_p
->c_cc
[VREPRINT
];
49 aixtermios
.c_cc
[AIX_VDISCARD
] = linuxtermios_p
->c_cc
[VDISCARD
];
50 aixtermios
.c_cc
[AIX_VWERASE
] = linuxtermios_p
->c_cc
[VWERASE
];
51 aixtermios
.c_cc
[AIX_VLNEXT
] = linuxtermios_p
->c_cc
[VLNEXT
];
53 /* AIX has not all the speeds (the high one) Linux supports. The
54 symbol names and values used for the speeds are fortunately the
56 if ((linuxtermios_p
->c_cflag
& CBAUD
) > B38400
)
62 aixtermios
.c_c_flag
= linuxtermios_p
->c_cflag
& CBAUD
;
64 /* Only the IUCLC, IXANY, and IMAXBEL values are different in the
66 aixtermios
.c_iflag
= linuxtermios_p
->c_iflag
& 0x7ff;
67 if (linuxtermios_p
->c_iflag
& IXANY
)
68 aixtermios
.c_iflag
|= AIX_IXANY
;
69 if (linuxtermios_p
->c_iflag
& IUCLC
)
70 aixtermios
.c_iflag
|= AIX_IUCLC
;
71 if (linuxtermios_p
->c_iflag
& IMAXBEL
)
72 aixtermios
.c_iflag
|= AIX_IMAXBEL
;
74 /* Many of the c_oflag files differ. Bummer. */
75 aixtermios
.c_oflag
= (linuxtermios_p
->c_oflag
76 & (OPOST
| OCRNL
| ONOCR
| ONLRET
| OFILL
78 if (linuxtermios_p
->c_oflag
& OLCUC
)
79 aixtermios
.c_oflag
|= AIX_OLCUC
;
80 if (linuxtermios_p
->c_oflag
& ONLCR
)
81 aixtermios
.c_oflag
|= AIX_ONLCR
;
82 if (linuxtermios_p
->c_oflag
& NLDLY
)
84 if ((linuxtermios_p
->c_oflag
& NLDLY
) >= NL2
)
90 if (linuxtermios_p
->c_oflag
& NLDLY
)
91 aixtermios
.c_oflag
|= AIX_NL1
;
93 if (linuxtermios_p
->c_oflag
& TABDLY
)
96 #if TAB1 >> offset != AIX_TAB1 || TAB3 >> offset != AIX_TAB3
97 # error "Check the offset"
99 aixtermios
.c_oflag
|= (linuxtermios_p
->c_oflag
>> offset
) & AIX_TABDLY
;
102 if (linuxtermios_p
->c_oflag
& FFDLY
)
103 aixtermios
.c_oflag
|= AIX_FF1
;
104 if (linuxtermios_p
->c_oflag
& BSDLY
)
105 aixtermios
.c_oflag
|= AIX_BS1
;
106 if (linuxtermios_p
->c_oflag
& VTDLY
)
107 aixtermios
.c_oflag
|= AIX_VT1
;
109 /* A lot of the c_cflag member is also different. */
110 if (linuxtermios_p
->c_cflag
& CSIZE
)
113 #if CSIZE >> offset != AIX_CSIZE
114 # error "Check the offset"
116 aixtermios
.c_cflag
|= (linuxtermios_p
->c_cflag
>> offset
) & AIX_CSIZE
;
120 if (linuxtermios_p
->c_cflag
& STOPB
)
121 aixtermios
.c_cflag
|= AIX_STOPB
;
122 if (linuxtermios_p
->c_cflag
& CREAD
)
123 aixtermios
.c_cflag
|= AIX_CREAD
;
124 if (linuxtermios_p
->c_cflag
& PARENB
)
125 aixtermios
.c_cflag
|= AIX_PARENB
;
126 if (linuxtermios_p
->c_cflag
& PARODD
)
127 aixtermios
.c_cflag
|= AIX_PARODD
;
128 if (linuxtermios_p
->c_cflag
& HUPCL
)
129 aixtermios
.c_cflag
|= AIX_HUPCL
;
130 if (linuxtermios_p
->c_cflag
& CLOCAL
)
131 aixtermios
.c_cflag
|= AIX_CLOCAL
;
133 /* The c_lflag is information is also different. */
134 aixtermios
.c_lflag
= 0;
135 if (linuxtermios_p
->c_lflag
& ISIG
)
136 aixtermios
.c_lflag
|= AIX_ISIG
;
137 if (linuxtermios_p
->c_lflag
& ICANON
)
138 aixtermios
.c_lflag
|= AIX_ICANON
;
139 if (linuxtermios_p
->c_lflag
& XCASE
)
140 aixtermios
.c_lflag
|= AIX_XCASE
;
141 if (linuxtermios_p
->c_lflag
& ECHO
)
142 aixtermios
.c_lflag
|= AIX_ECHO
;
143 if (linuxtermios_p
->c_lflag
& ECHOE
)
144 aixtermios
.c_lflag
|= AIX_ECHOE
;
145 if (linuxtermios_p
->c_lflag
& ECHOK
)
146 aixtermios
.c_lflag
|= AIX_ECHOK
;
147 if (linuxtermios_p
->c_lflag
& ECHONL
)
148 aixtermios
.c_lflag
|= AIX_ECHONL
;
149 if (linuxtermios_p
->c_lflag
& NOFLSH
)
150 aixtermios
.c_lflag
|= AIX_NOFLSH
;
151 if (linuxtermios_p
->c_lflag
& TOSTOP
)
152 aixtermios
.c_lflag
|= AIX_TOSTOP
;
153 if (linuxtermios_p
->c_lflag
& ECHOCTL
)
154 aixtermios
.c_lflag
|= AIX_ECHOCTL
;
155 if (linuxtermios_p
->c_lflag
& ECHOPRT
)
156 aixtermios
.c_lflag
|= AIX_ECHOPRT
;
157 if (linuxtermios_p
->c_lflag
& ECHOKE
)
158 aixtermios
.c_lflag
|= AIX_ECHOKE
;
159 if (linuxtermios_p
->c_lflag
& FLUSHO
)
160 aixtermios
.c_lflag
|= AIX_FLUSHO
;
161 if (linuxtermios_p
->c_lflag
& PENDIN
)
162 aixtermios
.c_lflag
|= AIX_PENDIN
;
163 if (linuxtermios_p
->c_lflag
& IEXTEN
)
164 aixtermios
.c_lflag
|= AIX_IEXTEN
;
166 result
= /* XXX syscall */;
168 // Convert error here or in syscall.