Add deInt64 alignment functions to delibs
authorMaciej Jesionowski <maciej.jesionowski@mobica.com>
Tue, 10 Jan 2017 12:09:14 +0000 (13:09 +0100)
committerAlexander Galazin <alexander.galazin@arm.com>
Fri, 23 Jun 2017 21:16:37 +0000 (23:16 +0200)
Change-Id: Icf66e7157ae6e972e0d7ef19486fa5b776da1eb0
(cherry picked from commit 412a848d25e4a97b343904f8beace2c3690267c8)

framework/delibs/debase/deInt32.h

index 72efc78..c694047 100644 (file)
@@ -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).