xref: /freebsd/sys/dev/vmware/vmci/vmci_kernel_defs.h (revision 63a938566d524836885917d95bd491aa4400b181)
1*63a93856SMark Peek /*-
2*63a93856SMark Peek  * Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3*63a93856SMark Peek  *
4*63a93856SMark Peek  * SPDX-License-Identifier: (BSD-2-Clause AND GPL-2.0)
5*63a93856SMark Peek  *
6*63a93856SMark Peek  * $FreeBSD$
7*63a93856SMark Peek  */
8*63a93856SMark Peek 
9*63a93856SMark Peek /* Some common utilities used by the VMCI kernel module. */
10*63a93856SMark Peek 
11*63a93856SMark Peek #ifndef _VMCI_KERNEL_DEFS_H_
12*63a93856SMark Peek #define _VMCI_KERNEL_DEFS_H_
13*63a93856SMark Peek 
14*63a93856SMark Peek #include <sys/param.h>
15*63a93856SMark Peek #include <sys/systm.h>
16*63a93856SMark Peek 
17*63a93856SMark Peek typedef uint32_t PPN;
18*63a93856SMark Peek 
19*63a93856SMark Peek #define ASSERT(cond)		KASSERT(cond, (""))
20*63a93856SMark Peek #define ASSERT_ON_COMPILE(e)	_Static_assert(e, #e);
21*63a93856SMark Peek 
22*63a93856SMark Peek #define LIKELY(_exp)		__builtin_expect(!!(_exp), 1)
23*63a93856SMark Peek #define UNLIKELY(_exp)		__builtin_expect((_exp), 0)
24*63a93856SMark Peek 
25*63a93856SMark Peek #define CONST64U(c)		c##uL
26*63a93856SMark Peek 
27*63a93856SMark Peek #define ARRAYSIZE(a)		(sizeof(a) / sizeof(*(a)))
28*63a93856SMark Peek 
29*63a93856SMark Peek #define ROUNDUP(x, y)		(((x) + (y) - 1) / (y) * (y))
30*63a93856SMark Peek #define CEILING(x, y)		(((x) + (y) - 1) / (y))
31*63a93856SMark Peek 
32*63a93856SMark Peek #endif /* !_VMCI_KERNEL_DEFS_H_ */
33