18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
28c2ecf20Sopenharmony_ci/* const.h: Macros for dealing with constants.  */
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#ifndef _UAPI_LINUX_CONST_H
58c2ecf20Sopenharmony_ci#define _UAPI_LINUX_CONST_H
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci/* Some constant macros are used in both assembler and
88c2ecf20Sopenharmony_ci * C code.  Therefore we cannot annotate them always with
98c2ecf20Sopenharmony_ci * 'UL' and other type specifiers unilaterally.  We
108c2ecf20Sopenharmony_ci * use the following macros to deal with this.
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci * Similarly, _AT() will cast an expression with a type in C, but
138c2ecf20Sopenharmony_ci * leave it unchanged in asm.
148c2ecf20Sopenharmony_ci */
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#ifdef __ASSEMBLY__
178c2ecf20Sopenharmony_ci#define _AC(X,Y)	X
188c2ecf20Sopenharmony_ci#define _AT(T,X)	X
198c2ecf20Sopenharmony_ci#else
208c2ecf20Sopenharmony_ci#define __AC(X,Y)	(X##Y)
218c2ecf20Sopenharmony_ci#define _AC(X,Y)	__AC(X,Y)
228c2ecf20Sopenharmony_ci#define _AT(T,X)	((T)(X))
238c2ecf20Sopenharmony_ci#endif
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#define _UL(x)		(_AC(x, UL))
268c2ecf20Sopenharmony_ci#define _ULL(x)		(_AC(x, ULL))
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define _BITUL(x)	(_UL(1) << (x))
298c2ecf20Sopenharmony_ci#define _BITULL(x)	(_ULL(1) << (x))
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#define __ALIGN_KERNEL(x, a)		__ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
328c2ecf20Sopenharmony_ci#define __ALIGN_KERNEL_MASK(x, mask)	(((x) + (mask)) & ~(mask))
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#endif /* _UAPI_LINUX_CONST_H */
37