Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/vm_extern.h
Context not available. | |||||
static inline bool | static inline bool | ||||
vm_addr_align_ok(vm_paddr_t pa, u_long alignment) | 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: 0x%lx", | |||||
__func__, alignment) | |||||
#endif | |||||
return ((pa & (alignment - 1)) == 0); | return ((pa & (alignment - 1)) == 0); | ||||
dougm: For what it's worth, this could be written as
return (pa == rounddown2(pa, alignment)); | |||||
Not Done Inline ActionsI don't see how that makes anything clearer. On the other hand, using powerof2() provides clarity. alc: I don't see how that makes anything clearer. On the other hand, using powerof2() provides… | |||||
} | } | ||||
Context not available. | |||||
static inline bool | static inline bool | ||||
vm_addr_bound_ok(vm_paddr_t pa, vm_paddr_t size, vm_paddr_t boundary) | 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: 0x%lx", | |||||
__func__, alignment) | |||||
kibUnsubmitted Not Done Inline ActionsThere is no alignment argument for the function, it is boundary. And boundary has vm_paddr_t type, which makes it fail on most of 32bit arches. You need to use uintmax_t cast and %jx for format. BTW, it is better to use %#jx instead of manually adding 0x. kib: There is no alignment argument for the function, it is boundary. And boundary has vm_paddr_t… | |||||
#endif | |||||
return (((pa ^ (pa + size - 1)) & -boundary) == 0); | return (((pa ^ (pa + size - 1)) & -boundary) == 0); | ||||
Done Inline ActionsFor what it's worth, this could be written as return (rounddown2(pa + size - 1, boundary) <= pa); dougm: For what it's worth, this could be written as
return (rounddown2(pa + size - 1, boundary) <=… | |||||
} | } | ||||
Context not available. |
For what it's worth, this could be written as
return (pa == rounddown2(pa, alignment));