[Mesa-dev] [PATCH 1/5] mesa: Add ALIGN() macro to main/macros.h.
Paul Berry
stereotype441 at gmail.com
Wed Jan 2 10:59:40 PST 2013
Previously this macro existed in 3 separate places, some inside the
intel driver and some outside of it. It makes more sense to have it
in main/macros.h
---
src/glsl/linker.cpp | 2 --
src/mesa/drivers/dri/i965/brw_context.h | 1 +
src/mesa/drivers/dri/intel/intel_context.h | 13 -------------
src/mesa/main/extensions.c | 3 +--
src/mesa/main/macros.h | 13 +++++++++++++
5 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index be08156..c5c462b 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -76,8 +76,6 @@ extern "C" {
#include "main/shaderobj.h"
}
-#define ALIGN(value, alignment) (((value) + alignment - 1) & ~(alignment - 1))
-
/**
* Visitor that determines whether or not a variable is ever written.
*/
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index eba9eb5..c7fc586 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -36,6 +36,7 @@
#include "intel_context.h"
#include "brw_structs.h"
#include "main/imports.h"
+#include "main/macros.h"
#ifdef __cplusplus
extern "C" {
diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h
index 8d544dc..dbc5ea0 100644
--- a/src/mesa/drivers/dri/intel/intel_context.h
+++ b/src/mesa/drivers/dri/intel/intel_context.h
@@ -350,19 +350,6 @@ extern char *__progname;
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
/**
- * 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()
- */
-#define ALIGN(value, alignment) (((value) + alignment - 1) & ~(alignment - 1))
-
-/**
* Align a value down to an alignment value
*
* If \c value is not already aligned to the requested alignment value, it
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 98711b3..3486b65 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -34,11 +34,10 @@
#include "imports.h"
#include "context.h"
#include "extensions.h"
+#include "macros.h"
#include "mfeatures.h"
#include "mtypes.h"
-#define ALIGN(value, alignment) (((value) + alignment - 1) & ~(alignment - 1))
-
enum {
DISABLE = 0,
GLL = 1 << API_OPENGL_COMPAT, /* GL Legacy / Compatibility */
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index 14a5d5f..d1e81fe 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -656,6 +656,19 @@ INTERP_4F(GLfloat t, GLfloat dst[4], const GLfloat out[4], const GLfloat in[4])
#define MIN3( A, B, C ) ((A) < (B) ? MIN2(A, C) : MIN2(B, C))
#define MAX3( A, B, C ) ((A) > (B) ? MAX2(A, C) : MAX2(B, C))
+/**
+ * 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()
+ */
+#define ALIGN(value, alignment) (((value) + alignment - 1) & ~(alignment - 1))
+
/** Cross product of two 3-element vectors */
--
1.8.1
More information about the mesa-dev
mailing list