diff options
author | Paul Berry <stereotype441@gmail.com> | 2012-01-25 14:34:00 -0800 |
---|---|---|
committer | Paul Berry <stereotype441@gmail.com> | 2012-01-27 10:24:59 -0800 |
commit | 90e906e817879b499594023794761c9bcb98d9dd (patch) | |
tree | 271365cfcf535a8e7b1fd2cadef8a1ee4adcc6e3 /tests | |
parent | d6ce2ad3f212934882049efb681292818062750b (diff) |
Change ELEMENTS macros to ARRAY_SIZE.
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().
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'tests')
25 files changed, 45 insertions, 98 deletions
diff --git a/tests/fbo/fbo-storage-completeness.c b/tests/fbo/fbo-storage-completeness.c index f8d4adbb0..8c099cdc3 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 70c1d84c5..71bfc4566 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 02628cd77..aa46caadf 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 a9ec91777..7a3ad68f8 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 232a6d2df..ab95940d0 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 48047bd8c..6f87dc052 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 ba8f1a1d5..16c3e1260 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 1dcb9944f..8dd4c40ce 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 19e2e6ccd..2a9a8f02d 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 9897f28c6..682a6aba4 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 d5c2e444f..0b56e5ca5 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 55f99601b..414ac1d76 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 9d3da173d..c78be80b3 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 19cb57af5..28a69174f 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 bb0c03825..cfa32e7a3 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 691f1ebce..353c62e8d 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 8ae521a09..8573637c4 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 bf4a552cb..17d981e50 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 c66cae86c..daff12f39 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 81ff93004..c7f29efc6 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 50dcb8acf..c30dc02cb 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 4b4afcada..3b43c3b49 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 07d8611ea..2856dd3ee 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 92ff58beb..b172ca182 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 0ae62e893..a256e0ac0 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); |