diff options
-rw-r--r-- | src/mesa/main/macros.h | 46 | ||||
-rw-r--r-- | src/util/u_math.h | 46 |
2 files changed, 46 insertions, 46 deletions
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h index a54ade1fc9b..a4c5ec67a4a 100644 --- a/src/mesa/main/macros.h +++ b/src/mesa/main/macros.h @@ -691,52 +691,6 @@ minify(unsigned value, unsigned levels) return MAX2(1, value >> levels); } -/** - * Align a value up to an alignment value - * - * If \c value is not already aligned to the requested alignment value, it - * will be rounded up. - * - * \param value Value to be rounded - * \param alignment Alignment value to be used. This must be a power of two. - * - * \sa ROUND_DOWN_TO() - */ -static inline uintptr_t -ALIGN(uintptr_t value, int32_t alignment) -{ - assert((alignment > 0) && _mesa_is_pow_two(alignment)); - return (((value) + (alignment) - 1) & ~((alignment) - 1)); -} - -/** - * Like ALIGN(), but works with a non-power-of-two alignment. - */ -static inline uintptr_t -ALIGN_NPOT(uintptr_t value, int32_t alignment) -{ - assert(alignment > 0); - return (value + alignment - 1) / alignment * alignment; -} - -/** - * Align a value down to an alignment value - * - * If \c value is not already aligned to the requested alignment value, it - * will be rounded down. - * - * \param value Value to be rounded - * \param alignment Alignment value to be used. This must be a power of two. - * - * \sa ALIGN() - */ -static inline uintptr_t -ROUND_DOWN_TO(uintptr_t value, int32_t alignment) -{ - assert((alignment > 0) && _mesa_is_pow_two(alignment)); - return ((value) & ~(alignment - 1)); -} - /** Cross product of two 3-element vectors */ static inline void diff --git a/src/util/u_math.h b/src/util/u_math.h index 4f2658e2897..a672486f02f 100644 --- a/src/util/u_math.h +++ b/src/util/u_math.h @@ -660,6 +660,52 @@ util_memcpy_cpu_to_le32(void * restrict dest, const void * restrict src, size_t /** + * Align a value up to an alignment value + * + * If \c value is not already aligned to the requested alignment value, it + * will be rounded up. + * + * \param value Value to be rounded + * \param alignment Alignment value to be used. This must be a power of two. + * + * \sa ROUND_DOWN_TO() + */ +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)); +} + +/** + * Like ALIGN(), but works with a non-power-of-two alignment. + */ +static inline uintptr_t +ALIGN_NPOT(uintptr_t value, int32_t alignment) +{ + assert(alignment > 0); + return (value + alignment - 1) / alignment * alignment; +} + +/** + * Align a value down to an alignment value + * + * If \c value is not already aligned to the requested alignment value, it + * will be rounded down. + * + * \param value Value to be rounded + * \param alignment Alignment value to be used. This must be a power of two. + * + * \sa ALIGN() + */ +static inline uintptr_t +ROUND_DOWN_TO(uintptr_t value, int32_t alignment) +{ + assert(util_is_power_of_two_nonzero(alignment)); + return ((value) & ~(alignment - 1)); +} + +/** * Align a value, only works pot alignemnts. */ static inline int |