xref: /linux/include/uapi/linux/const.h (revision 21e7bc600e3b662020c05fd0749bcf85f16336f7)
16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2607ca46eSDavid Howells /* const.h: Macros for dealing with constants.  */
3607ca46eSDavid Howells 
42a6cc8a6SMasahiro Yamada #ifndef _UAPI_LINUX_CONST_H
52a6cc8a6SMasahiro Yamada #define _UAPI_LINUX_CONST_H
6607ca46eSDavid Howells 
7607ca46eSDavid Howells /* Some constant macros are used in both assembler and
8607ca46eSDavid Howells  * C code.  Therefore we cannot annotate them always with
9607ca46eSDavid Howells  * 'UL' and other type specifiers unilaterally.  We
10607ca46eSDavid Howells  * use the following macros to deal with this.
11607ca46eSDavid Howells  *
12607ca46eSDavid Howells  * Similarly, _AT() will cast an expression with a type in C, but
13607ca46eSDavid Howells  * leave it unchanged in asm.
14607ca46eSDavid Howells  */
15607ca46eSDavid Howells 
16607ca46eSDavid Howells #ifdef __ASSEMBLY__
17607ca46eSDavid Howells #define _AC(X,Y)	X
18607ca46eSDavid Howells #define _AT(T,X)	X
19607ca46eSDavid Howells #else
20607ca46eSDavid Howells #define __AC(X,Y)	(X##Y)
21607ca46eSDavid Howells #define _AC(X,Y)	__AC(X,Y)
22607ca46eSDavid Howells #define _AT(T,X)	((T)(X))
23607ca46eSDavid Howells #endif
24607ca46eSDavid Howells 
252dd8a62cSMasahiro Yamada #define _UL(x)		(_AC(x, UL))
262dd8a62cSMasahiro Yamada #define _ULL(x)		(_AC(x, ULL))
272dd8a62cSMasahiro Yamada 
28*21e7bc60SMasahiro Yamada #define _BITUL(x)	(_UL(1) << (x))
29*21e7bc60SMasahiro Yamada #define _BITULL(x)	(_ULL(1) << (x))
302fc016c5SH. Peter Anvin 
312a6cc8a6SMasahiro Yamada #endif /* _UAPI_LINUX_CONST_H */
32