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:
@@ -49,6 +49,7 @@
|
|||||||
#include "u_endian.h" /* for UTIL_ARCH_BIG_ENDIAN */
|
#include "u_endian.h" /* for UTIL_ARCH_BIG_ENDIAN */
|
||||||
#include "util/detect_cc.h"
|
#include "util/detect_cc.h"
|
||||||
#include "util/detect_arch.h"
|
#include "util/detect_arch.h"
|
||||||
|
#include "util/macros.h"
|
||||||
|
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
@@ -656,7 +657,7 @@ static inline uintptr_t
|
|||||||
ALIGN(uintptr_t value, int32_t alignment)
|
ALIGN(uintptr_t value, int32_t alignment)
|
||||||
{
|
{
|
||||||
assert(util_is_power_of_two_nonzero(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
|
static inline int
|
||||||
align(int value, int alignment)
|
align(int value, int alignment)
|
||||||
{
|
{
|
||||||
return (value + alignment - 1) & ~(alignment - 1);
|
assert(IS_POT(alignment));
|
||||||
|
return ALIGN_POT(value, alignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint64_t
|
static inline uint64_t
|
||||||
align64(uint64_t value, uint64_t alignment)
|
align64(uint64_t value, uint64_t alignment)
|
||||||
{
|
{
|
||||||
return (value + alignment - 1) & ~(alignment - 1);
|
assert(IS_POT(alignment));
|
||||||
|
return ALIGN_POT(value, (uint64_t)alignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user