mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-05-02 13:44:00 +00:00
This patch cleans up the integral type violations to MISRA C rules, mostly related to signed constants that should be unsigned but also spelling out two integer narrowing and dropping some macros negating unsigned integers. v1 -> v2: * Drop INT_ROUNDUPx macros since they are never used. Signed-off-by: Junjie Mao <junjie.mao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
28 lines
627 B
C
28 lines
627 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 */
|