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