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 2821e7bc60SMasahiro Yamada #define _BITUL(x) (_UL(1) << (x)) 2921e7bc60SMasahiro Yamada #define _BITULL(x) (_ULL(1) << (x)) 302fc016c5SH. Peter Anvin 31*31088f6fSKevin Brodsky #define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1) 32a85cbe61SPetr Vorel #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask)) 33a85cbe61SPetr Vorel 34a85cbe61SPetr Vorel #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) 35a85cbe61SPetr Vorel 362a6cc8a6SMasahiro Yamada #endif /* _UAPI_LINUX_CONST_H */ 37