1 /****************************************************************************
2  ****************************************************************************
3  ***
4  ***   This header was automatically generated from a Linux kernel header
5  ***   of the same name, to make information necessary for userspace to
6  ***   call into the kernel available to libc.  It contains only constants,
7  ***   structures, and macros generated from the original header, and thus,
8  ***   contains no copyrightable information.
9  ***
10  ***   To edit the content of this header, modify the corresponding
11  ***   source file (e.g. under external/kernel-headers/original/) then
12  ***   run bionic/libc/kernel/tools/update_all.py
13  ***
14  ***   Any manual change here will be lost the next time this script will
15  ***   be run. You've been warned!
16  ***
17  ****************************************************************************
18  ****************************************************************************/
19 #ifndef _UAPI_ASM_GENERIC_IOCTL_H
20 #define _UAPI_ASM_GENERIC_IOCTL_H
21 #define _IOC_NRBITS 8
22 #define _IOC_TYPEBITS 8
23 #ifndef _IOC_SIZEBITS
24 #define _IOC_SIZEBITS 14
25 #endif
26 #ifndef _IOC_DIRBITS
27 #define _IOC_DIRBITS 2
28 #endif
29 #define _IOC_NRMASK ((1 << _IOC_NRBITS) - 1)
30 #define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS) - 1)
31 #define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS) - 1)
32 #define _IOC_DIRMASK ((1 << _IOC_DIRBITS) - 1)
33 #define _IOC_NRSHIFT 0
34 #define _IOC_TYPESHIFT (_IOC_NRSHIFT + _IOC_NRBITS)
35 #define _IOC_SIZESHIFT (_IOC_TYPESHIFT + _IOC_TYPEBITS)
36 #define _IOC_DIRSHIFT (_IOC_SIZESHIFT + _IOC_SIZEBITS)
37 #ifndef _IOC_NONE
38 #define _IOC_NONE 0U
39 #endif
40 #ifndef _IOC_WRITE
41 #define _IOC_WRITE 1U
42 #endif
43 #ifndef _IOC_READ
44 #define _IOC_READ 2U
45 #endif
46 #define _IOC(dir,type,nr,size) (((dir) << _IOC_DIRSHIFT) | ((type) << _IOC_TYPESHIFT) | ((nr) << _IOC_NRSHIFT) | ((size) << _IOC_SIZESHIFT))
47 #define _IOC_TYPECHECK(t) (sizeof(t))
48 #define _IO(type,nr) _IOC(_IOC_NONE, (type), (nr), 0)
49 #define _IOR(type,nr,size) _IOC(_IOC_READ, (type), (nr), (_IOC_TYPECHECK(size)))
50 #define _IOW(type,nr,size) _IOC(_IOC_WRITE, (type), (nr), (_IOC_TYPECHECK(size)))
51 #define _IOWR(type,nr,size) _IOC(_IOC_READ | _IOC_WRITE, (type), (nr), (_IOC_TYPECHECK(size)))
52 #define _IOR_BAD(type,nr,size) _IOC(_IOC_READ, (type), (nr), sizeof(size))
53 #define _IOW_BAD(type,nr,size) _IOC(_IOC_WRITE, (type), (nr), sizeof(size))
54 #define _IOWR_BAD(type,nr,size) _IOC(_IOC_READ | _IOC_WRITE, (type), (nr), sizeof(size))
55 #define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
56 #define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
57 #define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
58 #define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
59 #define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
60 #define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
61 #define IOC_INOUT ((_IOC_WRITE | _IOC_READ) << _IOC_DIRSHIFT)
62 #define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
63 #define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
64 #endif
65