From 7bd0ed6e4c8be4539f3369c29ab6adc17a860c40 Mon Sep 17 00:00:00 2001 From: Maciej Jesionowski Date: Tue, 10 Jan 2017 13:09:14 +0100 Subject: [PATCH] Add deInt64 alignment functions to delibs Change-Id: Icf66e7157ae6e972e0d7ef19486fa5b776da1eb0 (cherry picked from commit 412a848d25e4a97b343904f8beace2c3690267c8) --- framework/delibs/debase/deInt32.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/framework/delibs/debase/deInt32.h b/framework/delibs/debase/deInt32.h index 72efc78..c694047 100644 --- a/framework/delibs/debase/deInt32.h +++ b/framework/delibs/debase/deInt32.h @@ -248,6 +248,18 @@ DE_INLINE deBool deIsAligned32 (int a, int align) } /*--------------------------------------------------------------------*//*! + * \brief Check if an integer is aligned to given power-of-two size. + * \param a Input value. + * \param align Alignment to check for. + * \return True if input is aligned, false otherwise. + *//*--------------------------------------------------------------------*/ +DE_INLINE deBool deIsAligned64 (deInt64 a, deInt64 align) +{ + DE_ASSERT(deIsPowerOfTwo64(align)); + return ((a & (align-1)) == 0); +} + +/*--------------------------------------------------------------------*//*! * \brief Check if a pointer is aligned to given power-of-two size. * \param ptr Input pointer. * \param align Alignment to check for (power-of-two). @@ -272,6 +284,18 @@ DE_INLINE deInt32 deAlign32 (deInt32 val, deInt32 align) } /*--------------------------------------------------------------------*//*! + * \brief Align an integer to given power-of-two size. + * \param val Input to align. + * \param align Alignment to check for (power-of-two). + * \return The aligned value (larger or equal to input). + *//*--------------------------------------------------------------------*/ +DE_INLINE deInt64 deAlign64 (deInt64 val, deInt64 align) +{ + DE_ASSERT(deIsPowerOfTwo64(align)); + return (val + align - 1) & ~(align - 1); +} + +/*--------------------------------------------------------------------*//*! * \brief Align a pointer to given power-of-two size. * \param ptr Input pointer to align. * \param align Alignment to check for (power-of-two). -- 2.7.4