xref: /OK3568_Linux_fs/kernel/tools/include/uapi/linux/const.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2*4882a593Smuzhiyun /* const.h: Macros for dealing with constants.  */
3*4882a593Smuzhiyun 
4*4882a593Smuzhiyun #ifndef _UAPI_LINUX_CONST_H
5*4882a593Smuzhiyun #define _UAPI_LINUX_CONST_H
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun /* Some constant macros are used in both assembler and
8*4882a593Smuzhiyun  * C code.  Therefore we cannot annotate them always with
9*4882a593Smuzhiyun  * 'UL' and other type specifiers unilaterally.  We
10*4882a593Smuzhiyun  * use the following macros to deal with this.
11*4882a593Smuzhiyun  *
12*4882a593Smuzhiyun  * Similarly, _AT() will cast an expression with a type in C, but
13*4882a593Smuzhiyun  * leave it unchanged in asm.
14*4882a593Smuzhiyun  */
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun #ifdef __ASSEMBLY__
17*4882a593Smuzhiyun #define _AC(X,Y)	X
18*4882a593Smuzhiyun #define _AT(T,X)	X
19*4882a593Smuzhiyun #else
20*4882a593Smuzhiyun #define __AC(X,Y)	(X##Y)
21*4882a593Smuzhiyun #define _AC(X,Y)	__AC(X,Y)
22*4882a593Smuzhiyun #define _AT(T,X)	((T)(X))
23*4882a593Smuzhiyun #endif
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun #define _UL(x)		(_AC(x, UL))
26*4882a593Smuzhiyun #define _ULL(x)		(_AC(x, ULL))
27*4882a593Smuzhiyun 
28*4882a593Smuzhiyun #define _BITUL(x)	(_UL(1) << (x))
29*4882a593Smuzhiyun #define _BITULL(x)	(_ULL(1) << (x))
30*4882a593Smuzhiyun 
31*4882a593Smuzhiyun #define __ALIGN_KERNEL(x, a)		__ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
32*4882a593Smuzhiyun #define __ALIGN_KERNEL_MASK(x, mask)	(((x) + (mask)) & ~(mask))
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun #endif /* _UAPI_LINUX_CONST_H */
37