HV:treewide:avoid using multiple # or ## in a macro

In the C99 standard, the order of evaluation associated with
multiple #, multiple ## or a mix of # and ## preprocessor
operator is unspecified. For this case, gcc 7.3.0 manual
does not specify related implementation. So it is unsafe
to use multiple # or ## in a macro.
BTW, there are some macros with one or more "##" which are
not used by hypervisor.

Update relate codes to avoid using multiple # or ## in a macro;
Remove unused macros with one or more "##";
Remove "struct __hack;" at the end of GETCC since it is useless.

Note:
     '##' operator usage constraints: A ## preprocessing token shall
     not occur at the beginning or at the end of a replacement list
     for either form of macro definition.
V1--V2:
	Update relate codes to avoid using multiple # or ## in a macro.
V2-->V3:
	Remove unused macros with one or more "##";
	Remove "struct __hack;" at the end of GETCC since it is useless.

Signed-off-by: Xiangyang Wu <xiangyang.wu@linux.intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Xiangyang Wu
2018-08-01 13:27:35 +08:00
committed by lijinxia
parent 581a336bc8
commit 77c3917544
3 changed files with 36 additions and 60 deletions

View File

@@ -12,27 +12,6 @@
/** Replaces 'x' by its value. */
#define CPP_STRING(x) __CPP_STRING(x)
/** Creates a bitfield mask.
*
* @param pos The position of the LSB within the mask.
* @param width The width of the bitfield in bits.
*
* @return The bitfield mask.
*/
#define BITFIELD_MASK(pos, width) (((1<<(width))-1)<<(pos))
#define BITFIELD_VALUE(v, pos, width) (((v)<<(pos)) & (((1<<(width))-1)<<(pos)))
#define MAKE_BITFIELD_MASK(id) BITFIELD_MASK(id ## _POS, id ## _WIDTH)
#define MAKE_BITFIELD_VALUE(v, id) BITFIELD_VALUE(v, id ## _POS, id ## _WIDTH)
/** Defines a register within a register block. */
#define REGISTER(base, off) (base ## _BASE + (off))
#define MAKE_MMIO_REGISTER_ADDRESS(chip, module, register) \
(chip ## _ ## module ## _BASE + \
(chip ## _ ## module ## _ ## register ## _REGISTER))
/* Macro used to check if a value is aligned to the required boundary.
* Returns TRUE if aligned; FALSE if not aligned
* NOTE: The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc)