1 /*
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2019 Western Digital Corporation or its affiliates.
5  *
6  * Authors:
7  *   Anup Patel <anup.patel@wdc.com>
8  */
9 
10 #ifndef __SBI_CONST_H__
11 #define __SBI_CONST_H__
12 
13 /*
14  * Some constant macros are used in both assembler and
15  * C code.  Therefore we cannot annotate them always with
16  * 'UL' and other type specifiers unilaterally.  We
17  * use the following macros to deal with this.
18  *
19  * Similarly, _AT() will cast an expression with a type in C, but
20  * leave it unchanged in asm.
21  */
22 
23 /* clang-format off */
24 
25 #ifdef __ASSEMBLY__
26 #define _AC(X,Y)	X
27 #define _AT(T,X)	X
28 #else
29 #define __AC(X,Y)	(X##Y)
30 #define _AC(X,Y)	__AC(X,Y)
31 #define _AT(T,X)	((T)(X))
32 #endif
33 
34 #define _UL(x)		(_AC(x, UL))
35 #define _ULL(x)		(_AC(x, ULL))
36 
37 #define _BITUL(x)	(_UL(1) << (x))
38 #define _BITULL(x)	(_ULL(1) << (x))
39 
40 #define UL(x)		(_UL(x))
41 #define ULL(x)		(_ULL(x))
42 
43 #define __STR(s)	#s
44 #define STRINGIFY(s)	__STR(s)
45 
46 /* clang-format on */
47 
48 #endif
49