(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / sysdeps / mach / hurd / bits / ioctls.h
blob206058bf2f78d411ed1b1603cb888fe313b26fcc
1 /* Copyright (C) 1992,93,96,97,98,99,2001 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
17 02111-1307 USA. */
19 #ifndef __BITS_IOCTLS_H
20 #define __BITS_IOCTLS_H 1
22 #if !defined _HURD_IOCTL_H && !defined _SYS_IOCTL_H
23 # error "Never use <bits/ioctls.h> directly; include <hurd/ioctl.h> instead."
24 #endif
26 /* These macros are also defined in <bits/termios.h> (with numerically
27 identical values) but this serves to shut up cpp's complaining. */
28 #ifdef MDMBUF
29 # undef MDMBUF
30 #endif
31 #ifdef ECHO
32 # undef ECHO
33 #endif
34 #ifdef TOSTOP
35 # undef TOSTOP
36 #endif
37 #ifdef FLUSHO
38 # undef FLUSHO
39 #endif
40 #ifdef PENDIN
41 # undef PENDIN
42 #endif
43 #ifdef NOFLSH
44 # undef NOFLSH
45 #endif
47 /* Hurd ioctl request are made up of several fields:
49 10987654321098765432109876543210
50 IOt0t1t2cc0c0cc1c1cc2ggggccccccc
52 bits [31,30]: inout direction (enum __ioctl_dir)
53 bits [29,11]: type encoding as follows; zero count indicates omitted datum
54 [29,28]: datum #0 type (enum __ioctl_datum)
55 [27,26]: datum #1 type (enum __ioctl_datum)
56 [24,25]: datum #2 type (enum __ioctl_datum)
57 [23,19]: datum #0 count [0,31]
58 [18,14]: datum #1 count [0,31]
59 [13,11]: datum #2 count [0,3]
60 bits [07,10]: group (letter - 'f': ['f','v'])
61 bits [00,06]: command [0,127]
63 The following macros construct and dissect these fields. */
65 enum __ioctl_dir
67 IOC_VOID = 0, /* No parameters. */
68 IOC_OUT = 1, /* Data is written into the user's buffer. */
69 IOC_IN = 2, /* Data is read from the user's buffer. */
70 IOC_INOUT = (IOC_IN|IOC_OUT)
73 enum __ioctl_datum { IOC_8, IOC_16, IOC_32, IOC_64 };
75 /* Construct an ioctl from constructed type plus other fields. */
76 #define _IOC(inout, group, num, type) \
77 ((num) | ((((group) - 'f') | ((type) | (inout) << 19) << 4) << 7))
79 /* Dissect an ioctl into its component fields. */
80 #define _IOC_INOUT(request) (((unsigned int) (request) >> 30) & IOC_INOUT)
81 #define _IOC_GROUP(request) ('f' + (((unsigned int) (request) >> 7) & 0xf))
82 #define _IOC_COMMAND(request) ((unsigned int) (request) & 0x7f)
83 #define _IOC_TYPE(request) (((unsigned int) (request) >> 11) & 0x7ffff)
84 #define _IOC_NOTYPE(request) ((unsigned int) (request) & 0x3ff)
86 /* Construct a type information field from
87 the broken-out type and count fields. */
88 #define _IOT(t0, c0, t1, c1, t2, c2) \
89 ((c2) | (((c1) | ((c0) | ((t2) | ((t1) | (t0) << 2) << 2) << 5) << 5) << 3))
91 /* Dissect a type information field into the type and count fields. */
92 #define _IOT_TYPE0(type) (((unsigned int) (type) >> 17) & 3)
93 #define _IOT_TYPE1(type) (((unsigned int) (type) >> 15) & 3)
94 #define _IOT_TYPE2(type) (((unsigned int) (type) >> 13) & 3)
95 #define _IOT_COUNT0(type) (((unsigned int) (type) >> 8) & 0x1f)
96 #define _IOT_COUNT1(type) (((unsigned int) (type) >> 3) & 0x1f)
97 #define _IOT_COUNT2(type) (((unsigned int) (type) >> 0) & 7)
99 /* Construct an ioctl from all the broken-out fields. */
100 #define _IOCT(inout, group, num, t0, c0, t1, c1, t2, c2) \
101 _IOC ((inout), (group), (num), _IOT ((t0), (c0), (t1), (c1), (t2), (c2)))
103 /* Construct an individual type field for TYPE. */
104 #define _IOTS(type) \
105 (sizeof (type) == 8 ? IOC_64 : (sizeof (type) >> 1))
107 /* Construct a type information field for
108 a single argument of the scalar TYPE. */
109 #define _IOT_SIMPLE(type) _IOT (_IOTS (type), 1, 0, 0, 0, 0)
111 /* Basic C types. */
112 #define _IOT__IOTBASE_int _IOT_SIMPLE (int)
113 #define _IOT__IOTBASE_char _IOT_SIMPLE (char)
114 #define _IOT__IOTBASE_short _IOT_SIMPLE (short)
117 /* Standard flavors of ioctls.
118 _IOT_foobar is defined either in this file,
119 or where struct foobar is defined. */
120 #define _IO(g, n) _IOC (IOC_VOID, (g), (n), 0)
121 #define _IOR(g, n, t) _IOC (IOC_OUT, (g), (n), _IOC_ENCODE_TYPE (t))
122 #define _IOW(g, n, t) _IOC (IOC_IN, (g), (n), _IOC_ENCODE_TYPE (t))
123 #define _IOWR(g, n, t) _IOC (IOC_INOUT, (g), (n), _IOC_ENCODE_TYPE (t))
125 /* These macros do some preprocessor gymnastics to turn a TYPESPEC of
126 `struct foobar' into the identifier `_IOT_foobar', which is generally
127 defined using `_IOT' (above) in whatever file defines `struct foobar'.
128 For a TYPESPEC that does not begin with `struct' produces a different
129 identifier: `int' produces `_IOT__IOTBASE_int'. These identifiers
130 are defined for the basic C types above. */
131 #define _IOC_ENCODE_TYPE(typespec) _IOC_ENCODE_TYPE_1(_IOTBASE_##typespec)
132 #define _IOTBASE_struct
133 #define _IOC_ENCODE_TYPE_1(typespec) _IOC_ENCODE_TYPE_2(typespec)
134 #define _IOC_ENCODE_TYPE_2(typespec) _IOT_##typespec
137 /* ioctls verbatim from 4.4 <sys/ioctl.h>. */
139 #define TIOCMODG _IOR('t', 3, int) /* get modem control state */
140 #define TIOCMODS _IOW('t', 4, int) /* set modem control state */
141 #define TIOCM_LE 0001 /* line enable */
142 #define TIOCM_DTR 0002 /* data terminal ready */
143 #define TIOCM_RTS 0004 /* request to send */
144 #define TIOCM_ST 0010 /* secondary transmit */
145 #define TIOCM_SR 0020 /* secondary receive */
146 #define TIOCM_CTS 0040 /* clear to send */
147 #define TIOCM_CAR 0100 /* carrier detect */
148 #define TIOCM_CD TIOCM_CAR
149 #define TIOCM_RNG 0200 /* ring */
150 #define TIOCM_RI TIOCM_RNG
151 #define TIOCM_DSR 0400 /* data set ready */
152 /* 8-10 compat */
153 #define TIOCEXCL _IO('t', 13) /* set exclusive use of tty */
154 #define TIOCNXCL _IO('t', 14) /* reset exclusive use of tty */
155 /* 15 unused */
156 #define TIOCFLUSH _IOW('t', 16, int) /* flush buffers */
157 /* 17-18 compat */
158 #define TIOCGETA _IOR('t', 19, struct termios) /* get termios struct */
159 #define TIOCSETA _IOW('t', 20, struct termios) /* set termios struct */
160 #define TIOCSETAW _IOW('t', 21, struct termios) /* drain output, set */
161 #define TIOCSETAF _IOW('t', 22, struct termios) /* drn out, fls in, set */
162 #define TIOCGETD _IOR('t', 26, int) /* get line discipline */
163 #define TIOCSETD _IOW('t', 27, int) /* set line discipline */
164 /* 127-124 compat */
165 #define TIOCSBRK _IO('t', 123) /* set break bit */
166 #define TIOCCBRK _IO('t', 122) /* clear break bit */
167 #define TIOCSDTR _IO('t', 121) /* set data terminal ready */
168 #define TIOCCDTR _IO('t', 120) /* clear data terminal ready */
169 #define TIOCGPGRP _IOR('t', 119, int) /* get pgrp of tty */
170 #define TIOCSPGRP _IOW('t', 118, int) /* set pgrp of tty */
171 /* 117-116 compat */
172 #define TIOCOUTQ _IOR('t', 115, int) /* output queue size */
173 #define TIOCSTI _IOW('t', 114, char) /* simulate terminal input */
174 #define TIOCNOTTY _IO('t', 113) /* void tty association */
175 #define TIOCPKT _IOW('t', 112, int) /* pty: set/clear packet mode */
176 #define TIOCPKT_DATA 0x00 /* data packet */
177 #define TIOCPKT_FLUSHREAD 0x01 /* flush packet */
178 #define TIOCPKT_FLUSHWRITE 0x02 /* flush packet */
179 #define TIOCPKT_STOP 0x04 /* stop output */
180 #define TIOCPKT_START 0x08 /* start output */
181 #define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */
182 #define TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */
183 #define TIOCPKT_IOCTL 0x40 /* state change of pty driver */
184 #define TIOCSTOP _IO('t', 111) /* stop output, like ^S */
185 #define TIOCSTART _IO('t', 110) /* start output, like ^Q */
186 #define TIOCMSET _IOW('t', 109, int) /* set all modem bits */
187 #define TIOCMBIS _IOW('t', 108, int) /* bis modem bits */
188 #define TIOCMBIC _IOW('t', 107, int) /* bic modem bits */
189 #define TIOCMGET _IOR('t', 106, int) /* get all modem bits */
190 #define TIOCREMOTE _IOW('t', 105, int) /* remote input editing */
191 #define TIOCGWINSZ _IOR('t', 104, struct winsize) /* get window size */
192 #define TIOCSWINSZ _IOW('t', 103, struct winsize) /* set window size */
193 #define TIOCUCNTL _IOW('t', 102, int) /* pty: set/clr usr cntl mode */
194 #define UIOCCMD(n) _IO('u', n) /* usr cntl op "n" */
195 #define TIOCCONS _IOW('t', 98, int) /* become virtual console */
196 #define TIOCSCTTY _IO('t', 97) /* become controlling tty */
197 #define TIOCEXT _IOW('t', 96, int) /* pty: external processing */
198 #define TIOCSIG _IO('t', 95) /* pty: generate signal */
199 #define TIOCDRAIN _IO('t', 94) /* wait till output drained */
201 #define TTYDISC 0 /* termios tty line discipline */
202 #define TABLDISC 3 /* tablet discipline */
203 #define SLIPDISC 4 /* serial IP discipline */
206 #define FIOCLEX _IO('f', 1) /* set close on exec on fd */
207 #define FIONCLEX _IO('f', 2) /* remove close on exec */
208 #define FIONREAD _IOR('f', 127, int) /* get # bytes to read */
209 #define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */
210 #define FIOASYNC _IOW('f', 125, int) /* set/clear async i/o */
211 #define FIOSETOWN _IOW('f', 124, int) /* set owner */
212 #define FIOGETOWN _IOR('f', 123, int) /* get owner */
214 /* socket i/o controls */
215 #define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */
216 #define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */
217 #define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */
218 #define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */
219 #define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */
220 #define SIOCSPGRP _IOW('s', 8, int) /* set process group */
221 #define SIOCGPGRP _IOR('s', 9, int) /* get process group */
223 #define SIOCADDRT _IOW('r', 10, struct ortentry) /* add route */
224 #define SIOCDELRT _IOW('r', 11, struct ortentry) /* delete route */
226 #define SIOCSIFADDR _IOW('i', 12, struct ifreq) /* set ifnet address */
227 #define OSIOCGIFADDR _IOWR('i',13, struct ifreq) /* get ifnet address */
228 #define SIOCGIFADDR _IOWR('i',33, struct ifreq) /* get ifnet address */
229 #define SIOCSIFDSTADDR _IOW('i', 14, struct ifreq) /* set p-p address */
230 #define OSIOCGIFDSTADDR _IOWR('i',15, struct ifreq) /* get p-p address */
231 #define SIOCGIFDSTADDR _IOWR('i',34, struct ifreq) /* get p-p address */
232 #define SIOCSIFFLAGS _IOW('i', 16, struct ifreq_short)/* set ifnet flags */
233 #define SIOCGIFFLAGS _IOWR('i',17, struct ifreq_short)/* get ifnet flags */
234 #define OSIOCGIFBRDADDR _IOWR('i',18, struct ifreq) /* get broadcast addr */
235 #define SIOCGIFBRDADDR _IOWR('i',35, struct ifreq) /* get broadcast addr */
236 #define SIOCSIFBRDADDR _IOW('i',19, struct ifreq) /* set broadcast addr */
237 #define OSIOCGIFCONF _IOWR('i',20, struct ifconf) /* get ifnet list */
238 #define SIOCGIFCONF _IOWR('i',36, struct ifconf) /* get ifnet list */
239 #define OSIOCGIFNETMASK _IOWR('i',21, struct ifreq) /* get net addr mask */
240 #define SIOCGIFNETMASK _IOWR('i',37, struct ifreq) /* get net addr mask */
241 #define SIOCSIFNETMASK _IOW('i',22, struct ifreq) /* set net addr mask */
242 #define SIOCGIFMETRIC _IOWR('i',23, struct ifreq_int) /* get IF metric */
243 #define SIOCSIFMETRIC _IOW('i',24, struct ifreq_int) /* set IF metric */
244 #define SIOCDIFADDR _IOW('i',25, struct ifreq) /* delete IF addr */
245 #define SIOCAIFADDR _IOW('i',26, struct ifaliasreq) /* add/chg IF alias */
247 #define SIOCSARP _IOW('i', 30, struct arpreq) /* set arp entry */
248 #define OSIOCGARP _IOWR('i',31, struct arpreq) /* get arp entry */
249 #define SIOCGARP _IOWR('i',38, struct arpreq) /* get arp entry */
250 #define SIOCDARP _IOW('i', 32, struct arpreq) /* delete arp entry */
252 #define SIOCGIFMTU _IOWR('i', 51, struct ifreq_int)/* get IF mtu */
253 #define SIOCSIFMTU _IOW('i', 52, struct ifreq_int) /* set IF mtu */
255 #define SIOCGIFINDEX _IOWR('i', 90, struct ifreq_int)/* get IF index */
256 #define SIOCGIFNAME _IOWR('i', 91, struct ifreq_int)/* set IF name */
259 /* Compatibility with 4.3 BSD terminal driver.
260 From 4.4 <sys/ioctl_compat.h>. */
262 #ifdef USE_OLD_TTY
263 # undef TIOCGETD
264 # define TIOCGETD _IOR('t', 0, int) /* get line discipline */
265 # undef TIOCSETD
266 # define TIOCSETD _IOW('t', 1, int) /* set line discipline */
267 #else
268 # define OTIOCGETD _IOR('t', 0, int) /* get line discipline */
269 # define OTIOCSETD _IOW('t', 1, int) /* set line discipline */
270 #endif
271 #define TIOCHPCL _IO('t', 2) /* hang up on last close */
272 #define TIOCGETP _IOR('t', 8,struct sgttyb)/* get parameters -- gtty */
273 #define TIOCSETP _IOW('t', 9,struct sgttyb)/* set parameters -- stty */
274 #define TIOCSETN _IOW('t',10,struct sgttyb)/* as above, but no flushtty*/
275 #define TIOCSETC _IOW('t',17,struct tchars)/* set special characters */
276 #define TIOCGETC _IOR('t',18,struct tchars)/* get special characters */
277 #define TANDEM 0x00000001 /* send stopc on out q full */
278 #define CBREAK 0x00000002 /* half-cooked mode */
279 #define LCASE 0x00000004 /* simulate lower case */
280 #define ECHO 0x00000008 /* echo input */
281 #define CRMOD 0x00000010 /* map \r to \r\n on output */
282 #define RAW 0x00000020 /* no i/o processing */
283 #define ODDP 0x00000040 /* get/send odd parity */
284 #define EVENP 0x00000080 /* get/send even parity */
285 #define ANYP 0x000000c0 /* get any parity/send none */
286 #define NLDELAY 0x00000300 /* \n delay */
287 #define NL0 0x00000000
288 #define NL1 0x00000100 /* tty 37 */
289 #define NL2 0x00000200 /* vt05 */
290 #define NL3 0x00000300
291 #define TBDELAY 0x00000c00 /* horizontal tab delay */
292 #define TAB0 0x00000000
293 #define TAB1 0x00000400 /* tty 37 */
294 #define TAB2 0x00000800
295 #define XTABS 0x00000c00 /* expand tabs on output */
296 #define CRDELAY 0x00003000 /* \r delay */
297 #define CR0 0x00000000
298 #define CR1 0x00001000 /* tn 300 */
299 #define CR2 0x00002000 /* tty 37 */
300 #define CR3 0x00003000 /* concept 100 */
301 #define VTDELAY 0x00004000 /* vertical tab delay */
302 #define FF0 0x00000000
303 #define FF1 0x00004000 /* tty 37 */
304 #define BSDELAY 0x00008000 /* \b delay */
305 #define BS0 0x00000000
306 #define BS1 0x00008000
307 #define ALLDELAY (NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY)
308 #define CRTBS 0x00010000 /* do backspacing for crt */
309 #define PRTERA 0x00020000 /* \ ... / erase */
310 #define CRTERA 0x00040000 /* " \b " to wipe out char */
311 #define TILDE 0x00080000 /* hazeltine tilde kludge */
312 #define MDMBUF 0x00100000 /*start/stop output on carrier*/
313 #define LITOUT 0x00200000 /* literal output */
314 #define TOSTOP 0x00400000 /*SIGSTOP on background output*/
315 #define FLUSHO 0x00800000 /* flush output to terminal */
316 #define NOHANG 0x01000000 /* (no-op) was no SIGHUP on carrier drop */
317 #define L001000 0x02000000
318 #define CRTKIL 0x04000000 /* kill line with " \b " */
319 #define PASS8 0x08000000
320 #define CTLECH 0x10000000 /* echo control chars as ^X */
321 #define PENDIN 0x20000000 /* tp->t_rawq needs reread */
322 #define DECCTQ 0x40000000 /* only ^Q starts after ^S */
323 #define NOFLSH 0x80000000 /* no output flush on signal */
324 #define TIOCLBIS _IOW('t', 127, int) /* bis local mode bits */
325 #define TIOCLBIC _IOW('t', 126, int) /* bic local mode bits */
326 #define TIOCLSET _IOW('t', 125, int) /* set entire local mode word */
327 #define TIOCLGET _IOR('t', 124, int) /* get local modes */
328 #define LCRTBS (CRTBS>>16)
329 #define LPRTERA (PRTERA>>16)
330 #define LCRTERA (CRTERA>>16)
331 #define LTILDE (TILDE>>16)
332 #define LMDMBUF (MDMBUF>>16)
333 #define LLITOUT (LITOUT>>16)
334 #define LTOSTOP (TOSTOP>>16)
335 #define LFLUSHO (FLUSHO>>16)
336 #define LNOHANG (NOHANG>>16)
337 #define LCRTKIL (CRTKIL>>16)
338 #define LPASS8 (PASS8>>16)
339 #define LCTLECH (CTLECH>>16)
340 #define LPENDIN (PENDIN>>16)
341 #define LDECCTQ (DECCTQ>>16)
342 #define LNOFLSH (NOFLSH>>16)
343 #define TIOCSLTC _IOW('t',117,struct ltchars)/* set local special chars*/
344 #define TIOCGLTC _IOR('t',116,struct ltchars)/* get local special chars*/
345 #define OTIOCCONS _IO('t', 98) /* for hp300 -- sans int arg */
346 #define OTTYDISC 0
347 #define NETLDISC 1
348 #define NTTYDISC 2
350 /* From 4.4 <sys/ttydev.h>. */
351 #ifdef USE_OLD_TTY
352 # define B0 0
353 # define B50 1
354 # define B75 2
355 # define B110 3
356 # define B134 4
357 # define B150 5
358 # define B200 6
359 # define B300 7
360 # define B600 8
361 # define B1200 9
362 # define B1800 10
363 # define B2400 11
364 # define B4800 12
365 # define B9600 13
366 # define EXTA 14
367 # define EXTB 15
368 #endif /* USE_OLD_TTY */
370 #endif /* bits/ioctls.h */