acrn-hypervisor/hypervisor/include/lib/util.h
Yang, Yu-chu da0f28c6de HV: Bracket for the same level of precendence
The plus and minor have the same level of precedence. The Misra-C
considers it as a violation. Added brackets in between addition and
substraction oprators.

Signed-off-by: Yang, Yu-chu <yu-chu.yang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-07-24 10:10:39 +08:00

28 lines
629 B
C

/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef UTIL_H
#define UTIL_H
/** Add an offset (in bytes) to an (base)address.
*
* @param addr Baseaddress
* @param off Offset
* @return Returns baseaddress + offset in bytes.
*/
#define ADD_OFFSET(addr, off) (void *)(((uint8_t *)(addr))+(off))
#define offsetof(st, m) __builtin_offsetof(st, m)
/** Roundup (x/y) to ( x/y + (x%y) ? 1 : 0) **/
#define INT_DIV_ROUNDUP(x, y) ((((x)+(y))-1)/(y))
#define min(x, y) ((x) < (y)) ? (x) : (y)
#define max(x, y) ((x) < (y)) ? (y) : (x)
#endif /* UTIL_H */