Rename Elements ARRAY_SIZE

Similar to upstream mesa change
macos/master
Marc-André Lureau 10 years ago committed by Dave Airlie
parent cd69deebad
commit dbd90fb682
  1. 2
      src/gallium/auxiliary/os/os_process.c
  2. 2
      src/gallium/auxiliary/tgsi/tgsi_info.c
  3. 6
      src/gallium/auxiliary/tgsi/tgsi_scan.c
  4. 16
      src/gallium/auxiliary/tgsi/tgsi_strings.c
  5. 8
      src/gallium/auxiliary/tgsi/tgsi_text.c
  6. 10
      src/gallium/auxiliary/tgsi/tgsi_ureg.c
  7. 2
      src/gallium/auxiliary/util/u_debug.c
  8. 4
      src/gallium/auxiliary/util/u_memory.h
  9. 2
      src/vrend_formats.c

@ -56,7 +56,7 @@ os_get_process_name(char *procname, size_t size)
char *lpProcessName; char *lpProcessName;
char *lpProcessExt; char *lpProcessExt;
GetModuleFileNameA(NULL, szProcessPath, Elements(szProcessPath)); GetModuleFileNameA(NULL, szProcessPath, ARRAY_SIZE(szProcessPath));
lpProcessName = strrchr(szProcessPath, '\\'); lpProcessName = strrchr(szProcessPath, '\\');
lpProcessName = lpProcessName ? lpProcessName + 1 : szProcessPath; lpProcessName = lpProcessName ? lpProcessName + 1 : szProcessPath;

@ -245,7 +245,7 @@ tgsi_get_opcode_info( uint opcode )
if (firsttime) { if (firsttime) {
unsigned i; unsigned i;
firsttime = 0; firsttime = 0;
for (i = 0; i < Elements(opcode_info); i++) for (i = 0; i < ARRAY_SIZE(opcode_info); i++)
assert(opcode_info[i].opcode == i); assert(opcode_info[i].opcode == i);
} }

@ -60,7 +60,7 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
memset(info, 0, sizeof(*info)); memset(info, 0, sizeof(*info));
for (i = 0; i < TGSI_FILE_COUNT; i++) for (i = 0; i < TGSI_FILE_COUNT; i++)
info->file_max[i] = -1; info->file_max[i] = -1;
for (i = 0; i < Elements(info->const_file_max); i++) for (i = 0; i < ARRAY_SIZE(info->const_file_max); i++)
info->const_file_max[i] = -1; info->const_file_max[i] = -1;
/** /**
@ -136,7 +136,7 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
/* MSAA samplers */ /* MSAA samplers */
if (src->Register.File == TGSI_FILE_SAMPLER) { if (src->Register.File == TGSI_FILE_SAMPLER) {
assert(fullinst->Instruction.Texture); assert(fullinst->Instruction.Texture);
assert(src->Register.Index < Elements(info->is_msaa_sampler)); assert(src->Register.Index < ARRAY_SIZE(info->is_msaa_sampler));
if (fullinst->Instruction.Texture && if (fullinst->Instruction.Texture &&
(fullinst->Texture.Texture == TGSI_TEXTURE_2D_MSAA || (fullinst->Texture.Texture == TGSI_TEXTURE_2D_MSAA ||
@ -299,7 +299,7 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
= &parse.FullToken.FullProperty; = &parse.FullToken.FullProperty;
unsigned name = fullprop->Property.PropertyName; unsigned name = fullprop->Property.PropertyName;
assert(name < Elements(info->properties)); assert(name < ARRAY_SIZE(info->properties));
info->properties[name] = fullprop->u[0].Data; info->properties[name] = fullprop->u[0].Data;
} }
break; break;

@ -192,12 +192,12 @@ const char *tgsi_immediate_type_names[3] =
static inline void static inline void
tgsi_strings_check(void) tgsi_strings_check(void)
{ {
STATIC_ASSERT(Elements(tgsi_semantic_names) == TGSI_SEMANTIC_COUNT); STATIC_ASSERT(ARRAY_SIZE(tgsi_semantic_names) == TGSI_SEMANTIC_COUNT);
STATIC_ASSERT(Elements(tgsi_texture_names) == TGSI_TEXTURE_COUNT); STATIC_ASSERT(ARRAY_SIZE(tgsi_texture_names) == TGSI_TEXTURE_COUNT);
STATIC_ASSERT(Elements(tgsi_property_names) == TGSI_PROPERTY_COUNT); STATIC_ASSERT(ARRAY_SIZE(tgsi_property_names) == TGSI_PROPERTY_COUNT);
STATIC_ASSERT(Elements(tgsi_primitive_names) == PIPE_PRIM_MAX); STATIC_ASSERT(ARRAY_SIZE(tgsi_primitive_names) == PIPE_PRIM_MAX);
STATIC_ASSERT(Elements(tgsi_interpolate_names) == TGSI_INTERPOLATE_COUNT); STATIC_ASSERT(ARRAY_SIZE(tgsi_interpolate_names) == TGSI_INTERPOLATE_COUNT);
STATIC_ASSERT(Elements(tgsi_return_type_names) == TGSI_RETURN_TYPE_COUNT); STATIC_ASSERT(ARRAY_SIZE(tgsi_return_type_names) == TGSI_RETURN_TYPE_COUNT);
(void) tgsi_processor_type_names; (void) tgsi_processor_type_names;
(void) tgsi_return_type_names; (void) tgsi_return_type_names;
(void) tgsi_immediate_type_names; (void) tgsi_immediate_type_names;
@ -209,8 +209,8 @@ tgsi_strings_check(void)
const char * const char *
tgsi_file_name(unsigned file) tgsi_file_name(unsigned file)
{ {
STATIC_ASSERT(Elements(tgsi_file_names) == TGSI_FILE_COUNT); STATIC_ASSERT(ARRAY_SIZE(tgsi_file_names) == TGSI_FILE_COUNT);
if (file < Elements(tgsi_file_names)) if (file < ARRAY_SIZE(tgsi_file_names))
return tgsi_file_names[file]; return tgsi_file_names[file];
else else
return "invalid file"; return "invalid file";

@ -1448,11 +1448,11 @@ static boolean parse_immediate( struct translate_ctx *ctx )
report_error( ctx, "Syntax error" ); report_error( ctx, "Syntax error" );
return FALSE; return FALSE;
} }
for (type = 0; type < Elements(tgsi_immediate_type_names); ++type) { for (type = 0; type < ARRAY_SIZE(tgsi_immediate_type_names); ++type) {
if (str_match_nocase_whole(&ctx->cur, tgsi_immediate_type_names[type])) if (str_match_nocase_whole(&ctx->cur, tgsi_immediate_type_names[type]))
break; break;
} }
if (type == Elements(tgsi_immediate_type_names)) { if (type == ARRAY_SIZE(tgsi_immediate_type_names)) {
report_error( ctx, "Expected immediate type" ); report_error( ctx, "Expected immediate type" );
return FALSE; return FALSE;
} }
@ -1498,7 +1498,7 @@ parse_fs_coord_origin( const char **pcur, uint *fs_coord_origin )
{ {
uint i; uint i;
for (i = 0; i < Elements(tgsi_fs_coord_origin_names); i++) { for (i = 0; i < ARRAY_SIZE(tgsi_fs_coord_origin_names); i++) {
const char *cur = *pcur; const char *cur = *pcur;
if (str_match_nocase_whole( &cur, tgsi_fs_coord_origin_names[i])) { if (str_match_nocase_whole( &cur, tgsi_fs_coord_origin_names[i])) {
@ -1515,7 +1515,7 @@ parse_fs_coord_pixel_center( const char **pcur, uint *fs_coord_pixel_center )
{ {
uint i; uint i;
for (i = 0; i < Elements(tgsi_fs_coord_pixel_center_names); i++) { for (i = 0; i < ARRAY_SIZE(tgsi_fs_coord_pixel_center_names); i++) {
const char *cur = *pcur; const char *cur = *pcur;
if (str_match_nocase_whole( &cur, tgsi_fs_coord_pixel_center_names[i])) { if (str_match_nocase_whole( &cur, tgsi_fs_coord_pixel_center_names[i])) {

@ -182,7 +182,7 @@ static void tokens_error( struct ureg_tokens *tokens )
FREE(tokens->tokens); FREE(tokens->tokens);
tokens->tokens = error_tokens; tokens->tokens = error_tokens;
tokens->size = Elements(error_tokens); tokens->size = ARRAY_SIZE(error_tokens);
tokens->count = 0; tokens->count = 0;
} }
@ -272,7 +272,7 @@ ureg_dst_register( unsigned file,
void void
ureg_property(struct ureg_program *ureg, unsigned name, unsigned value) ureg_property(struct ureg_program *ureg, unsigned name, unsigned value)
{ {
assert(name < Elements(ureg->properties)); assert(name < ARRAY_SIZE(ureg->properties));
ureg->properties[name] = value; ureg->properties[name] = value;
} }
@ -1389,7 +1389,7 @@ static void emit_decls( struct ureg_program *ureg )
{ {
unsigned i; unsigned i;
for (i = 0; i < Elements(ureg->properties); i++) for (i = 0; i < ARRAY_SIZE(ureg->properties); i++)
if (ureg->properties[i] != ~0) if (ureg->properties[i] != ~0)
emit_property(ureg, i, ureg->properties[i]); emit_property(ureg, i, ureg->properties[i]);
@ -1649,7 +1649,7 @@ struct ureg_program *ureg_create( unsigned processor )
ureg->processor = processor; ureg->processor = processor;
for (i = 0; i < Elements(ureg->properties); i++) for (i = 0; i < ARRAY_SIZE(ureg->properties); i++)
ureg->properties[i] = ~0; ureg->properties[i] = ~0;
ureg->free_temps = util_bitmask_create(); ureg->free_temps = util_bitmask_create();
@ -1690,7 +1690,7 @@ void ureg_destroy( struct ureg_program *ureg )
{ {
unsigned i; unsigned i;
for (i = 0; i < Elements(ureg->domain); i++) { for (i = 0; i < ARRAY_SIZE(ureg->domain); i++) {
if (ureg->domain[i].tokens && if (ureg->domain[i].tokens &&
ureg->domain[i].tokens != error_tokens) ureg->domain[i].tokens != error_tokens)
FREE(ureg->domain[i].tokens); FREE(ureg->domain[i].tokens);

@ -491,7 +491,7 @@ debug_print_transfer_flags(const char *msg, unsigned usage)
debug_printf("%s ", msg); debug_printf("%s ", msg);
for (i = 0; i < Elements(flags); i++) { for (i = 0; i < ARRAY_SIZE(flags); i++) {
if (usage & flags[i].bit) { if (usage & flags[i].bit) {
debug_printf("%s", flags[i].name); debug_printf("%s", flags[i].name);
usage &= ~flags[i].bit; usage &= ~flags[i].bit;

@ -80,8 +80,8 @@ mem_dup(const void *src, uint size)
/** /**
* Number of elements in an array. * Number of elements in an array.
*/ */
#ifndef Elements #ifndef ARRAY_SIZE
#define Elements(x) (sizeof(x)/sizeof((x)[0])) #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
#endif #endif

@ -314,7 +314,7 @@ static void vrend_add_formats(struct vrend_format_table *table, int num_entries)
} }
} }
#define add_formats(x) vrend_add_formats((x), Elements((x))) #define add_formats(x) vrend_add_formats((x), ARRAY_SIZE((x)))
void vrend_build_format_list(void) void vrend_build_format_list(void)
{ {

Loading…
Cancel
Save