mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 03:08:05 +02:00
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:
parent
5cc3258533
commit
81e3c46d06
1 changed files with 11 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue