Mesa (master): mesa/macros: move ALIGN_NPOT to macros.h

Nanley Chery nchery at kemper.freedesktop.org
Wed Aug 26 22:04:12 UTC 2015


Module: Mesa
Branch: master
Commit: 54d2aa4258f0bfcc669b2bc4e82332f7ff4876dd
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=54d2aa4258f0bfcc669b2bc4e82332f7ff4876dd

Author: Nanley Chery <nanley.g.chery at intel.com>
Date:   Tue Jun  2 11:03:22 2015 -0700

mesa/macros: move ALIGN_NPOT to macros.h

Aligning with a non-power-of-two number is a general task that can be used in
various places. This commit is required for the next one.

v2: add greater than 0 assertion (Anuj).
    convert the macro to a static inline function.

Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>
Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>

---

 src/mesa/drivers/dri/i965/intel_upload.c |    6 ------
 src/mesa/main/macros.h                   |   10 ++++++++++
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_upload.c b/src/mesa/drivers/dri/i965/intel_upload.c
index 870aabc..deaae6c 100644
--- a/src/mesa/drivers/dri/i965/intel_upload.c
+++ b/src/mesa/drivers/dri/i965/intel_upload.c
@@ -44,12 +44,6 @@
 
 #define INTEL_UPLOAD_SIZE (64*1024)
 
-/**
- * Like ALIGN(), but works with a non-power-of-two alignment.
- */
-#define ALIGN_NPOT(value, alignment) \
-   (((value) + (alignment) - 1) / (alignment) * (alignment))
-
 void
 intel_upload_finish(struct brw_context *brw)
 {
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index c3ef42a..ed207d4 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -698,6 +698,16 @@ ALIGN(uintptr_t value, int32_t alignment)
 }
 
 /**
+ * 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




More information about the mesa-commit mailing list