[Piglit] [PATCH 5/5] Change ELEMENTS macros to ARRAY_SIZE.

Paul Berry stereotype441 at gmail.com
Wed Jan 25 17:56:48 PST 2012


The ELEMENTS() macro is defined in several parts of Piglit.  An
equivalent macro, ARRAY_SIZE(), already exists in piglit-util.h.  This
patch eliminates all of the definitions of ELEMENTS() and replaces
their uses with ARRAY_SIZE().
---
 tests/fbo/fbo-storage-completeness.c               |    5 +----
 tests/fbo/fbo-storage-formats.c                    |    7 ++-----
 tests/general/array-stride.c                       |    6 ++----
 tests/general/longprim.c                           |    4 +---
 tests/general/user-clip.c                          |    2 --
 tests/shaders/fp-abs-01.c                          |    4 +---
 tests/shaders/fp-abs-02.c                          |    4 +---
 tests/shaders/fp-rfl.c                             |    4 +---
 tests/shaders/fp-set-01.c                          |    4 +---
 tests/shaders/fp-set-02.c                          |   10 ++++------
 tests/shaders/fp-unpack-01.c                       |   12 +++++-------
 tests/shaders/gpu_shader4_attribs.c                |    7 ++-----
 tests/shaders/vp-address-01.c                      |    8 +++-----
 tests/shaders/vp-address-02.c                      |    8 +++-----
 tests/shaders/vp-address-03.c                      |    6 ++----
 tests/shaders/vp-address-04.c                      |    4 +---
 tests/shaders/vp-address-05.c                      |    6 ++----
 tests/shaders/vp-address-06.c                      |    6 ++----
 tests/shaders/vp-clipdistance-01.c                 |    6 ++----
 tests/shaders/vp-clipdistance-02.c                 |    6 ++----
 tests/shaders/vp-clipdistance-03.c                 |    6 ++----
 tests/shaders/vp-clipdistance-04.c                 |    6 ++----
 .../spec/arb_texture_float/texture-float-formats.c |    6 ++----
 tests/spec/ext_texture_integer/api-teximage.c      |    2 --
 tests/texturing/texture-integer.c                  |    4 +---
 25 files changed, 45 insertions(+), 98 deletions(-)

diff --git a/tests/fbo/fbo-storage-completeness.c b/tests/fbo/fbo-storage-completeness.c
index f8d4adb..8c099cd 100644
--- a/tests/fbo/fbo-storage-completeness.c
+++ b/tests/fbo/fbo-storage-completeness.c
@@ -139,9 +139,6 @@ static const struct format_info Formats[] = {
 };
 
 
-#define ELEMENTS(A) (sizeof(A) / sizeof(A[0]))
-
-
 static enum piglit_result
 test(void)
 {
@@ -154,7 +151,7 @@ test(void)
       ;
 
    /* find a format which is incomplete */
-   for (i = 0; i < ELEMENTS(Formats); i++) {
+   for (i = 0; i < ARRAY_SIZE(Formats); i++) {
       if (!HaveExtension[Formats[i].extension])
           continue;
 
diff --git a/tests/fbo/fbo-storage-formats.c b/tests/fbo/fbo-storage-formats.c
index 70c1d84..71bfc45 100644
--- a/tests/fbo/fbo-storage-formats.c
+++ b/tests/fbo/fbo-storage-formats.c
@@ -169,9 +169,6 @@ static const GLenum InvalidFormats[] = {
 };
 
 
-#define ELEMENTS(A) (sizeof(A) / sizeof(A[0]))
-
-
 static enum piglit_result
 test(void)
 {
@@ -199,7 +196,7 @@ test(void)
       ;
 
    /* test formats that should be accepted */
-   for (i = 0; i < ELEMENTS(Formats); i++) {
+   for (i = 0; i < ARRAY_SIZE(Formats); i++) {
       if (!HaveExtension[Formats[i].extension])
           continue;
 
@@ -217,7 +214,7 @@ test(void)
    }
 
    /* test formats that should fail */
-   for (i = 0; i < ELEMENTS(InvalidFormats); i++) {
+   for (i = 0; i < ARRAY_SIZE(InvalidFormats); i++) {
       glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, InvalidFormats[i],
                                piglit_width, piglit_height);
       err = glGetError();
diff --git a/tests/general/array-stride.c b/tests/general/array-stride.c
index 02628cd..aa46caa 100644
--- a/tests/general/array-stride.c
+++ b/tests/general/array-stride.c
@@ -37,8 +37,6 @@ int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
 static const char *TestName = "array-stride";
 
 
-#define ELEMENTS(ARRAY)  (sizeof(ARRAY) / sizeof(ARRAY[0]))
-
 #define ROWS 10
 #define COLS 10
 #define NUM_VERTS (ROWS * COLS * 4)
@@ -74,7 +72,7 @@ draw_simple_stride(void)
    static GLushort elements[NUM_VERTS];
    int i;
 
-   for (i = 0; i < ELEMENTS(elements); i++)
+   for (i = 0; i < ARRAY_SIZE(elements); i++)
       elements[i] = i;
 
    glVertexPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), Verts);
@@ -95,7 +93,7 @@ draw_unusual_stride(int stride)
    static GLushort elements[NUM_VERTS];
    int i;
 
-   for (i = 0; i < ELEMENTS(elements); i++)
+   for (i = 0; i < ARRAY_SIZE(elements); i++)
       elements[i] = i * 8 / stride;
 
    glVertexPointer(2, GL_FLOAT, stride, Verts);
diff --git a/tests/general/longprim.c b/tests/general/longprim.c
index a9ec917..7a3ad68 100644
--- a/tests/general/longprim.c
+++ b/tests/general/longprim.c
@@ -64,8 +64,6 @@ static const char *primNames[] = {
    "GL_POLYGON"
 };
 
-#define ELEMENTS(ARRAY)  (sizeof(ARRAY) / sizeof(ARRAY[0]))
-
 
 static void
 draw(GLenum mode, GLuint numVerts)
@@ -87,7 +85,7 @@ test_prims(void)
    GLuint len, prim;
 
    for (len = 1000; len <= 1000 * 1000; len *= 10) {
-      for (prim = 0; prim < ELEMENTS(primTypes); prim++) {
+      for (prim = 0; prim < ARRAY_SIZE(primTypes); prim++) {
          if (!piglit_automatic)
             printf("%s: %s %u vertices\n", TestName, primNames[prim], len);
          glClear(GL_COLOR_BUFFER_BIT);
diff --git a/tests/general/user-clip.c b/tests/general/user-clip.c
index 232a6d2..ab95940 100644
--- a/tests/general/user-clip.c
+++ b/tests/general/user-clip.c
@@ -30,8 +30,6 @@
 #include "piglit-util.h"
 #include "piglit-framework.h"
 
-#define ELEMENTS(x)  (sizeof(x) / sizeof(x[0]))
-
 #define BOX_SIZE   32
 
 
diff --git a/tests/shaders/fp-abs-01.c b/tests/shaders/fp-abs-01.c
index 48047bd..6f87dc0 100644
--- a/tests/shaders/fp-abs-01.c
+++ b/tests/shaders/fp-abs-01.c
@@ -35,8 +35,6 @@
 #define TEST_COLS  2
 #define BOX_SIZE   32
 
-#define ELEMENTS(x)  (sizeof(x) / sizeof(x[0]))
-
 int piglit_window_mode = GLUT_DOUBLE;
 int piglit_width = (((BOX_SIZE+1)*TEST_COLS)+1);
 int piglit_height = (((BOX_SIZE+1)*TEST_ROWS)+1);
@@ -128,7 +126,7 @@ piglit_display(void)
 
 	glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vert_prog);
 
-	for (i = 0; i < ELEMENTS(progs); i++) {
+	for (i = 0; i < ARRAY_SIZE(progs); i++) {
 		const int x = 1 + (i * (BOX_SIZE + 1));
 
 		glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, progs[i]);
diff --git a/tests/shaders/fp-abs-02.c b/tests/shaders/fp-abs-02.c
index ba8f1a1..16c3e12 100644
--- a/tests/shaders/fp-abs-02.c
+++ b/tests/shaders/fp-abs-02.c
@@ -35,8 +35,6 @@
 #define TEST_COLS  3
 #define BOX_SIZE   32
 
-#define ELEMENTS(x)  (sizeof(x) / sizeof(x[0]))
-
 int piglit_window_mode = GLUT_DOUBLE;
 int piglit_width = (((BOX_SIZE+1)*TEST_COLS)+1);
 int piglit_height = (((BOX_SIZE+1)*TEST_ROWS)+1);
@@ -150,7 +148,7 @@ piglit_display(void)
 
 	glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vert_prog);
 
-	for (i = 0; i < ELEMENTS(progs); i++) {
+	for (i = 0; i < ARRAY_SIZE(progs); i++) {
 		const int x = 1 + (i * (BOX_SIZE + 1));
 
 		glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, progs[i]);
diff --git a/tests/shaders/fp-rfl.c b/tests/shaders/fp-rfl.c
index 1dcb994..8dd4c40 100644
--- a/tests/shaders/fp-rfl.c
+++ b/tests/shaders/fp-rfl.c
@@ -48,8 +48,6 @@ int piglit_window_mode = GLUT_DOUBLE;
 int piglit_width = (((BOX_SIZE + 1) * TEST_COLS)+1);
 int piglit_height = (((BOX_SIZE + 1) * TEST_ROWS)+1);
 
-#define ELEMENTS(x)  (sizeof(x) / sizeof(x[0]))
-
 static const char vert_shader_source[] =
 	"!!ARBvp1.0\n"
 	"ATTRIB	iPos = vertex.position;\n"
@@ -221,7 +219,7 @@ piglit_init(int argc, char **argv)
 	 * random vector across the axis is { 0, 1, 0 }.
 	 */
 	srand(time(NULL));
-	for (i = 0; i < (ELEMENTS(direction) / 4); i++) {
+	for (i = 0; i < (ARRAY_SIZE(direction) / 4); i++) {
 		const double d[3] = {
 			random_float(),
 			random_float(),
diff --git a/tests/shaders/fp-set-01.c b/tests/shaders/fp-set-01.c
index 19e2e6c..2a9a8f0 100644
--- a/tests/shaders/fp-set-01.c
+++ b/tests/shaders/fp-set-01.c
@@ -45,8 +45,6 @@ int piglit_window_mode = GLUT_DOUBLE;
 int piglit_width = (((BOX_SIZE+1)*TEST_COLS)+1);
 int piglit_height = (((BOX_SIZE+1)*TEST_ROWS)+1);
 
-#define ELEMENTS(x)  (sizeof(x) / sizeof(x[0]))
-
 /**
  * Source for the fragment program to render the reference box.
  */
@@ -109,7 +107,7 @@ piglit_display(void)
 
 		glColor4fv(color);
 
-		for (j = 0; j < ELEMENTS(progs); j++) {
+		for (j = 0; j < ARRAY_SIZE(progs); j++) {
 			const int y = ((j + 1) * (BOX_SIZE + 1)) + 1;
 
 			glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, progs[j]);
diff --git a/tests/shaders/fp-set-02.c b/tests/shaders/fp-set-02.c
index 9897f28..682a6ab 100644
--- a/tests/shaders/fp-set-02.c
+++ b/tests/shaders/fp-set-02.c
@@ -60,15 +60,13 @@ struct {
 	{ "SLE", le_func },
 };
 
-#define ELEMENTS(x)  (sizeof(x) / sizeof(x[0]))
-
 /* One column for each possible combination of set-on results
  */
 #define TEST_COLS  (3 * 3 * 3 * 3)
 
 /* One for each set-on opcode and its reference square.
  */
-#define TEST_ROWS  (ELEMENTS(tests) * 2)
+#define TEST_ROWS  (ARRAY_SIZE(tests) * 2)
 
 #define BOX_SIZE   8
 
@@ -100,7 +98,7 @@ static const char shader_template[] =
  */
 /*@{*/
 static GLint reference_prog;
-static GLint progs[ELEMENTS(tests)];
+static GLint progs[ARRAY_SIZE(tests)];
 /*@}*/
 
 int
@@ -169,7 +167,7 @@ piglit_display(void)
 
 	glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, 1, comparitor);
 
-	for (i = 0; i < (2 * ELEMENTS(progs)); i++) {
+	for (i = 0; i < (2 * ARRAY_SIZE(progs)); i++) {
 		const int y = (i * (BOX_SIZE + 1)) + 1;
 		const unsigned idx = i >> 1;
 
@@ -245,7 +243,7 @@ piglit_init(int argc, char **argv)
 	reference_prog = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB,
 						reference_shader_source);
 
-	for (i = 0; i < ELEMENTS(tests); i++) {
+	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		char shader_source[512];
 
 		sprintf(shader_source, shader_template, tests[i].opcode);
diff --git a/tests/shaders/fp-unpack-01.c b/tests/shaders/fp-unpack-01.c
index d5c2e44..0b56e5c 100644
--- a/tests/shaders/fp-unpack-01.c
+++ b/tests/shaders/fp-unpack-01.c
@@ -46,8 +46,6 @@ int piglit_window_mode = GLUT_DOUBLE;
 int piglit_width = (((BOX_SIZE+1)*TEST_COLS)+1);
 int piglit_height = (((BOX_SIZE+1)*TEST_ROWS)+1);
 
-#define ELEMENTS(x)  (sizeof(x) / sizeof(x[0]))
-
 static char shader_source[64 * 1024];
 static GLfloat colors[TEST_COLS][4];
 
@@ -83,7 +81,7 @@ static const char reference_shader_source[] =
  */
 /*@{*/
 static GLint reference_prog;
-static GLint progs[ELEMENTS(types)];
+static GLint progs[ARRAY_SIZE(types)];
 /*@}*/
 
 
@@ -257,7 +255,7 @@ piglit_display(void)
 					    0, colors[i]);
 		piglit_draw_rect(x, 1, BOX_SIZE, BOX_SIZE);
 
-		for (j = 0; j < ELEMENTS(types); j++) {
+		for (j = 0; j < ARRAY_SIZE(types); j++) {
 			const int y = ((j + 1) * (BOX_SIZE + 1)) + 1;
 			GLfloat v[4];
 
@@ -331,7 +329,7 @@ piglit_init(int argc, char **argv)
 
 	glClearColor(1.0, 1.0, 1.0, 1.0);
 
-	for (i = 0; i < ELEMENTS(types); i++) {
+	for (i = 0; i < ARRAY_SIZE(types); i++) {
 		generate_shader(types[i]);
 		progs[i] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB,
 						  shader_source);
@@ -344,7 +342,7 @@ piglit_init(int argc, char **argv)
 		v[i] = ((float) i) / 127.0;
 	}
 
-	for (/* empty */; i < ELEMENTS(v); i++) {
+	for (/* empty */; i < ARRAY_SIZE(v); i++) {
 		v[i] = 0.5;
 	}
 
@@ -354,7 +352,7 @@ piglit_init(int argc, char **argv)
 	 */
 	shuffle(v, 128);
 	for (i = 0; i < TEST_COLS; i++) {
-		assert((i * 3) + 2 < ELEMENTS(v));
+		assert((i * 3) + 2 < ARRAY_SIZE(v));
 
 		colors[i][0] = v[(i * 3) + 0];
 		colors[i][1] = v[(i * 3) + 1];
diff --git a/tests/shaders/gpu_shader4_attribs.c b/tests/shaders/gpu_shader4_attribs.c
index 55f9960..414ac1d 100644
--- a/tests/shaders/gpu_shader4_attribs.c
+++ b/tests/shaders/gpu_shader4_attribs.c
@@ -44,9 +44,6 @@ static GLuint Program;
 #define SIGNED 1
 
 
-#define ELEMENTS(ARRAY)  (sizeof(ARRAY) / sizeof(ARRAY[0]))
-
-
 static GLboolean
 check_error(const char *file, int line)
 {
@@ -474,7 +471,7 @@ test_attrib_array(void)
       ;
 
    /* These should not generate a GL error */
-   for (i = 0; i < ELEMENTS(goodTypes); i++) {
+   for (i = 0; i < ARRAY_SIZE(goodTypes); i++) {
       glVertexAttribIPointerEXT(index, size, goodTypes[i], stride, data);
       err = glGetError();
       if (err != GL_NO_ERROR) {
@@ -485,7 +482,7 @@ test_attrib_array(void)
       }
    }
 
-   for (i = 0; i < ELEMENTS(badTypes); i++) {
+   for (i = 0; i < ARRAY_SIZE(badTypes); i++) {
       glVertexAttribIPointerEXT(index, size, badTypes[i], stride, data);
       err = glGetError();
       if (err != GL_INVALID_ENUM) {
diff --git a/tests/shaders/vp-address-01.c b/tests/shaders/vp-address-01.c
index 9d3da17..c78be80 100644
--- a/tests/shaders/vp-address-01.c
+++ b/tests/shaders/vp-address-01.c
@@ -39,10 +39,8 @@ static const GLfloat attrib[] = {
 	-2.0
 };
 
-#define ELEMENTS(x)  (sizeof(x) / sizeof(x[0]))
-
 #define TEST_ROWS  1
-#define TEST_COLS  ELEMENTS(attrib)
+#define TEST_COLS  ARRAY_SIZE(attrib)
 #define BOX_SIZE   32
 
 
@@ -87,7 +85,7 @@ piglit_display(void)
 	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 2, bad_color);
 	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 3, bad_color);
 
-	for (i = 0; i < ELEMENTS(progs); i++) {
+	for (i = 0; i < ARRAY_SIZE(progs); i++) {
 		const int x = 1 + (i * (BOX_SIZE + 1));
 
 		glBindProgramARB(GL_VERTEX_PROGRAM_ARB, progs[i]);
@@ -135,7 +133,7 @@ piglit_init(int argc, char **argv)
 		piglit_report_result(PIGLIT_FAIL);
 	}
 
-	for (i = 0; i < ELEMENTS(progs); i++) {
+	for (i = 0; i < ARRAY_SIZE(progs); i++) {
 		char shader_source[1024];
 		int offset[2];
 		char direction[2];
diff --git a/tests/shaders/vp-address-02.c b/tests/shaders/vp-address-02.c
index 19cb57a..28a6917 100644
--- a/tests/shaders/vp-address-02.c
+++ b/tests/shaders/vp-address-02.c
@@ -49,10 +49,8 @@ static const GLfloat attrib[] = {
 	2.0, -2.0,
 };
 
-#define ELEMENTS(x)  (sizeof(x) / sizeof(x[0]))
-
 #define TEST_ROWS  1
-#define TEST_COLS  (ELEMENTS(attrib) / 2)
+#define TEST_COLS  (ARRAY_SIZE(attrib) / 2)
 #define BOX_SIZE   32
 
 
@@ -98,7 +96,7 @@ piglit_display(void)
 	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 2, bad_color);
 	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 3, bad_color);
 
-	for (i = 0; i < ELEMENTS(progs); i++) {
+	for (i = 0; i < ARRAY_SIZE(progs); i++) {
 		const int x = 1 + (i * (BOX_SIZE + 1));
 
 		glBindProgramARB(GL_VERTEX_PROGRAM_ARB, progs[i]);
@@ -161,7 +159,7 @@ piglit_init(int argc, char **argv)
 		}
 	}
 
-	for (i = 0; i < ELEMENTS(progs); i++) {
+	for (i = 0; i < ARRAY_SIZE(progs); i++) {
 		char shader_source[1024];
 		int offset[2];
 		char direction[2];
diff --git a/tests/shaders/vp-address-03.c b/tests/shaders/vp-address-03.c
index bb0c038..cfa32e7 100644
--- a/tests/shaders/vp-address-03.c
+++ b/tests/shaders/vp-address-03.c
@@ -31,8 +31,6 @@
 #include "piglit-util.h"
 #include "piglit-framework.h"
 
-#define ELEMENTS(x)  (sizeof(x) / sizeof(x[0]))
-
 #define TEST_ROWS  1
 #define TEST_COLS  4
 #define BOX_SIZE   32
@@ -79,7 +77,7 @@ piglit_display(void)
 	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 2, color);
 	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 3, color);
 
-	for (i = 0; i < ELEMENTS(progs); i++) {
+	for (i = 0; i < ARRAY_SIZE(progs); i++) {
 		const int x = 1 + (i * (BOX_SIZE + 1));
 
 		glBindProgramARB(GL_VERTEX_PROGRAM_ARB, progs[i]);
@@ -118,7 +116,7 @@ piglit_init(int argc, char **argv)
 	piglit_require_extension("GL_NV_vertex_program2_option");
 	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
 
-	for (i = 0; i < ELEMENTS(progs); i++) {
+	for (i = 0; i < ARRAY_SIZE(progs); i++) {
 		char shader_source[1024];
 
 		snprintf(shader_source, sizeof(shader_source),
diff --git a/tests/shaders/vp-address-04.c b/tests/shaders/vp-address-04.c
index 691f1eb..353c62e 100644
--- a/tests/shaders/vp-address-04.c
+++ b/tests/shaders/vp-address-04.c
@@ -68,10 +68,8 @@ static const GLfloat attrib[] = {
 	-2.0, -2.0,
 };
 
-#define ELEMENTS(x)  (sizeof(x) / sizeof(x[0]))
-
 #define TEST_ROWS  16
-#define TEST_COLS  (ELEMENTS(attrib) / 2)
+#define TEST_COLS  (ARRAY_SIZE(attrib) / 2)
 #define BOX_SIZE   16
 
 
diff --git a/tests/shaders/vp-address-05.c b/tests/shaders/vp-address-05.c
index 8ae521a..8573637 100644
--- a/tests/shaders/vp-address-05.c
+++ b/tests/shaders/vp-address-05.c
@@ -31,8 +31,6 @@
 #include "piglit-util.h"
 #include "piglit-framework.h"
 
-#define ELEMENTS(x)  (sizeof(x) / sizeof(x[0]))
-
 #define TEST_ROWS  1
 #define TEST_COLS  4
 #define BOX_SIZE   32
@@ -86,7 +84,7 @@ piglit_display(void)
 	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 2, color);
 	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 3, bad_color);
 
-	for (i = 0; i < ELEMENTS(progs); i++) {
+	for (i = 0; i < ARRAY_SIZE(progs); i++) {
 		const int x = 1 + (i * (BOX_SIZE + 1));
 
 		glBindProgramARB(GL_VERTEX_PROGRAM_ARB, progs[i]);
@@ -121,7 +119,7 @@ piglit_init(int argc, char **argv)
 	piglit_require_extension("GL_NV_vertex_program2_option");
 	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
 
-	for (i = 0; i < ELEMENTS(progs); i++) {
+	for (i = 0; i < ARRAY_SIZE(progs); i++) {
 		char shader_source[1024];
 
 		snprintf(shader_source, sizeof(shader_source),
diff --git a/tests/shaders/vp-address-06.c b/tests/shaders/vp-address-06.c
index bf4a552..17d981e 100644
--- a/tests/shaders/vp-address-06.c
+++ b/tests/shaders/vp-address-06.c
@@ -31,8 +31,6 @@
 #include "piglit-util.h"
 #include "piglit-framework.h"
 
-#define ELEMENTS(x)  (sizeof(x) / sizeof(x[0]))
-
 #define TEST_ROWS  1
 #define TEST_COLS  2
 #define BOX_SIZE   32
@@ -85,7 +83,7 @@ piglit_display(void)
 	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 2, color);
 	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 3, bad_color);
 
-	for (i = 0; i < ELEMENTS(progs); i++) {
+	for (i = 0; i < ARRAY_SIZE(progs); i++) {
 		const int x = 1 + (i * (BOX_SIZE + 1));
 
 		glBindProgramARB(GL_VERTEX_PROGRAM_ARB, progs[i]);
@@ -120,7 +118,7 @@ piglit_init(int argc, char **argv)
 	piglit_require_extension("GL_NV_vertex_program2_option");
 	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
 
-	for (i = 0; i < ELEMENTS(progs); i++) {
+	for (i = 0; i < ARRAY_SIZE(progs); i++) {
 		char shader_source[1024];
 
 		snprintf(shader_source, sizeof(shader_source),
diff --git a/tests/shaders/vp-clipdistance-01.c b/tests/shaders/vp-clipdistance-01.c
index c66cae8..daff12f 100644
--- a/tests/shaders/vp-clipdistance-01.c
+++ b/tests/shaders/vp-clipdistance-01.c
@@ -31,8 +31,6 @@
 #include "piglit-util.h"
 #include "piglit-framework.h"
 
-#define ELEMENTS(x)  (sizeof(x) / sizeof(x[0]))
-
 #define TEST_ROWS  1
 #define TEST_COLS  6
 #define BOX_SIZE   32
@@ -92,7 +90,7 @@ piglit_display(void)
 	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 2, color);
 	glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 3, color);
 
-	for (i = 0; i < ELEMENTS(progs); i++) {
+	for (i = 0; i < ARRAY_SIZE(progs); i++) {
 		const int x = 1 + (i * (BOX_SIZE + 1));
 
 		glBindProgramARB(GL_VERTEX_PROGRAM_ARB, progs[i]);
@@ -132,7 +130,7 @@ piglit_init(int argc, char **argv)
 	piglit_require_extension("GL_NV_vertex_program2_option");
 	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
 
-	for (i = 0; i < ELEMENTS(progs); i++) {
+	for (i = 0; i < ARRAY_SIZE(progs); i++) {
 		char shader_source[1024];
 
 		snprintf(shader_source, sizeof(shader_source),
diff --git a/tests/shaders/vp-clipdistance-02.c b/tests/shaders/vp-clipdistance-02.c
index 81ff930..c7f29ef 100644
--- a/tests/shaders/vp-clipdistance-02.c
+++ b/tests/shaders/vp-clipdistance-02.c
@@ -35,8 +35,6 @@
 #include "piglit-util.h"
 #include "piglit-framework.h"
 
-#define ELEMENTS(x)  (sizeof(x) / sizeof(x[0]))
-
 #define TEST_ROWS  1
 #define TEST_COLS  6
 #define BOX_SIZE   32
@@ -93,7 +91,7 @@ piglit_display(void)
 	for (i = 0; i < 6; i++)
 		glEnable(GL_CLIP_PLANE0 + i);
 
-	for (i = 0; i < ELEMENTS(progs); i++) {
+	for (i = 0; i < ARRAY_SIZE(progs); i++) {
 		const int x = 1 + (i * (BOX_SIZE + 1));
 
 		glBindProgramARB(GL_VERTEX_PROGRAM_ARB, progs[i]);
@@ -127,7 +125,7 @@ piglit_init(int argc, char **argv)
 	piglit_require_extension("GL_NV_vertex_program2_option");
 	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
 
-	for (i = 0; i < ELEMENTS(progs); i++) {
+	for (i = 0; i < ARRAY_SIZE(progs); i++) {
 		char shader_source[1024];
 
 		snprintf(shader_source, sizeof(shader_source),
diff --git a/tests/shaders/vp-clipdistance-03.c b/tests/shaders/vp-clipdistance-03.c
index 50dcb8a..c30dc02 100644
--- a/tests/shaders/vp-clipdistance-03.c
+++ b/tests/shaders/vp-clipdistance-03.c
@@ -31,8 +31,6 @@
 #include "piglit-util.h"
 #include "piglit-framework.h"
 
-#define ELEMENTS(x)  (sizeof(x) / sizeof(x[0]))
-
 #define TEST_ROWS  1
 #define TEST_COLS  1
 #define BOX_SIZE   32
@@ -78,7 +76,7 @@ piglit_display(void)
 
 	glClear(GL_COLOR_BUFFER_BIT);
 
-	for (i = 0; i < ELEMENTS(progs); i++) {
+	for (i = 0; i < ARRAY_SIZE(progs); i++) {
 		const int x = 1 + (i * (BOX_SIZE + 1));
 
 		glBindProgramARB(GL_VERTEX_PROGRAM_ARB, progs[i]);
@@ -112,7 +110,7 @@ piglit_init(int argc, char **argv)
 	piglit_require_extension("GL_NV_vertex_program2_option");
 	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
 
-	for (i = 0; i < ELEMENTS(progs); i++) {
+	for (i = 0; i < ARRAY_SIZE(progs); i++) {
 		char shader_source[1024];
 
 		snprintf(shader_source, sizeof(shader_source),
diff --git a/tests/shaders/vp-clipdistance-04.c b/tests/shaders/vp-clipdistance-04.c
index 4b4afca..3b43c3b 100644
--- a/tests/shaders/vp-clipdistance-04.c
+++ b/tests/shaders/vp-clipdistance-04.c
@@ -35,8 +35,6 @@
 #include "piglit-util.h"
 #include "piglit-framework.h"
 
-#define ELEMENTS(x)  (sizeof(x) / sizeof(x[0]))
-
 #define TEST_ROWS  1
 #define TEST_COLS  6
 #define BOX_SIZE   32
@@ -82,7 +80,7 @@ piglit_display(void)
 
 	glClear(GL_COLOR_BUFFER_BIT);
 
-	for (i = 0; i < ELEMENTS(progs); i++) {
+	for (i = 0; i < ARRAY_SIZE(progs); i++) {
 		const int x = 1 + (i * (BOX_SIZE + 1));
 		const GLenum p = GL_CLIP_PLANE0 + ((i + 1) % 6);
 
@@ -117,7 +115,7 @@ piglit_init(int argc, char **argv)
 	piglit_require_extension("GL_NV_vertex_program2_option");
 	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
 
-	for (i = 0; i < ELEMENTS(progs); i++) {
+	for (i = 0; i < ARRAY_SIZE(progs); i++) {
 		char shader_source[1024];
 
 		snprintf(shader_source, sizeof(shader_source),
diff --git a/tests/spec/arb_texture_float/texture-float-formats.c b/tests/spec/arb_texture_float/texture-float-formats.c
index 07d8611..2856dd3 100644
--- a/tests/spec/arb_texture_float/texture-float-formats.c
+++ b/tests/spec/arb_texture_float/texture-float-formats.c
@@ -28,8 +28,6 @@
 
 #include "piglit-util.h"
 
-#define ELEMENTS(ARRAY)  (sizeof(ARRAY) / sizeof(ARRAY[0]))
-
 int piglit_width = 100, piglit_height = 100;
 int piglit_window_mode = GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE;
 static const char *TestName = "texture-float-formats";
@@ -244,7 +242,7 @@ test_format(const struct format_info *info)
          "GL_TEXTURE_DEPTH_TYPE_ARB"
       };
       int i;
-      for (i = 0; i < ELEMENTS(queries); i++) {
+      for (i = 0; i < ARRAY_SIZE(queries); i++) {
          GLint type = 1;
          glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, queries[i], &type);
          if (check_error(__FILE__, __LINE__))
@@ -348,7 +346,7 @@ piglit_display(void)
    int f;
    GLboolean pass = GL_TRUE;
 
-   for (f = 0; f < ELEMENTS(Formats); f++)
+   for (f = 0; f < ARRAY_SIZE(Formats); f++)
       if (!test_format(&Formats[f]))
          pass = GL_FALSE;
 
diff --git a/tests/spec/ext_texture_integer/api-teximage.c b/tests/spec/ext_texture_integer/api-teximage.c
index 92ff58b..b172ca1 100644
--- a/tests/spec/ext_texture_integer/api-teximage.c
+++ b/tests/spec/ext_texture_integer/api-teximage.c
@@ -30,8 +30,6 @@
 
 #include "piglit-util.h"
 
-#define ELEMENTS(ARRAY)  (sizeof(ARRAY) / sizeof(ARRAY[0]))
-
 int piglit_width = 10, piglit_height = 10;
 int piglit_window_mode = GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE;
 
diff --git a/tests/texturing/texture-integer.c b/tests/texturing/texture-integer.c
index 0ae62e8..a256e0a 100644
--- a/tests/texturing/texture-integer.c
+++ b/tests/texturing/texture-integer.c
@@ -29,8 +29,6 @@
 
 #include "piglit-util.h"
 
-#define ELEMENTS(ARRAY)  (sizeof(ARRAY) / sizeof(ARRAY[0]))
-
 
 int piglit_width = 100, piglit_height = 100;
 int piglit_window_mode = GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE;
@@ -423,7 +421,7 @@ test_specific_formats(void)
    while (glGetError() != GL_NO_ERROR)
       ;
 
-   for (i = 0; i < ELEMENTS(formats); i++) {
+   for (i = 0; i < ARRAY_SIZE(formats); i++) {
       glTexImage2D(GL_TEXTURE_2D, 0, formats[i].intFormat,
                    16, 16, 0,
                    formats[i].srcFormat, formats[i].srcType, NULL);
-- 
1.7.7.6



More information about the Piglit mailing list