]> rtime.felk.cvut.cz Git - jailhouse.git/blob - hypervisor/include/jailhouse/utils.h
core/tools: Protect result of ARRAY_SIZE
[jailhouse.git] / hypervisor / include / jailhouse / utils.h
1 /*
2  * Jailhouse, a Linux-based partitioning hypervisor
3  *
4  * Copyright (c) Siemens AG, 2013
5  *
6  * Authors:
7  *  Jan Kiszka <jan.kiszka@siemens.com>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2.  See
10  * the COPYING file in the top-level directory.
11  */
12
13 #define ARRAY_SIZE(array)       (sizeof(array) / sizeof((array)[0]))
14
15 /* create 64-bit mask with bytes 0 to size-1 set to 0xff */
16 #define BYTE_MASK(size)         (0xffffffffffffffffULL >> ((8 - (size)) * 8))
17
18 /* create 64-bit mask with all bits in [last:first] set */
19 #define BIT_MASK(last, first) \
20         ((0xffffffffffffffffULL >> (64 - ((last) + 1 - (first)))) << (first))
21
22 #define MAX(a, b)               ((a) >= (b) ? (a) : (b))