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