[Mesa-dev] [PATCH 06/21] mesa/macros: Add ARRAY_SIZE helper macro core mesa

Pauli Nieminen pauli.nieminen at linux.intel.com
Sun Jun 10 23:59:20 PDT 2012


The ARRAY_SIZE macro is usefull helper that is used already in many
parts of core. But mesa core was missing it. I decided to add it to the
macros.h when I wanted to use it in following patch.

Signed-off-by: Pauli Nieminen <pauli.nieminen at linux.intel.com>
---
 src/mesa/drivers/dri/intel/intel_context.h  |    3 +--
 src/mesa/drivers/dri/radeon/radeon_screen.c |    2 --
 src/mesa/main/macros.h                      |    3 +++
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h
index cc3ee0d..4dc98d6 100644
--- a/src/mesa/drivers/dri/intel/intel_context.h
+++ b/src/mesa/drivers/dri/intel/intel_context.h
@@ -33,6 +33,7 @@
 #include <string.h>
 #include "main/mtypes.h"
 #include "main/mm.h"
+#include "main/macros.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -341,8 +342,6 @@ extern char *__progname;
 #define SUBPIXEL_X 0.125
 #define SUBPIXEL_Y 0.125
 
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
-
 /**
  * Align a value up to an alignment value
  *
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c
index 85cfe17..b0545b5 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.c
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
@@ -702,8 +702,6 @@ radeonDestroyBuffer(__DRIdrawable *driDrawPriv)
     _mesa_reference_framebuffer((struct gl_framebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
 }
 
-#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
-
 /**
  * This is the driver specific part of the createNewScreen entry point.
  * Called when using DRI2.
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index d1df2ce..e05fa14 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -679,5 +679,8 @@ do {                        \
 #define ENUM_TO_DOUBLE(E)  ((GLdouble)(GLint)(E))
 #define ENUM_TO_BOOLEAN(E) ((E) ? GL_TRUE : GL_FALSE)
 
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+#endif
 
 #endif
-- 
1.7.9.5



More information about the mesa-dev mailing list