util: migrate alignment functions and macros to use ALIGN_POT

Signed-off-by: Rohan Garg <rohan.garg@intel.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20153>
This commit is contained in:
Rohan Garg
2022-12-02 22:30:15 +05:30
committed by Marge Bot
parent 78e7a9740b
commit 0a06cf7523

View File

@@ -49,6 +49,7 @@
#include "u_endian.h" /* for UTIL_ARCH_BIG_ENDIAN */
#include "util/detect_cc.h"
#include "util/detect_arch.h"
#include "util/macros.h"
#ifdef __HAIKU__
#include <sys/param.h>
@@ -656,7 +657,7 @@ static inline uintptr_t
ALIGN(uintptr_t value, int32_t alignment)
{
assert(util_is_power_of_two_nonzero(alignment));
return (((value) + (alignment) - 1) & ~((alignment) - 1));
return ALIGN_POT(value, alignment);
}
/**
@@ -693,13 +694,15 @@ ROUND_DOWN_TO(uint64_t value, uint32_t alignment)
static inline int
align(int value, int alignment)
{
return (value + alignment - 1) & ~(alignment - 1);
assert(IS_POT(alignment));
return ALIGN_POT(value, alignment);
}
static inline uint64_t
align64(uint64_t value, uint64_t alignment)
{
return (value + alignment - 1) & ~(alignment - 1);
assert(IS_POT(alignment));
return ALIGN_POT(value, (uint64_t)alignment);
}
/**