util: add util_is_aligned()
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28568>
This commit is contained in:
committed by
Marge Bot
parent
5cc3258533
commit
81e3c46d06
@@ -808,6 +808,17 @@ util_clamped_uadd(unsigned a, unsigned b)
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the value 'n' is aligned to 'a'.
|
||||
* The alignment must be a power of two.
|
||||
*/
|
||||
static inline bool
|
||||
util_is_aligned(uintmax_t n, uintmax_t a)
|
||||
{
|
||||
assert(a == (a & -a));
|
||||
return (n & (a - 1)) == 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user