mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-05-04 14:36:55 +00:00
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>
29 lines
776 B
C
29 lines
776 B
C
/*
|
|
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#ifndef MACROS_H
|
|
#define MACROS_H
|
|
|
|
/** Replaces 'x' by the string "x". */
|
|
#define __CPP_STRING(x) #x
|
|
/** Replaces 'x' by its value. */
|
|
#define CPP_STRING(x) __CPP_STRING(x)
|
|
|
|
/* 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)
|
|
*/
|
|
#define MEM_ALIGNED_CHECK(value, req_align) \
|
|
(((uint64_t)(value) & ((uint64_t)(req_align) - 1UL)) == 0UL)
|
|
|
|
#if !defined(ASSEMBLER) && !defined(LINKER_SCRIPT)
|
|
|
|
#define ARRAY_LENGTH(x) (sizeof(x)/sizeof((x)[0]))
|
|
|
|
#endif
|
|
|
|
#endif /* INCLUDE_MACROS_H defined */
|