git: 29d481ae6a19 - main - Make <vm/vm_extern.h> more self-contained.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 28 Jan 2022 21:26:09 UTC
The branch main has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=29d481ae6a197d000527c317641bbccdb4305d72
commit 29d481ae6a197d000527c317641bbccdb4305d72
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-01-28 21:14:03 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-01-28 21:14:03 +0000
Make <vm/vm_extern.h> more self-contained.
Add a nested include of <sys/systm.h> for recently added assertions.
Without this, existing code (such as in drm-kmod) needs to be patched
to add the newly required header.
While here, rewrite the assertions using KASSERT().
Reviewed by: dougm, alc, imp, kib
Differential Revision: https://reviews.freebsd.org/D34070
---
sys/vm/vm_extern.h | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/sys/vm/vm_extern.h b/sys/vm/vm_extern.h
index 9fac3403f787..ce733b92c87e 100644
--- a/sys/vm/vm_extern.h
+++ b/sys/vm/vm_extern.h
@@ -42,6 +42,8 @@ struct vnode;
struct vmem;
#ifdef _KERNEL
+#include <sys/systm.h>
+
struct cdev;
struct cdevsw;
struct domainset;
@@ -140,11 +142,8 @@ u_int vm_wait_count(void);
static inline bool
vm_addr_align_ok(vm_paddr_t pa, u_long alignment)
{
-#ifdef INVARIANTS
- if (!powerof2(alignment))
- panic("%s: alignment is not a power of 2: %#lx",
- __func__, alignment);
-#endif
+ KASSERT(powerof2(alignment), ("%s: alignment is not a power of 2: %#lx",
+ __func__, alignment));
return ((pa & (alignment - 1)) == 0);
}
@@ -155,11 +154,8 @@ vm_addr_align_ok(vm_paddr_t pa, u_long alignment)
static inline bool
vm_addr_bound_ok(vm_paddr_t pa, vm_paddr_t size, vm_paddr_t boundary)
{
-#ifdef INVARIANTS
- if (!powerof2(boundary))
- panic("%s: boundary is not a power of 2: %#jx",
- __func__, (uintmax_t)boundary);
-#endif
+ KASSERT(powerof2(boundary), ("%s: boundary is not a power of 2: %#jx",
+ __func__, (uintmax_t)boundary));
return (((pa ^ (pa + size - 1)) & -boundary) == 0);
}