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 /* Some constant macros are used in both assembler and 14 * C code. Therefore we cannot annotate them always with 15 * 'UL' and other type specifiers unilaterally. We 16 * use the following macros to deal with this. 17 * 18 * Similarly, _AT() will cast an expression with a type in C, but 19 * leave it unchanged in asm. 20 */ 21 22 /* clang-format off */ 23 24 #ifdef __ASSEMBLY__ 25 #define _AC(X,Y) X 26 #define _AT(T,X) X 27 #else 28 #define __AC(X,Y) (X##Y) 29 #define _AC(X,Y) __AC(X,Y) 30 #define _AT(T,X) ((T)(X)) 31 #endif 32 33 #define _UL(x) (_AC(x, UL)) 34 #define _ULL(x) (_AC(x, ULL)) 35 36 #define _BITUL(x) (_UL(1) << (x)) 37 #define _BITULL(x) (_ULL(1) << (x)) 38 39 #define UL(x) (_UL(x)) 40 #define ULL(x) (_ULL(x)) 41 42 #define __STR(s) #s 43 #define STRINGIFY(s) __STR(s) 44 45 /* clang-format on */ 46 47 #endif 48