csu: restore crt1.o symlink
[minix.git] / include / minix / ioctl.h
blobfe18d9d47687c8970aca2987e1f9ab01fb10ae77
1 /* minix/ioctl.h - Ioctl helper definitions. Author: Kees J. Bot
2 * 23 Nov 2002
4 * This file is included by every header file that defines ioctl codes.
5 */
7 #ifndef _M_IOCTL_H
8 #define _M_IOCTL_H
10 #include <sys/cdefs.h>
11 #include <sys/types.h>
13 /* Ioctls have the command encoded in the low-order word, and the size
14 * of the parameter in the high-order word. The 3 high bits of the high-
15 * order word are used to encode the in/out/void status of the parameter.
17 #define _IOCPARM_MASK 0x0FFF
18 #define _IOCPARM_MASK_BIG 0x0FFFFF
19 #define _IOC_VOID 0x20000000
20 #define _IOCTYPE_MASK 0xFFFF
21 #define _IOC_IN 0x40000000
22 #define _IOC_OUT 0x80000000
23 #define _IOC_INOUT (_IOC_IN | _IOC_OUT)
25 /* Flag indicating ioctl format with only one type field, and more bits
26 * for the size field (using mask _IOCPARM_MASK_BIG).
28 #define _IOC_BIG 0x10000000
30 #define _IO(x,y) ((x << 8) | y | _IOC_VOID)
31 #define _IOR(x,y,t) ((x << 8) | y | ((sizeof(t) & _IOCPARM_MASK) << 16) |\
32 _IOC_OUT)
33 #define _IOW(x,y,t) ((x << 8) | y | ((sizeof(t) & _IOCPARM_MASK) << 16) |\
34 _IOC_IN)
35 #define _IORW(x,y,t) ((x << 8) | y | ((sizeof(t) & _IOCPARM_MASK) << 16) |\
36 _IOC_INOUT)
38 #define _IOW_BIG(y,t) (y | ((sizeof(t) & _IOCPARM_MASK_BIG) << 8) \
39 | _IOC_IN | _IOC_BIG)
40 #define _IOR_BIG(y,t) (y | ((sizeof(t) & _IOCPARM_MASK_BIG) << 8) \
41 | _IOC_OUT | _IOC_BIG)
42 #define _IORW_BIG(y,t) (y | ((sizeof(t) & _IOCPARM_MASK_BIG) << 8) \
43 | _IOC_INOUT | _IOC_BIG)
45 /* Decode an ioctl call. */
46 #define _MINIX_IOCTL_SIZE(i) (((i) >> 16) & _IOCPARM_MASK)
47 #define _MINIX_IOCTL_IOR(i) ((i) & _IOC_OUT)
48 #define _MINIX_IOCTL_IORW(i) ((i) & _IOC_INOUT)
49 #define _MINIX_IOCTL_IOW(i) ((i) & _IOC_IN)
51 /* Recognize and decode size of a 'big' ioctl call. */
52 #define _MINIX_IOCTL_BIG(i) ((i) & _IOC_BIG)
53 #define _MINIX_IOCTL_SIZE_BIG(i) (((i) >> 8) & _IOCPARM_MASK_BIG)
55 __BEGIN_DECLS
56 int ioctl(int _fd, int _request, void *_data);
57 __END_DECLS
59 #endif /* _M_IOCTL_H */