1 /*
2  * This file is auto-generated. Modifications will be lost.
3  *
4  * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5  * for more information.
6  */
7 #ifndef _UAPI_ASM_GENERIC_IOCTL_H
8 #define _UAPI_ASM_GENERIC_IOCTL_H
9 #define _IOC_NRBITS 8
10 #define _IOC_TYPEBITS 8
11 #ifndef _IOC_SIZEBITS
12 #define _IOC_SIZEBITS 14
13 #endif
14 #ifndef _IOC_DIRBITS
15 #define _IOC_DIRBITS 2
16 #endif
17 #define _IOC_NRMASK ((1 << _IOC_NRBITS) - 1)
18 #define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS) - 1)
19 #define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS) - 1)
20 #define _IOC_DIRMASK ((1 << _IOC_DIRBITS) - 1)
21 #define _IOC_NRSHIFT 0
22 #define _IOC_TYPESHIFT (_IOC_NRSHIFT + _IOC_NRBITS)
23 #define _IOC_SIZESHIFT (_IOC_TYPESHIFT + _IOC_TYPEBITS)
24 #define _IOC_DIRSHIFT (_IOC_SIZESHIFT + _IOC_SIZEBITS)
25 #ifndef _IOC_NONE
26 #define _IOC_NONE 0U
27 #endif
28 #ifndef _IOC_WRITE
29 #define _IOC_WRITE 1U
30 #endif
31 #ifndef _IOC_READ
32 #define _IOC_READ 2U
33 #endif
34 #define _IOC(dir,type,nr,size) (((dir) << _IOC_DIRSHIFT) | ((type) << _IOC_TYPESHIFT) | ((nr) << _IOC_NRSHIFT) | ((size) << _IOC_SIZESHIFT))
35 #define _IOC_TYPECHECK(t) (sizeof(t))
36 #define _IO(type,nr) _IOC(_IOC_NONE, (type), (nr), 0)
37 #define _IOR(type,nr,size) _IOC(_IOC_READ, (type), (nr), (_IOC_TYPECHECK(size)))
38 #define _IOW(type,nr,size) _IOC(_IOC_WRITE, (type), (nr), (_IOC_TYPECHECK(size)))
39 #define _IOWR(type,nr,size) _IOC(_IOC_READ | _IOC_WRITE, (type), (nr), (_IOC_TYPECHECK(size)))
40 #define _IOR_BAD(type,nr,size) _IOC(_IOC_READ, (type), (nr), sizeof(size))
41 #define _IOW_BAD(type,nr,size) _IOC(_IOC_WRITE, (type), (nr), sizeof(size))
42 #define _IOWR_BAD(type,nr,size) _IOC(_IOC_READ | _IOC_WRITE, (type), (nr), sizeof(size))
43 #define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
44 #define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
45 #define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
46 #define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
47 #define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
48 #define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
49 #define IOC_INOUT ((_IOC_WRITE | _IOC_READ) << _IOC_DIRSHIFT)
50 #define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
51 #define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
52 #endif
53